File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change 5
5
export function getColor ( color ) {
6
6
if ( ! color ) return "color: inherit" ;
7
7
const isDark = matchMedia ( "(prefers-color-scheme: dark)" ) . matches ;
8
- /** @type {string } */
9
- let hex ;
10
- if ( color === "blue" ) {
11
- hex = isDark ? "#006fff" : "#317eff" ;
12
- } else if ( color === "green" ) {
13
- hex = isDark ? "#60f36c" : "#2bb239" ;
14
- } else if ( color === "yellow" ) {
15
- hex = isDark ? "#fff600" : "#b8722c" ;
16
- } else {
17
- return "" ;
8
+ const colors = {
9
+ blue : { dark : "#006fff" , light : "#317eff" } ,
10
+ green : { dark : "#60f36c" , light : "#2bb239" } ,
11
+ yellow : { dark : "#fff600" , light : "#b8722c" } ,
12
+ } ;
13
+ if ( color in colors ) {
14
+ const hex = isDark ? colors [ color ] . dark : colors [ color ] . light ;
15
+ return `color: ${ hex } ` ;
18
16
}
19
- return `color: ${ hex } ` ;
17
+ return "" ;
20
18
}
You can’t perform that action at this time.
0 commit comments