Skip to content

Commit

Permalink
[#182321458] update tokens (#12)
Browse files Browse the repository at this point in the history
* pivotal-182321458 update tokens and remove token type

* adjust sd directory structure

* pivotal-182321458 add missing theme keys

* pivotal-182321458
- allow for multiple token files,
- remove at and me token sets for now,
- simplify themeprovider only passing theme key as context

* move tokens again (to make github sync simpler)

* update readme
  • Loading branch information
josefie authored Jul 12, 2022
1 parent 212bc77 commit bc3dc83
Show file tree
Hide file tree
Showing 11 changed files with 502 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ app/javascript/shared/i18n.ts
config/**/*.js
vite.config.ts
node_modules
sd.config.js
style-dictionary/config.js
storybook-static
dist
8 changes: 4 additions & 4 deletions config/sd.config.js → config/style-dictionary/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const themes = require('./themes.json')
require('./sd/transforms.js')
require('./sd/transformGroups.js')
require('./sd/parsers.js')
const themes = require('../themes.json')
require('./transforms.js')
require('./transformGroups.js')
require('./parsers.js')

const getFileConfig = (platform, format) => {
const themeFiles = themes.map((theme) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ StyleDictionary.registerParser({
// strip away the global key for global token set but keep the themes nested
// this is necessary, because the references from Figma Tokens do not include the token set key
// e.g. {Primary.Green 800} would not work
let transformedTokens = tokens['global']
let transformedTokens = tokens['global'] || {}

Object.keys(tokens).forEach((set) => {
// only add the token set if it is defined as a valid theme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ StyleDictionary.registerTransformGroup({
transforms: [
...StyleDictionary.transformGroup['web'],
'name/theme',
'name/tokenType',
'size/pxToRem',
'value/quote',
'value/boxShadow',
Expand All @@ -18,7 +17,6 @@ StyleDictionary.registerTransformGroup({
...StyleDictionary.transformGroup['js'],
'name/cti/kebab',
'name/theme',
'name/tokenType',
'size/pxToRem',
'value/boxShadow',
],
Expand Down
13 changes: 0 additions & 13 deletions config/sd/transforms.js → config/style-dictionary/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,6 @@ StyleDictionary.registerTransform({
},
})

// add token type to name
StyleDictionary.registerTransform({
name: 'name/tokenType',
type: 'name',
matcher: function (token) {
return token.type
},
transformer: function (token) {
const prefix = token.name.split('-')[0]
return token.name.replace(prefix, `${prefix}-${token.type}`)
},
})

// TODO: output typography styles as mixin
StyleDictionary.registerTransform({
name: 'value/typography',
Expand Down
2 changes: 1 addition & 1 deletion config/themes.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["at", "me", "org"]
["org"]
Loading

0 comments on commit bc3dc83

Please sign in to comment.