-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* UX-747 & UX-748: Add Style Dictionary and CSS custom properties file (#1026) * UX-747 Add Style Dictionary basic setup * UX-747 Add box-shadow * UX-747 Update to a temporary package name * UX-747 Update readme.md * UX-747 Fix spelling error * UX-750 Add SCSS map and function generation (#1027) * UX-750 Add SCSS map and function generation * UX-750 Interpolate string so quotes are not needed by end user * UX-750 Fix font size tokens * UX-749 Generate JS token files (#1028) * UX-749 Generate JS token files * UX-749 Update deprecated token file name * UX-749 Use 'legacy' instead of 'deprecated' * UX-752 Generate meta token file (#1030) * UX-752 Add meta file generation * UX-752 Add index.js file entry point * UX-752 Some clean up * UX-752 More clean up * UX-755 Harden design tokens (#1032) * UX-755 Harden design tokens * UX-755 Add sd package to lerna * UX-754 Prepare design token package * UX-754 Prepare design token package part 2 * UX-754 Update readme * UX-754 Update snapshots * UX-754 Fix color-white and color casing in tests * UX-754 Fix color-white types
- Loading branch information
Showing
53 changed files
with
2,634 additions
and
8,226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
/node_modules | ||
/data | ||
/gulpfile | ||
/scripts | ||
|
||
# misc | ||
.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
const { mapGet, utils, colorMapGet } = require('./templates/scss-functions'); | ||
const { toSnake, toCamel, toFriendly } = require('./utils/utils'); | ||
const transforms = require('style-dictionary/lib/common/transforms'); | ||
|
||
module.exports = { | ||
source: ['tokens/**/*.json'], | ||
platforms: { | ||
// Generates css custom properties | ||
css: { | ||
transformGroup: 'css', | ||
buildPath: 'dist/css/', | ||
files: [ | ||
{ | ||
destination: 'tokens.css', | ||
format: 'css/variables', | ||
}, | ||
], | ||
}, | ||
scss: { | ||
transformGroup: 'scss', | ||
buildPath: 'dist/scss/', | ||
files: [ | ||
// Generates scss maps | ||
{ | ||
destination: 'maps.scss', | ||
format: 'scss/map-deep', | ||
mapName: 'matchbox-tokens', | ||
}, | ||
// Generates scss map functions | ||
{ | ||
destination: 'tokens.scss', | ||
format: 'scss/functions', | ||
}, | ||
], | ||
}, | ||
// Generates JS files in snake case | ||
js: { | ||
transformGroup: 'js', | ||
buildPath: 'dist/js/', | ||
transforms: ['name/cti/snake'], | ||
files: [ | ||
{ | ||
destination: 'tokens.js', | ||
format: 'javascript/module-flat', | ||
}, | ||
], | ||
}, | ||
// Generates JS files in the old format of snake & camel using a custom transform | ||
js_legacy: { | ||
transformGroup: 'js', | ||
buildPath: 'dist/js/', | ||
transforms: ['name/cti/legacy'], | ||
files: [ | ||
{ | ||
destination: 'tokens.legacy.js', | ||
format: 'javascript/module-flat', | ||
}, | ||
], | ||
}, | ||
// Generates meta JS file | ||
js_meta: { | ||
transformGroup: 'js', | ||
buildPath: 'dist/meta/', | ||
files: [ | ||
{ | ||
destination: 'meta.js', | ||
format: 'javascript/meta', | ||
}, | ||
], | ||
}, | ||
}, | ||
transform: { | ||
'name/cti/legacy': { | ||
type: 'name', | ||
transformer: (token) => { | ||
const [category, ...rest] = token.path; | ||
return `${toCamel(category)}_${toSnake(rest.join('-'))}`; | ||
}, | ||
}, | ||
}, | ||
format: { | ||
'scss/functions': (args) => { | ||
const keys = Object.keys(args.dictionary.tokens); | ||
const rootFontSize = args.dictionary.allTokens.find(({ name }) => name === 'font-size-root'); | ||
const functions = keys.map((key) => (key !== 'color' ? mapGet(key) : colorMapGet())).join(''); | ||
return `${utils(rootFontSize)}\n${functions}`; | ||
}, | ||
'javascript/meta': (args) => { | ||
const all = args.dictionary.allTokens; | ||
|
||
const tokens = all | ||
.map((token) => { | ||
const { path, value, pixel_value } = token; | ||
const [head, ...tail] = path; | ||
|
||
return JSON.stringify({ | ||
category: head, | ||
css: `--${path.join('-')}`, | ||
friendly: toFriendly(path.join(' ')), | ||
javascript: transforms['name/cti/snake'].transformer(token, {}), | ||
name: path.join('-'), | ||
pixel_value: pixel_value, | ||
pixel_value_unitless: !!pixel_value ? pixel_value.replace(/px$/, '') : undefined, | ||
scss: `${head}(${tail.join(',')})`, | ||
system: tail.join('.'), | ||
type: head, | ||
value: head.match(/^color$/) ? value.toUpperCase() : value, | ||
}); | ||
}) | ||
.join(',\n'); | ||
|
||
return `module.exports = [${tokens}]`; | ||
}, | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.