|
43 | 43 |
|
44 | 44 | console.log('Generating SCSS variables...'); |
45 | 45 |
|
46 | | - // Separate typography tokens from the rest |
47 | | - const typographyProperties = dictionary.allTokens.filter((prop) => prop.$type === 'typography'); |
48 | | - const otherProperties = dictionary.allTokens.filter((prop) => prop.$type !== 'typography'); |
49 | | - |
50 | | - // Make sure the reused scss variables are defined first, to avoid compilation errors |
51 | | - const sortedProperties = [...otherProperties, ...typographyProperties]; |
| 46 | + const primitiveProperties = dictionary.allTokens.filter((prop) => prop.path[0] === 'primitives'); |
| 47 | + const scaleProperties = dictionary.allTokens.filter((prop) => prop.path[0] === 'scale'); |
| 48 | + const borderProperties = dictionary.allTokens.filter((prop) => prop.path[0] === 'border'); |
| 49 | + const semanticsProperties = dictionary.allTokens.filter((prop) => prop.path[0] === 'semantics'); |
| 50 | + const nonPrimitiveScaleBorderSemanticsProperties = dictionary.allTokens.filter( |
| 51 | + (prop) => !['primitives', 'scale', 'border', 'semantics'].includes(prop.path[0]) |
| 52 | + ); |
| 53 | + const typographyProperties = nonPrimitiveScaleBorderSemanticsProperties.filter((prop) => prop.$type === 'typography'); |
| 54 | + const otherProperties = nonPrimitiveScaleBorderSemanticsProperties.filter((prop) => prop.$type !== 'typography'); |
| 55 | + |
| 56 | + // Order: primitives → semantics → scale → border → other → typography |
| 57 | + const sortedProperties = [ |
| 58 | + ...primitiveProperties, |
| 59 | + ...semanticsProperties, |
| 60 | + ...scaleProperties, |
| 61 | + ...borderProperties, |
| 62 | + ...otherProperties, |
| 63 | + ...typographyProperties |
| 64 | + ]; |
52 | 65 |
|
53 | 66 | const prefixedVariables = sortedProperties.map((prop) => { |
54 | 67 | // Remove consecutive repeated words from the token name, like border-border-color |
|
0 commit comments