@tokens-studio/sd-transforms
Version:
Custom transforms for Style-Dictionary, to work with Design Tokens that are exported from Tokens Studio
14 lines (13 loc) • 389 B
JavaScript
import { percentageToDecimal } from './utils/percentageToDecimal.js';
/**
* Helper: Transforms opacity % to a decimal point number
* @example
* 50% -> 0.5
*/
export function transformOpacity(value) {
if (value === undefined) {
return value;
}
const decimal = percentageToDecimal(value);
return typeof decimal === 'string' || isNaN(decimal) ? value : decimal;
}