File tree 1 file changed +20
-5
lines changed
1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<button
3
- :aria-label =" `toggle to ${getNextMode} mode color` "
4
- :title =" `toggle to ${getNextMode} mode color` "
3
+ :aria-label =" getAriaLabel "
4
+ :title =" getAriaLabel "
5
5
class =" vue-dark-mode"
6
6
@click =" toggleColorMode"
7
7
>
8
8
<span
9
9
class =" visually-hidden"
10
10
aria-live =" assertive"
11
- >
12
- {{ chosenMode }} color mode is enabled
13
- </span >
11
+ v-text =" getAriaLive"
12
+ />
14
13
<slot :mode =" chosenMode" />
15
14
</button >
16
15
</template >
@@ -37,6 +36,14 @@ export default {
37
36
metaThemeColor: {
38
37
type: Object ,
39
38
default : () => ({})
39
+ },
40
+ ariaLabel: {
41
+ type: String ,
42
+ default: ' toggle to %cm mode color'
43
+ },
44
+ ariaLive: {
45
+ type: String ,
46
+ default: ' %cm color mode is enabled'
40
47
}
41
48
},
42
49
@@ -61,6 +68,14 @@ export default {
61
68
return colorScheme
62
69
},
63
70
71
+ getAriaLabel () {
72
+ return this .ariaLabel .replace (/ %cm/ g , this .getNextMode )
73
+ },
74
+
75
+ getAriaLive () {
76
+ return this .ariaLive .replace (/ %cm/ g , this .chosenMode )
77
+ },
78
+
64
79
getNextMode () {
65
80
const currentIndex = this .modes .findIndex (mode => mode === this .chosenMode )
66
81
return this .modes [currentIndex === (this .modes .length - 1 ) ? 0 : currentIndex + 1 ]
You can’t perform that action at this time.
0 commit comments