@wix/css-property-parser
Version:
A comprehensive TypeScript library for parsing and serializing CSS property values with full MDN specification compliance
31 lines (30 loc) • 1.22 kB
JavaScript
// CSS border-start-end-radius logical property parser
// Maps to physical border radius properties based on writing mode and direction
// https://developer.mozilla.org/en-US/docs/Web/CSS/border-start-end-radius
import { parseLogicalBorderRadiusProperty, logicalBorderRadiusToCSSValue } from './shared-logical-border-radius.js';
/**
* Parse border-start-end-radius value
* @param value - The CSS value to parse
* @returns Parsed value or null if invalid
*
* @example
* parse('10px') // { type: 'length', value: 10, unit: 'px' }
* parse('50%') // { type: 'percentage', value: 50, unit: '%' }
* parse('inherit') // { type: 'keyword', keyword: 'inherit' }
*/
export function parse(value) {
return parseLogicalBorderRadiusProperty(value);
}
/**
* Convert parsed border-start-end-radius value to CSS string
* @param parsed - The parsed value to convert
* @returns CSS string or null if invalid
*
* @example
* toCSSValue({ type: 'length', value: 10, unit: 'px' }) // '10px'
* toCSSValue({ type: 'percentage', value: 50, unit: '%' }) // '50%'
* toCSSValue({ type: 'keyword', keyword: 'inherit' }) // 'inherit'
*/
export function toCSSValue(parsed) {
return logicalBorderRadiusToCSSValue(parsed);
}