Skip to content

Commit 26b8445

Browse files
committed
feat: a11y for find box
1 parent 51f0cd9 commit 26b8445

File tree

1 file changed

+62
-45
lines changed

1 file changed

+62
-45
lines changed

src/renderer/components/FindBox.vue

Lines changed: 62 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -116,63 +116,67 @@ watch($$(isFinding), (value: boolean) => {
116116
</script>
117117

118118
<template>
119-
<div v-show="isFinding" ref="root" class="find-box">
120-
<input
121-
ref="finder"
122-
v-model="keyword"
123-
v-i18n:placeholder
124-
type="search"
125-
class="keyword"
126-
placeholder="Find#!terminal.5"
127-
autofocus
128-
@keyup.enter="find"
129-
@keyup.esc="cancel"
130-
>
131-
<div class="options">
132-
<div
133-
class="option case-sensitive"
134-
:class="{ selected: options.caseSensitive }"
135-
@click="toggle('caseSensitive')"
136-
>Aa</div>
137-
<template v-if="!terminal?.pane">
119+
<div v-show="isFinding" ref="root" class="find-box" @submit.prevent="find">
120+
<form class="finder">
121+
<input
122+
ref="finder"
123+
v-model="keyword"
124+
v-i18n:placeholder
125+
type="search"
126+
class="keyword"
127+
placeholder="Find#!terminal.5"
128+
autofocus
129+
@keyup.esc="cancel"
130+
>
131+
<div class="options">
138132
<div
139-
class="option whole-word"
140-
:class="{ selected: options.wholeWord }"
141-
@click="toggle('wholeWord')"
142-
>|ab|</div>
143-
<div
144-
class="option use-regexp"
145-
:class="{ selected: options.regex }"
146-
@click="toggle('regex')"
147-
>.*</div>
148-
</template>
149-
</div>
150-
<div v-if="currentNumber && totalNumber" class="indicator">{{ currentNumber }} / {{ totalNumber }}</div>
151-
<div class="buttons">
152-
<div class="button previous">
153-
<VisualIcon name="lucide-arrow-up" @click="findPrevious" />
154-
</div>
155-
<div class="button next">
156-
<VisualIcon name="lucide-arrow-down" @click="findNext" />
133+
class="option case-sensitive"
134+
:class="{ selected: options.caseSensitive }"
135+
@click="toggle('caseSensitive')"
136+
>Aa</div>
137+
<template v-if="!terminal?.pane">
138+
<div
139+
class="option whole-word"
140+
:class="{ selected: options.wholeWord }"
141+
@click="toggle('wholeWord')"
142+
>|ab|</div>
143+
<div
144+
class="option use-regexp"
145+
:class="{ selected: options.regex }"
146+
@click="toggle('regex')"
147+
>.*</div>
148+
</template>
157149
</div>
158-
<div class="button close">
159-
<VisualIcon name="lucide-x" @click="cancel" />
150+
<div v-if="currentNumber && totalNumber" class="indicator">{{ currentNumber }} / {{ totalNumber }}</div>
151+
<div class="buttons">
152+
<button type="button" class="button previous" @click.prevent="findPrevious">
153+
<VisualIcon name="lucide-arrow-up" />
154+
</button>
155+
<button class="button next">
156+
<VisualIcon name="lucide-arrow-down" />
157+
</button>
158+
<button type="button" class="button close" @click.prevent="cancel">
159+
<VisualIcon name="lucide-x" />
160+
</button>
160161
</div>
161-
</div>
162+
</form>
162163
</div>
163164
</template>
164165

165166
<style lang="scss" scoped>
166167
.find-box {
167-
display: flex;
168168
flex: none;
169-
height: #{36px - 2 * 8px}; // var(--min-tab-height) - 2 * 8px
170169
padding: 8px;
171-
line-height: #{36px - 2 * 8px};
172170
background: rgb(var(--theme-background) / var(--theme-opacity));
173171
border-radius: var(--design-card-border-radius);
174172
box-shadow: var(--design-card-shadow);
175173
}
174+
.finder {
175+
display: flex;
176+
gap: 8px;
177+
height: #{36px - 2 * 8px}; // var(--min-tab-height) - 2 * 8px
178+
line-height: #{36px - 2 * 8px};
179+
}
176180
.keyword {
177181
flex: auto;
178182
padding: 2px 6px;
@@ -211,11 +215,24 @@ watch($$(isFinding), (value: boolean) => {
211215
.buttons {
212216
display: flex;
213217
flex: none;
218+
gap: 4px;
214219
}
215220
.button {
216-
display: inline-block;
217-
width: 28px;
221+
appearance: none;
222+
width: 20px;
223+
padding: 0;
224+
border: none;
218225
text-align: center;
226+
background: transparent;
227+
border-radius: 4px;
228+
transition: color 0.2s, transform 0.2s;
219229
cursor: pointer;
230+
&:hover {
231+
background: var(--design-highlight-background);
232+
opacity: 1;
233+
}
234+
&:active {
235+
transform: scale(0.96);
236+
}
220237
}
221238
</style>

0 commit comments

Comments
 (0)