@wix/css-property-parser
Version:
A comprehensive TypeScript library for parsing and serializing CSS property values with full MDN specification compliance
29 lines (28 loc) • 1.11 kB
TypeScript
import { type ObjectFitValue } from '../types';
/**
* Parses CSS object-fit property values
*
* Syntax: fill | contain | cover | none | scale-down | inherit | initial | unset | revert
*
* @param value - The CSS object-fit value to parse
* @returns Parsed ObjectFitValue or null if invalid
*
* @example
* ```typescript
* parse('fill') // { type: 'keyword', keyword: 'fill' }
* parse('contain') // { type: 'keyword', keyword: 'contain' }
* parse('cover') // { type: 'keyword', keyword: 'cover' }
* parse('none') // { type: 'keyword', keyword: 'none' }
* parse('scale-down') // { type: 'keyword', keyword: 'scale-down' }
* parse('inherit') // { type: 'keyword', keyword: 'inherit' }
* parse('var(--my-fit)') // { type: 'variable', variable: 'my-fit' }
* ```
*/
export declare function parse(value: string): ObjectFitValue | null;
/**
* Converts a parsed ObjectFitValue back to its CSS string representation
*
* @param value - The parsed object-fit value
* @returns CSS string representation or null if invalid
*/
export declare function toCSSValue(value: ObjectFitValue | null): string | null;