|
| 1 | +import baseMotion from '@primer/primitives/dist/docs/base/motion/motion.json' with {type: 'json'} |
| 2 | +import baseSize from '@primer/primitives/dist/docs/base/size/size.json' with {type: 'json'} |
| 3 | +import baseTypography from '@primer/primitives/dist/docs/base/typography/typography.json' with {type: 'json'} |
| 4 | +import functionalSizeBorder from '@primer/primitives/dist/docs/functional/size/border.json' with {type: 'json'} |
| 5 | +import functionalSizeCoarse from '@primer/primitives/dist/docs/functional/size/size-coarse.json' with {type: 'json'} |
| 6 | +import functionalSizeFine from '@primer/primitives/dist/docs/functional/size/size-fine.json' with {type: 'json'} |
| 7 | +import functionalSize from '@primer/primitives/dist/docs/functional/size/size.json' with {type: 'json'} |
| 8 | +import light from '@primer/primitives/dist/docs/functional/themes/light.json' with {type: 'json'} |
| 9 | +import functionalTypography from '@primer/primitives/dist/docs/functional/typography/typography.json' with {type: 'json'} |
| 10 | + |
| 11 | +const categories = { |
| 12 | + base: { |
| 13 | + motion: Object.values(baseMotion).map(token => { |
| 14 | + return { |
| 15 | + name: token.name, |
| 16 | + type: token.type, |
| 17 | + value: token.value, |
| 18 | + } |
| 19 | + }), |
| 20 | + size: Object.values(baseSize).map(token => { |
| 21 | + return { |
| 22 | + name: token.name, |
| 23 | + type: token.type, |
| 24 | + value: token.value, |
| 25 | + } |
| 26 | + }), |
| 27 | + typography: Object.values(baseTypography).map(token => { |
| 28 | + return { |
| 29 | + name: token.name, |
| 30 | + type: token.type, |
| 31 | + value: token.value, |
| 32 | + } |
| 33 | + }), |
| 34 | + }, |
| 35 | + functional: { |
| 36 | + border: Object.values(functionalSizeBorder).map(token => { |
| 37 | + return { |
| 38 | + name: token.name, |
| 39 | + type: token.type, |
| 40 | + value: token.value, |
| 41 | + } |
| 42 | + }), |
| 43 | + sizeCoarse: Object.values(functionalSizeCoarse).map(token => { |
| 44 | + return { |
| 45 | + name: token.name, |
| 46 | + type: token.type, |
| 47 | + value: token.value, |
| 48 | + } |
| 49 | + }), |
| 50 | + sizeFine: Object.values(functionalSizeFine).map(token => { |
| 51 | + return { |
| 52 | + name: token.name, |
| 53 | + type: token.type, |
| 54 | + value: token.value, |
| 55 | + } |
| 56 | + }), |
| 57 | + size: Object.values(functionalSize).map(token => { |
| 58 | + return { |
| 59 | + name: token.name, |
| 60 | + type: token.type, |
| 61 | + value: token.value, |
| 62 | + } |
| 63 | + }), |
| 64 | + themes: { |
| 65 | + light: Object.values(light).map(token => { |
| 66 | + return { |
| 67 | + name: token.name, |
| 68 | + type: token.type, |
| 69 | + value: token.value, |
| 70 | + } |
| 71 | + }), |
| 72 | + }, |
| 73 | + typography: Object.values(functionalTypography).map(token => { |
| 74 | + return { |
| 75 | + name: token.name, |
| 76 | + type: token.type, |
| 77 | + value: token.value, |
| 78 | + } |
| 79 | + }), |
| 80 | + }, |
| 81 | +} as const |
| 82 | + |
| 83 | +const tokens = [ |
| 84 | + ...categories.base.motion, |
| 85 | + ...categories.base.size, |
| 86 | + ...categories.base.typography, |
| 87 | + ...categories.functional.border, |
| 88 | + ...categories.functional.sizeCoarse, |
| 89 | + ...categories.functional.sizeFine, |
| 90 | + ...categories.functional.size, |
| 91 | + ...categories.functional.themes.light, |
| 92 | + ...categories.functional.typography, |
| 93 | +] |
| 94 | + |
| 95 | +function serialize(value: typeof tokens): string { |
| 96 | + return value |
| 97 | + .map(token => { |
| 98 | + return `<token name="${token.name}" value="${token.value}" type="${token.type}"></token>` |
| 99 | + }) |
| 100 | + .join('\n') |
| 101 | +} |
| 102 | + |
| 103 | +export {categories, tokens, serialize} |
0 commit comments