convert-color
This parser helps you convert the color formats of color compatible tokens over a SDTF graph.
Interface
interface parser {
name: 'convert-color';
options: {
toFormat:
| 'hex'
| 'rgb'
| 'hsl'
| 'hsb'
| 'lch'
| 'lab';
applyTo?:
| { collection: string | true }
| { group: string | true }
| { token: string | true }
| SDTFQuery;
};
}
Options
Parameter
Required
Type
Default
Description
toFormat
required
| 'hex'
| 'rgb'
| 'hsl'
| 'hsb'
| 'lch'
| 'lab'
The target color format to convert to. Actual value conversion is done by the colord package.
applyTo
false
| { collection: string | true }
| { group: string | true }
| { token: string | true }
| SDTFQuery
{ token: true }
The selection where to apply the transformation.
collection
, group
, token
take a Regex string or true
to select anything of the kind.
An SDTFQuery
can be used for advance use cases.
Basic usage
{
"Colors": {
"$collection": { "$modes": ["Light", "Dark"] },
"Core": {
"blue 100": {
"$type": "color",
"$description": "token 1 aliased with n modes within collection within n groups",
"$value": {
"Light": {
"red": 219,
"blue": 254,
"alpha": 1,
"green": 236,
"model": "rgb"
},
"Dark": {
"red": 41,
"blue": 67,
"alpha": 1,
"green": 52,
"model": "rgb"
}
}
},
"blue 700": {
"$type": "color",
"$description": "token 2 aliased with n modes within collection within n groups",
"$value": {
"Light": {
"red": 17,
"blue": 249,
"alpha": 1,
"green": 125,
"model": "rgb"
},
"Dark": {
"red": 96,
"blue": 250,
"alpha": 1,
"green": 168,
"model": "rgb"
}
}
}
},
"semantic": {
"background": {
"button": {
"primary": {
"hover": {
"$type": "color",
"$description": "alias token with n modes within collection within n groups",
"$value": {
"Dark": {
"$mode": "dark",
"$alias": "Colors.Core.blue 100"
},
"Light": {
"$mode": "light",
"$alias": "Colors.Core.blue 700"
}
}
}
}
}
}
}
}
}
Last updated
Was this helpful?