Theemo / @theemo/style-dictionary / isConstrainedByPlatform
Function: isConstrainedByPlatform()
ts
function isConstrainedByPlatform(token): boolean;
Defined in: filters/constraints.ts:182
Matches the token against constraints given for the platform.
When platform constraints are added to a token with attribute/constraints
, then you can use isConstrainedByPlatform()
to filter for them.
Parameters
Parameter | Type | Description |
---|---|---|
token | TransformedToken | the token in question |
Returns
boolean
true
when the token matches platform constraints, otherwise false
Example
Usage:
js
import StyleDictionary from 'style-dictionary';
import { isConstrainedByPlatform } from '@theemo/style-dictionary';
export default {
source: ['tokens/**/*.json'],
platforms: {
css: {
constraints: {
features: {
'color-scheme': 'light'
}
},
files: [
{
format: 'css/variables',
destination: 'constrained-tokens.css',
filter: isConstrainedByPlatform
}
]
}
}
};
See
attributeConstraintsTransform