@wix/css-property-parser
Version:
A comprehensive TypeScript library for parsing and serializing CSS property values with full MDN specification compliance
28 lines (27 loc) • 1.21 kB
TypeScript
import { type BorderColorPropertyValue } from './shared-border-color';
export type BorderLeftColorValue = BorderColorPropertyValue;
/**
* Parse CSS border-left-color property
*
* @param value - CSS border-left-color property value
* @returns Parsed border color value or null if invalid
*
* @example
* parse('purple') // { type: 'color', format: 'named', values: { name: 'purple' } }
* parse('rgba(255, 0, 0, 0.5)') // { type: 'color', format: 'rgba', values: { r: 255, g: 0, b: 0, a: 0.5 } }
* parse('currentcolor') // { type: 'keyword', keyword: 'currentcolor' }
* parse('var(--color)') // null (CSS variables handled at runtime)
*/
export declare function parse(value: string): BorderLeftColorValue;
/**
* Convert parsed border-left-color back to CSS string
*
* @param parsed - Parsed border color value
* @returns CSS string representation or null if invalid
*
* @example
* toCSSValue({ type: 'color', format: 'named', values: { name: 'purple' } }) // 'purple'
* toCSSValue({ type: 'keyword', keyword: 'currentcolor' }) // 'currentcolor'
* toCSSValue({ type: 'keyword', keyword: 'revert' }) // 'revert'
*/
export declare function toCSSValue(parsed: BorderLeftColorValue): string | null;