(input: string)
| 346 | } |
| 347 | |
| 348 | export function simplifyColorMixToRgba(input: string): string { |
| 349 | if (!input || !input.includes('color-mix(')) return input |
| 350 | |
| 351 | return input.replace( |
| 352 | /color-mix\(\s*in\s+srgb\s*,\s*(#[0-9a-fA-F]{3,8})\s+([0-9.]+)%\s*,\s*transparent\s*\)/g, |
| 353 | (_match, hex: string, pct: string) => { |
| 354 | const parsed = parseHexColor(hex) |
| 355 | if (!parsed) return _match |
| 356 | const weight = Number(pct) / 100 |
| 357 | if (!Number.isFinite(weight)) return _match |
| 358 | const alpha = toDecimalPlace(Math.min(1, Math.max(0, parsed.a * weight)), 2) |
| 359 | return `rgba(${parsed.r}, ${parsed.g}, ${parsed.b}, ${alpha})` |
| 360 | } |
| 361 | ) |
| 362 | } |
| 363 | |
| 364 | export function simplifyHexAlphaToRgba(input: string): string { |
| 365 | if (!input || !input.includes('#')) return input |
no test coverage detected