Skip to content

Commit be282b6

Browse files
committed
fix: using mono font for diff and enabling word wrap
1 parent cdfb574 commit be282b6

File tree

3 files changed

+45
-50
lines changed

3 files changed

+45
-50
lines changed

layouts/main.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<template>
22
<div class="w-full h-full">
3-
<Navbar />
43
<Nuxt />
54
</div>
65
</template>

pages/diff/_diff.vue

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="w-full h-full">
2+
<div class="contents">
33
<Navbar show-back-button="true">
44
<template v-slot:right>
55
<button
@@ -25,26 +25,24 @@
2525
</button>
2626
</template>
2727
</Navbar>
28-
<div class="h-full">
29-
<main class="h-full mt-24 xl:container">
30-
<div class="flex gap-4 mt-5">
31-
<div
32-
class="flex-1 p-4 overflow-y-auto border-2 rounded-sm max-h-screen--nav"
33-
>
34-
<p v-for="(lineDiff, index) in lhsDiff" :key="index">
35-
<span v-html="lineDiff"></span>
36-
</p>
37-
</div>
38-
<div
39-
class="flex-1 p-4 overflow-y-auto border-2 rounded-sm max-h-screen--nav"
40-
>
41-
<p v-for="(lineDiff, index) in rhsDiff" :key="index">
42-
<span v-html="lineDiff"></span>
43-
</p>
44-
</div>
28+
<main class="h-full mt-24 xl:container">
29+
<div class="flex gap-4 mt-5">
30+
<div
31+
class="flex-1 p-4 overflow-y-auto border-2 rounded-sm max-h-screen--nav"
32+
>
33+
<p v-for="(lineDiff, index) in lhsDiff" :key="index">
34+
<span v-html="lineDiff"></span>
35+
</p>
36+
</div>
37+
<div
38+
class="flex-1 p-4 overflow-y-auto border-2 rounded-sm max-h-screen--nav"
39+
>
40+
<p v-for="(lineDiff, index) in rhsDiff" :key="index">
41+
<span v-html="lineDiff"></span>
42+
</p>
4543
</div>
46-
</main>
47-
</div>
44+
</div>
45+
</main>
4846
</div>
4947
</template>
5048

@@ -60,7 +58,7 @@ export default {
6058
.map((item) => {
6159
if (item[0] === -1 || item[0] === 0) {
6260
const className = item[0] === -1 ? 'bg-red-300' : ''
63-
return `<pre class="inline mr-[-4px] p-0 m-0 ${className}">${item[1]}</pre>`
61+
return `<span class="whitespace-pre-wrap font-mono break-all inline mr-[-4px] p-0 m-0 ${className}">${item[1]}</span>`
6462
}
6563
return ''
6664
})
@@ -74,7 +72,7 @@ export default {
7472
.map((item) => {
7573
if (item[0] === 1 || item[0] === 0) {
7674
const className = item[0] === 1 ? 'bg-green-300' : ''
77-
return `<pre class="inline mr-[-4px] p-0 m-0 ${className}">${item[1]}</pre>`
75+
return `<span class="whitespace-pre-wrap font-mono break-all inline mr-[-4px] p-0 m-0 ${className}">${item[1]}</span>`
7876
}
7977
return ''
8078
})
@@ -91,7 +89,6 @@ export default {
9189
},
9290
methods: {
9391
copyUrlToClipboard() {
94-
console.log('demo')
9592
navigator.clipboard.writeText(window.location.href)
9693
},
9794
},

pages/index.vue

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
11
<template>
2-
<div class="w-full h-full">
2+
<div class="contents">
33
<Navbar />
4-
<div class="h-full">
5-
<main class="flex flex-wrap h-full mt-20 xl:container">
6-
<p class="w-full mb-2 text-xl text-center">
7-
Insert your data below to find the difference in them
8-
</p>
9-
<form @submit="checkForm" class="w-full h-full">
10-
<div class="flex flex-wrap w-full h-full gap-4">
11-
<textarea
12-
id="lhs"
13-
class="flex-1 h-full max-h-full rounded-md resize-none form-textarea"
14-
></textarea>
15-
<textarea
16-
id="rhs"
17-
class="flex-1 h-full max-h-full rounded-md resize-none form-textarea"
18-
></textarea>
19-
<div class="self-end w-full text-center">
20-
<button
21-
class="w-64 px-4 py-3 text-white transition-transform transform bg-blue-600 rounded-md shadow-lg outline-none focus:ring-4 active:scale-y-75"
22-
>
23-
Compare
24-
</button>
25-
</div>
4+
<main class="flex flex-wrap h-full mt-20 xl:container">
5+
<p class="w-full mb-2 text-xl text-center">
6+
Insert your data below to find the difference in them
7+
</p>
8+
<form @submit="checkForm" class="w-full h-full">
9+
<div class="flex flex-wrap w-full h-full gap-4">
10+
<textarea
11+
id="lhs"
12+
class="flex-1 h-full max-h-full rounded-md resize-none form-textarea"
13+
></textarea>
14+
<textarea
15+
id="rhs"
16+
class="flex-1 h-full max-h-full rounded-md resize-none form-textarea"
17+
></textarea>
18+
<div class="self-end w-full text-center">
19+
<button
20+
class="w-64 px-4 py-3 text-white transition-transform transform bg-blue-600 rounded-md shadow-lg outline-none focus:ring-4 active:scale-y-75"
21+
>
22+
Compare
23+
</button>
2624
</div>
27-
</form>
28-
</main>
29-
</div>
25+
</div>
26+
</form>
27+
</main>
3028
</div>
3129
</template>
3230

@@ -36,6 +34,7 @@ import Vue from 'vue'
3634
import { urlEncode } from '../helpers/utils'
3735
const dmp = new DiffMatchPatch()
3836
export default Vue.extend({
37+
layout: 'main',
3938
methods: {
4039
checkForm(e: any) {
4140
e.preventDefault()

0 commit comments

Comments
 (0)