(input: string)
| 373 | } |
| 374 | |
| 375 | function parseHexColor(input: string): { r: number; g: number; b: number; a: number } | null { |
| 376 | let hex = input.trim().replace(/^#/, '') |
| 377 | if (![3, 4, 6, 8].includes(hex.length)) return null |
| 378 | |
| 379 | if (hex.length === 3 || hex.length === 4) { |
| 380 | hex = hex |
| 381 | .split('') |
| 382 | .map((c) => c + c) |
| 383 | .join('') |
| 384 | } |
| 385 | |
| 386 | const r = parseInt(hex.slice(0, 2), 16) |
| 387 | const g = parseInt(hex.slice(2, 4), 16) |
| 388 | const b = parseInt(hex.slice(4, 6), 16) |
| 389 | const a = hex.length === 8 ? parseInt(hex.slice(6, 8), 16) / 255 : 1 |
| 390 | |
| 391 | return { r, g, b, a } |
| 392 | } |
| 393 | |
| 394 | function parseBorderShorthand(normalized: string): { |
| 395 | width?: string |
no outgoing calls
no test coverage detected