(name: string)
| 88 | } |
| 89 | |
| 90 | export function token(name: string) { |
| 91 | let token = name.split('.').reduce((acc, curr) => { |
| 92 | let res = acc[curr]; |
| 93 | if (res == null) { |
| 94 | throw new Error(`Token ${name} not found`); |
| 95 | } |
| 96 | return res; |
| 97 | }, tokens) as any; |
| 98 | if (token?.light && token.dark) { |
| 99 | return `light-dark(${convertColor(token.light)}, ${convertColor(token.dark)})`; |
| 100 | } else if (token?.light) { |
| 101 | return convertColor(token.light); |
| 102 | } else if (token?.dark) { |
| 103 | return convertColor(token.dark); |
| 104 | } else { |
| 105 | return convertColor(token.value ?? token); |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | export function mix(gray: string, stop: string, opacity: string) { |
| 110 | let stopColor = token(stop); |
no test coverage detected