Skip to content

Commit 8bafec2

Browse files
committed
fix: showing error toast if no data on either side
1 parent 8f8629b commit 8bafec2

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

components/Toast.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
v-bind:class="{
1616
'-translate-y-screen': !toastState.show,
1717
'-translate-y-0': !toastState.show,
18-
'bg-green-400': toastState.theme === 'success',
19-
'bg-blue-400': toastState.theme !== 'success',
18+
'bg-green-400 text-gray-800': toastState.theme === 'success',
19+
'bg-red-400 text-white': toastState.theme === 'error',
20+
'bg-blue-400 text-white': toastState.theme !== 'success',
2021
}"
2122
>
2223
<div class="flex justify-between gap-2">

pages/diff/_diff.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class="inline-flex justify-center px-4 py-2 text-white transition-transform transform rounded-md shadow-lg outline-none copy-uri-button align-center focus:ring-4 active:scale-y-75"
99
v-bind:class="{
1010
'bg-blue-600 text-white': !copied,
11-
'bg-green-500 text-black': copied,
11+
'bg-green-500 text-gray-800': copied,
1212
}"
1313
>
1414
<span class="inline-flex justify-center" v-show="copied">

pages/index.vue

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,27 @@ export default Vue.extend({
4646
) as HTMLTextAreaElement
4747
const rhs: string = rhsTextArea?.value || ''
4848
if (!lhs || !rhs) {
49+
this.$store.commit('toast/show', {
50+
show: true,
51+
content: 'Please enter some data on both sides to compare',
52+
iconHTML: `
53+
<svg
54+
class="w-6 h-6"
55+
fill="none"
56+
stroke="currentColor"
57+
viewBox="0 0 24 24"
58+
xmlns="http://www.w3.org/2000/svg"
59+
>
60+
<path
61+
stroke-linecap="round"
62+
stroke-linejoin="round"
63+
stroke-width="2"
64+
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
65+
></path>
66+
</svg>
67+
`,
68+
theme: 'error',
69+
})
4970
return
5071
}
5172
const originalLhs = lhs.split('\n')

0 commit comments

Comments
 (0)