Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 2x 2x 3545x 7078x 7078x 7078x 2x 2x 2x 2x 2x | /**
* Scope-based filters for CSS and JSON output
* Each filter excludes alias tokens and config tokens, then filters by specific scope
*
* Path-based filters (path[1]):
* - 'g' = global tokens
* - 'r' = reference tokens
* - 's' = shared tokens
* - 'c' = component tokens
*/
// Path to config file
const CONFIG_FILE_PATH = '/common/config.json';
// Filter functions
const globalFilterFn = (token) =>
token.path[0] !== 'alias' && !token.filePath?.includes(CONFIG_FILE_PATH) && token.path[1] === 'g';
const referenceFilterFn = (token) => token.path[0] !== 'alias' && token.path[1] === 'r';
const sharedFilterFn = (token) => token.path[0] !== 'alias' && token.path[1] === 's';
const componentFilterFn = (token) => token.path[0] !== 'alias' && token.path[1] === 'c';
export const scopeFilter = (StyleDictionary) => {
StyleDictionary.registerFilter({
name: 'filter/global',
filter: globalFilterFn,
});
StyleDictionary.registerFilter({
name: 'filter/reference',
filter: referenceFilterFn,
});
StyleDictionary.registerFilter({
name: 'filter/shared',
filter: sharedFilterFn,
});
StyleDictionary.registerFilter({
name: 'filter/component',
filter: componentFilterFn,
});
};
// Export for testing
export {
globalFilterFn as globalFilterFunction,
referenceFilterFn as referenceFilterFunction,
sharedFilterFn as sharedFilterFunction,
componentFilterFn as componentFilterFunction,
};
|