Skip to content

Commit 268674d

Browse files
Merge pull request #20 from technikhil314/develop
Develop
2 parents 55c293a + 5c216f0 commit 268674d

File tree

3 files changed

+318
-52
lines changed

3 files changed

+318
-52
lines changed

pages/diff.vue

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
v-for="(lineDiff, index) in lhsDiff"
6161
:key="index"
6262
:class="{
63-
'bg-red-100 dark:bg-yellow-700': lineDiff.includes('isModified'),
63+
'bg-red-200 dark:bg-red-800': lineDiff.includes('isModified'),
6464
}"
6565
>
6666
<p class="break-all whitespace-pre-wrap" v-html="lineDiff"></p>
@@ -74,7 +74,7 @@
7474
v-for="(lineDiff, index) in rhsDiff"
7575
:key="index"
7676
:class="{
77-
'bg-green-100 dark:bg-green-700': lineDiff.includes('isModified'),
77+
'bg-green-200 dark:bg-green-700': lineDiff.includes('isModified'),
7878
}"
7979
>
8080
<p class="break-all whitespace-pre-wrap" v-html="lineDiff"></p>
@@ -89,9 +89,9 @@
8989
<script>
9090
import pako from 'pako'
9191
import { undoUrlSafeBase64, escapeHtml } from '../helpers/utils'
92-
import footer from '~/components/footer.vue'
92+
import Footer from '~/components/footer.vue'
9393
export default {
94-
components: { footer },
94+
components: { Footer },
9595
layout: 'main',
9696
data() {
9797
return {
@@ -100,9 +100,6 @@ export default {
100100
copied: false,
101101
}
102102
},
103-
asyncData() {
104-
return { name: 'World' }
105-
},
106103
mounted() {
107104
const _diff = this.$route.hash
108105
const gunzip = pako.ungzip(Buffer.from(undoUrlSafeBase64(_diff), 'base64'))
@@ -112,7 +109,7 @@ export default {
112109
const hunkState = item[0]
113110
if (hunkState === -1 || hunkState === 0) {
114111
const className =
115-
hunkState === -1 ? 'isModified bg-red-300 dark:bg-yellow-900' : ''
112+
hunkState === -1 ? 'isModified bg-red-300 dark:bg-red-500' : ''
116113
return `<span class="break-all inline p-0 m-0 ${className}">${escapeHtml(
117114
item[1]
118115
)}</span>`
@@ -127,7 +124,7 @@ export default {
127124
const hunkState = item[0]
128125
if (hunkState === 1 || hunkState === 0) {
129126
const className =
130-
hunkState === 1 ? 'isModified bg-green-300 dark:bg-green-900' : ''
127+
hunkState === 1 ? 'isModified bg-green-400 dark:bg-green-900' : ''
131128
return `<span class="break-all inline p-0 m-0 ${className}">${escapeHtml(
132129
item[1]
133130
)}</span>`
@@ -191,6 +188,9 @@ export default {
191188
</script>
192189

193190
<style lang="scss">
191+
::selection {
192+
@apply bg-gray-800 text-gray-300 dark:bg-gray-200 dark:text-gray-800;
193+
}
194194
.copy-uri-button:hover {
195195
@apply shadow-lg;
196196
svg {
@@ -206,31 +206,24 @@ export default {
206206
&::before {
207207
content: '';
208208
width: var(--line-number-gutter-width);
209-
@apply bg-gray-200 dark:bg-gray-700 inline-block left-0 top-0 bottom-0 absolute text-sm;
209+
@apply bg-gray-300 dark:bg-gray-700 inline-block left-0 top-0 bottom-0 absolute text-sm;
210210
}
211211
@apply relative;
212212
p {
213213
padding-left: calc(var(--line-number-gutter-width) - 10px);
214214
line-height: 1.65;
215215
@apply relative;
216216
&:hover {
217-
@apply bg-gray-200 dark:bg-gray-700;
217+
@apply bg-gray-200 dark:bg-gray-600;
218+
span {
219+
@apply dark:mix-blend-hard-light dark:bg-blend-multiply;
220+
}
218221
}
219222
&::before {
220223
counter-increment: line-numbers;
221224
content: counter(line-numbers);
222225
width: var(--line-number-gutter-width);
223-
@apply absolute left-0 top-0 -mx-4 bottom-0 text-center bg-gray-200 dark:bg-gray-700 dark:text-gray-50 text-gray-500 flex justify-center text-sm;
224-
}
225-
&:first-of-type {
226-
&::before {
227-
@apply -mt-2 pt-2;
228-
}
229-
}
230-
&:last-of-type {
231-
&::before {
232-
@apply -mb-2 pb-2;
233-
}
226+
@apply absolute left-0 top-0 -mx-4 bg-gray-200 dark:bg-gray-700 dark:text-gray-50 text-gray-500 inline-flex justify-center items-center text-sm h-full;
234227
}
235228
}
236229
}

pages/index.vue

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,47 @@
1212
</h2>
1313
</header>
1414
</section>
15-
<form class="w-full" @submit="checkForm">
16-
<div class="flex flex-wrap w-full gap-4">
17-
<textarea
18-
rows="28"
19-
id="lhs"
20-
class="flex-1 bg-transparent rounded-md resize-none form-textarea"
21-
></textarea>
22-
<textarea
23-
id="rhs"
24-
rows="28"
25-
class="flex-1 bg-transparent rounded-md resize-none form-textarea"
26-
></textarea>
27-
<div class="self-end flex-grow-0 w-full text-center">
28-
<button
29-
class="inline-flex items-center justify-center w-48 px-4 py-2 transition-transform transform bg-blue-600 rounded-md shadow-lg outline-none text-gray-50 focus:ring-4 active:scale-y-75"
30-
>
31-
Compare
32-
</button>
15+
<form class="flex flex-col w-full gap-4" @submit="checkForm">
16+
<section class="flex w-full gap-4">
17+
<div class="flex flex-col flex-wrap w-1/2 gap-4">
18+
<label for="lhsLabel" class="relative">
19+
<input
20+
id="lhsLabel"
21+
name="lhsLabel"
22+
type="text"
23+
class="flex-1 flex-grow-0 w-full bg-transparent rounded-md material-input"
24+
placeholder="Add label to this text block"
25+
/>
26+
</label>
27+
<textarea
28+
id="lhs"
29+
rows="28"
30+
name="lhs"
31+
class="flex-1 w-full bg-transparent rounded-md resize-none form-textarea"
32+
></textarea>
33+
</div>
34+
<div class="flex flex-col flex-wrap w-1/2 gap-4">
35+
<input
36+
id="rhsLabel"
37+
name="rhsLabel"
38+
type="text"
39+
class="flex-1 flex-grow-0 w-full bg-transparent rounded-md material-input"
40+
placeholder="Add label to this text block"
41+
/>
42+
<textarea
43+
id="rhs"
44+
rows="28"
45+
name="rhs"
46+
class="flex-1 w-full bg-transparent rounded-md resize-none form-textarea"
47+
></textarea>
3348
</div>
49+
</section>
50+
<div class="self-end flex-grow-0 w-full text-center">
51+
<button
52+
class="inline-flex items-center justify-center w-48 px-4 py-2 transition-transform transform bg-blue-600 rounded-md shadow-lg outline-none text-gray-50 focus:ring-4 active:scale-y-75"
53+
>
54+
Compare
55+
</button>
3456
</div>
3557
</form>
3658
</main>
@@ -49,14 +71,12 @@ export default Vue.extend({
4971
methods: {
5072
checkForm(e: Event) {
5173
e.preventDefault()
52-
const lhsTextArea: HTMLTextAreaElement = document.getElementById(
53-
'lhs'
54-
) as HTMLTextAreaElement
55-
const lhs: string = lhsTextArea?.value || ''
56-
const rhsTextArea: HTMLTextAreaElement = document.getElementById(
57-
'rhs'
58-
) as HTMLTextAreaElement
59-
const rhs: string = rhsTextArea?.value || ''
74+
const formData = new FormData(e.currentTarget as HTMLFormElement)
75+
// const formDataJson = Object.fromEntries(formData.entries())
76+
const lhs = formData.get('lhs')
77+
const rhs = formData.get('rhs')
78+
const lhsLabel = formData.get('lhsLabel')
79+
const rhsLabel = formData.get('rhsLabel')
6080
if (!lhs || !rhs) {
6181
this.$store.commit('toast/show', {
6282
show: true,
@@ -84,11 +104,17 @@ export default Vue.extend({
84104
const originalLhs = lhs
85105
const originalRhs = rhs
86106
const diff = dmp.diff_main(originalLhs, originalRhs)
87-
const gzip = Buffer.from(pako.gzip(JSON.stringify(diff))).toString(
88-
'base64'
89-
)
107+
const gzip = Buffer.from(
108+
pako.gzip(
109+
JSON.stringify({
110+
diff,
111+
lhsLabel,
112+
rhsLabel,
113+
})
114+
)
115+
).toString('base64')
90116
this.$router.push({
91-
path: '/diff',
117+
path: '/v1/diff',
92118
hash: `#${doUrlSafeBase64(gzip)}`,
93119
})
94120
},

0 commit comments

Comments
 (0)