Skip to content

Commit f2b0279

Browse files
committed
feat(AppButton): Make button keyboard-focus only (accessibility)
1 parent 452528a commit f2b0279

File tree

3 files changed

+59
-23
lines changed

3 files changed

+59
-23
lines changed

src/components/AppButton.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<button class="app-btn" type="button">
3+
<span tabindex="-1">
4+
<slot></slot>
5+
</span>
6+
</button>
7+
</template>
8+
9+
<script>
10+
export default {
11+
name: "AppButton"
12+
};
13+
</script>
14+
15+
<style lang="scss" scoped></style>

src/components/CanvasEditor.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
<div class="control-footer">
1414
<span>Name</span>
1515
<span :title="fileName">{{ fileName }}</span>
16-
<button class="btn" @click="openFilePicker">
16+
<app-button @click="openFilePicker">
1717
<img src="@/assets/triangle.svg" alt="" srcset="" />
1818
Upload
19-
</button>
19+
</app-button>
2020
</div>
2121
</div>
2222
<input
@@ -29,10 +29,14 @@
2929
</template>
3030

3131
<script>
32+
import AppButton from "@/components/AppButton";
33+
3234
const pipe = (...fns) => initVal => fns.reduce((val, fn) => fn(val), initVal);
3335
3436
export default {
35-
components: {},
37+
components: {
38+
AppButton
39+
},
3640
name: "CanvasEditor",
3741
props: {
3842
settings: {
@@ -157,7 +161,7 @@ export default {
157161
}
158162
}
159163
160-
.btn {
164+
.app-btn {
161165
margin-left: 1.5rem;
162166
}
163167
</style>

src/styles/components/_button.scss

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,45 @@
1-
.btn {
2-
@extend %control-style;
3-
padding: 1rem 2rem;
4-
display: flex;
5-
align-items: center;
6-
margin-left: 1.5rem;
7-
border-radius: $border-radius;
8-
background-color: $grey-1;
9-
color: $blue;
1+
.app-btn {
2+
@at-root button#{&} {
3+
appearance: none;
4+
background: none;
5+
border: none;
6+
outline: none;
7+
}
108

11-
&:hover {
12-
background-color: darken($grey-1, 10%);
9+
> span {
10+
@extend %control-style;
11+
position: relative;
12+
display: flex;
13+
align-items: center;
14+
padding: 1rem 2rem;
15+
border-radius: $border-radius;
16+
background-color: $grey-1;
17+
color: $blue;
18+
19+
&:focus {
20+
outline: none;
21+
}
22+
23+
img {
24+
width: 1em;
25+
height: 1em;
26+
margin-right: 0.5em;
27+
}
1328
}
1429

15-
&:focus {
16-
outline: none;
30+
&:hover > span {
31+
background-color: darken($grey-1, 5%);
1732
}
1833

19-
&:active {
20-
background-color: darken($grey-1, 15%);
34+
&:active > span {
35+
background-color: darken($grey-1, 10%);
2136
}
2237

23-
img {
24-
width: 1em;
25-
height: 1em;
26-
margin-right: 0.5em;
38+
&:focus {
39+
outline: none;
40+
41+
> span {
42+
box-shadow: 0 0 10px 6px rgba(0, 0, 0, 0.2);
43+
}
2744
}
2845
}

0 commit comments

Comments
 (0)