Skip to content

Commit 2765548

Browse files
committed
feat(clear): added clear button to clear all inputs in one click
1 parent f432f6c commit 2765548

File tree

1 file changed

+47
-42
lines changed

1 file changed

+47
-42
lines changed

pages/v2/index.vue

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,7 @@
3737
aria-label="Beautify entered text"
3838
type="button"
3939
title="Beautify"
40-
class="
41-
absolute
42-
p-2
43-
transition-all
44-
rounded-sm
45-
top-16
46-
right-3
47-
aspect-square
48-
dark:hover:bg-slate-600 dark:bg-slate-600/50
49-
hover:bg-slate-300
50-
bg-gray-300/50
51-
"
40+
class="absolute p-2 transition-all rounded-sm top-16 right-3 aspect-square dark:hover:bg-slate-600 dark:bg-slate-600/50 hover:bg-slate-300 bg-gray-300/50"
5241
@click="
5342
lhsEditor.trigger('editor', 'editor.action.formatDocument')
5443
"
@@ -88,18 +77,7 @@
8877
aria-label="Beautify entered text"
8978
type="button"
9079
title="Beautify"
91-
class="
92-
absolute
93-
p-2
94-
transition-all
95-
rounded-sm
96-
top-16
97-
right-3
98-
aspect-square
99-
dark:hover:bg-slate-600 dark:bg-slate-600/50
100-
hover:bg-slate-300
101-
bg-gray-300/50
102-
"
80+
class="absolute p-2 transition-all rounded-sm top-16 right-3 aspect-square dark:hover:bg-slate-600 dark:bg-slate-600/50 hover:bg-slate-300 bg-gray-300/50"
10381
@click="
10482
rhsEditor.trigger('editor', 'editor.action.formatDocument')
10583
"
@@ -119,29 +97,52 @@
11997
</button>
12098
</div>
12199
</section>
122-
<div class="self-end flex-grow-0 w-full mt-4 text-center">
100+
<div
101+
class="flex self-end justify-center flex-grow-0 w-full gap-4 mt-4 text-center "
102+
>
123103
<button
124104
id="submitButton"
125-
class="
126-
inline-flex
127-
items-center
128-
justify-center
129-
w-48
130-
px-4
131-
py-2
132-
transition-transform
133-
transform
134-
bg-blue-600
135-
rounded-md
136-
shadow-lg
137-
outline-none
138-
text-gray-50
139-
focus:ring-4
140-
active:scale-y-75
141-
"
105+
class="inline-flex items-center justify-center w-48 gap-4 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"
142106
aria-label="Click here to compare the inputted text blocks"
143107
>
144108
Compare
109+
<span class="w-4 aspect-square">
110+
<svg
111+
viewBox="0 0 15 15"
112+
fill="none"
113+
xmlns="http://www.w3.org/2000/svg"
114+
width="15"
115+
height="15"
116+
>
117+
<path
118+
d="M13.5 7.5l-4-4m4 4l-4 4m4-4H1"
119+
stroke="currentColor"
120+
></path>
121+
</svg>
122+
</span>
123+
</button>
124+
<button
125+
id="submitButton"
126+
class="inline-flex items-center justify-center w-48 gap-4 px-4 py-2 text-gray-800 transition-transform transform bg-yellow-300 rounded-md shadow-lg outline-none focus:ring-4 active:scale-y-75"
127+
aria-label="Click here to clear all the inputs"
128+
type="button"
129+
@click="clear"
130+
>
131+
<span class="w-4 aspect-square">
132+
<svg
133+
viewBox="0 0 15 15"
134+
fill="none"
135+
xmlns="http://www.w3.org/2000/svg"
136+
width="15"
137+
height="15"
138+
>
139+
<path
140+
d="M4.5 3V1.5a1 1 0 011-1h4a1 1 0 011 1V3M0 3.5h15m-13.5 0v10a1 1 0 001 1h10a1 1 0 001-1v-10M7.5 7v5m-3-3v3m6-3v3"
141+
stroke="currentColor"
142+
></path>
143+
</svg>
144+
</span>
145+
Clear
145146
</button>
146147
</div>
147148
</form>
@@ -272,6 +273,10 @@ export default Vue.extend({
272273
theme: 'error',
273274
})
274275
},
276+
clear() {
277+
this.lhsEditor.getModel().setValue('')
278+
this.rhsEditor.getModel().setValue('')
279+
},
275280
},
276281
})
277282
</script>

0 commit comments

Comments
 (0)