File tree 1 file changed +13
-4
lines changed
1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 6
6
getIntervalTypeColor ,
7
7
getMinutes ,
8
8
getSeconds ,
9
+ toSpacedString ,
9
10
} from ' @/utils' ;
10
11
import { IntervalType } from ' @/types' ;
11
12
@@ -16,20 +17,28 @@ const { type, duration } = defineProps({
16
17
17
18
const time = computed (() => formatTime (duration ));
18
19
const label = computed (() => {
19
- const mins = getMinutes (duration );
20
+ let mins = getMinutes (duration );
20
21
const secs = getSeconds (duration );
21
- return ` ${mins } minutes ${secs ? secs + ' seconds ' : ' ' }left ` ;
22
+ if (mins === 0 && secs === 0 ) {
23
+ return ` ${toSpacedString (type )}: time out ` ;
24
+ }
25
+ if (mins === 0 ) {
26
+ return ` ${toSpacedString (type )}: less than 1 minute left ` ;
27
+ }
28
+ return ` ${toSpacedString (type )}: ${mins + 1 } minutes left ` ;
22
29
});
23
30
24
31
const classes = computed (() => getIntervalTypeColor (type as IntervalType ));
25
32
</script >
26
33
<template >
27
34
<div
28
35
role =" timer"
36
+ aria-live =" polite"
37
+ aria-atomic =" true"
29
38
class =" rounded-lg border-4 px-8 py-4 text-4xl tabular-nums"
30
39
:class =" classes"
31
- :aria-label =" label"
32
40
>
33
- {{ time }}
41
+ <span aria-hidden =" true" >{{ time }}</span >
42
+ <span class =" sr-only" >{{ label }}</span >
34
43
</div >
35
44
</template >
You can’t perform that action at this time.
0 commit comments