This repository has been archived by the owner on Oct 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d2c1f84
commit 204be4e
Showing
5 changed files
with
127 additions
and
109 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
#!/usr/bin/env node | ||
const fs = require('fs'); | ||
|
||
const THEMES = require('./build').THEMES; | ||
|
||
if (!fs.existsSync('dist_ios/Sources')) { | ||
fs.mkdirSync('dist_ios/Sources') | ||
} | ||
|
||
fs.copyFile('dist/ios/tokens.swift', 'dist_ios/Sources/tokens.swift', (err) => { | ||
if (err) throw err; | ||
console.log('dialtone.swift was copied to dist_ios/Sources/tokens.swift'); | ||
THEMES.forEach(theme => { | ||
fs.copyFile(`dist/ios/tokens-${theme}.swift`, `dist_ios/Sources/tokens-${theme}.swift`, (err) => { | ||
if (err) throw err; | ||
console.log(`dialtone.swift was copied to dist_ios/Sources/tokens-${theme}.swift`); | ||
}); | ||
}); |
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,96 +1,97 @@ | ||
module.exports = { | ||
source: ['tokens/**/*.json'], | ||
platforms: { | ||
less: { | ||
transforms: ['dt/size/pxToRem', 'dt/fonts/transformToStack', 'attribute/cti', 'name/cti/kebab', 'time/seconds', 'content/icon', 'color/hex'], | ||
prefix: 'dt', | ||
buildPath: 'dist/less/', | ||
files: [ | ||
{ | ||
destination: 'variables.less', | ||
format: 'less/variables', | ||
}, | ||
], | ||
}, | ||
css: { | ||
transforms: ['dt/size/pxToRem', 'dt/fonts/transformToStack', 'attribute/cti', 'name/cti/kebab', 'time/seconds', 'content/icon', 'size/rem', 'color/css'], | ||
actions: ['buildDocJson'], | ||
prefix: 'dt', | ||
buildPath: 'dist/css/', | ||
files: [ | ||
{ | ||
destination: 'variables.css', | ||
format: 'css/variables', | ||
}, | ||
], | ||
}, | ||
android_xml: { | ||
transforms: ['attribute/cti', 'name/cti/snake', 'dt/android/color', 'size/remToSp', 'size/remToDp'], | ||
actions: ['buildDocJson'], | ||
prefix: 'dt', | ||
buildPath: 'dist/android/res/values/', | ||
files: [ | ||
{ | ||
destination: 'colors.xml', | ||
format: 'android/resources', | ||
resourceType: 'color', | ||
filter: function(token) { | ||
return ['color'].includes(token.type); | ||
const getStyleDictionaryConfig = (theme) => { | ||
return { | ||
source: [`tokens/tokens-${theme}.json`], | ||
platforms: { | ||
less: { | ||
transforms: ['dt/size/pxToRem', 'dt/fonts/transformToStack', 'attribute/cti', 'name/cti/kebab', 'time/seconds', 'content/icon', 'color/hex'], | ||
prefix: 'dt', | ||
buildPath: 'dist/less/', | ||
files: [ | ||
{ | ||
destination: `variables-${theme}.less`, | ||
format: 'less/variables', | ||
}, | ||
}, | ||
{ | ||
destination: 'dimens.xml', | ||
format: 'android/resources', | ||
resourceType: 'dimen', | ||
filter: function(token) { | ||
return ['sizing', 'borderRadius', 'fontSizes', 'borderWidth', 'spacing'].includes(token.type); | ||
], | ||
}, | ||
css: { | ||
transforms: ['dt/size/pxToRem', 'dt/fonts/transformToStack', 'attribute/cti', 'name/cti/kebab', 'time/seconds', 'content/icon', 'size/rem', 'color/css'], | ||
actions: ['buildDocJson'], | ||
prefix: 'dt', | ||
buildPath: 'dist/css/', | ||
files: [ | ||
{ | ||
destination: `variables-${theme}.css`, | ||
format: 'css/variables', | ||
options: { | ||
selector: `.dialtone-theme-${theme}` | ||
} | ||
}, | ||
}, | ||
], | ||
}, | ||
android_compose: { | ||
transforms: ['dt/android/compose/fonts/transformToStack', 'dt/android/fonts/weight', 'dt/android/lineHeight/percentToDecimal', 'dt/android/opacity/percentToFloat', 'dt/android/size/pxToDp', 'dt/android/size/pxToSp', 'dt/android/compose/color', 'dt/stringify', 'attribute/cti', 'name/cti/camel'], | ||
actions: ['buildDocJson'], | ||
prefix: 'dt', | ||
buildPath: 'dist/android/java/', | ||
files: [ | ||
{ | ||
destination: 'tokens.kt', | ||
format: 'compose/object', | ||
packageName: 'design.dialpad', | ||
className: 'DialtoneTokens', | ||
filter: function(token) { | ||
return token.path[0] !== 'tokenSetOrder'; | ||
], | ||
}, | ||
android_xml: { | ||
transforms: ['attribute/cti', 'name/cti/snake', 'dt/android/color', 'size/remToSp', 'size/remToDp'], | ||
actions: ['buildDocJson'], | ||
prefix: `dt_${theme}`, | ||
buildPath: 'dist/android/res/values/', | ||
files: [ | ||
{ | ||
destination: `colors-${theme}.xml`, | ||
format: 'android/resources', | ||
resourceType: 'color', | ||
filter: function(token) { | ||
return ['color'].includes(token.type); | ||
}, | ||
}, | ||
} | ||
] | ||
}, | ||
ios: { | ||
transforms: ['dt/ios/fonts/transformToStack', 'attribute/cti', 'name/cti/camel', 'dt/ios/color', 'dt/ios/size/pxToCGFloat', 'dt/ios/lineHeight/percentToDecimal', 'dt/stringify'], | ||
actions: ['buildDocJson'], | ||
prefix: 'dt', | ||
buildPath: 'dist/ios/', | ||
files: [ | ||
{ | ||
destination: 'tokens.swift', | ||
format: 'ios-swift/enum.swift', | ||
className: 'DialtoneTokens', | ||
filter: function(token) { | ||
return token.path[0] !== 'tokenSetOrder'; | ||
{ | ||
destination: 'dimens.xml', | ||
format: 'android/resources', | ||
resourceType: 'dimen', | ||
filter: function(token) { | ||
return ['sizing', 'borderRadius', 'fontSizes', 'borderWidth', 'spacing'].includes(token.type); | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
json: { | ||
prefix: 'dt', | ||
buildPath: 'dist/', | ||
transforms: ['dt/size/pxToRem', 'dt/fonts/transformToStack', 'name/cti/camel'], | ||
files: [ | ||
{ | ||
destination: 'tokens.json', | ||
format: 'json/flat', | ||
}, | ||
], | ||
], | ||
}, | ||
android_compose: { | ||
transforms: ['dt/android/compose/fonts/transformToStack', 'dt/android/fonts/weight', 'dt/android/lineHeight/percentToDecimal', 'dt/android/opacity/percentToFloat', 'dt/android/size/pxToDp', 'dt/android/size/pxToSp', 'dt/android/compose/color', 'dt/stringify', 'attribute/cti', 'name/cti/camel'], | ||
actions: ['buildDocJson'], | ||
prefix: 'dt', | ||
buildPath: 'dist/android/java/', | ||
files: [ | ||
{ | ||
destination: `tokens-${theme}.kt`, | ||
format: 'compose/object', | ||
packageName: 'design.dialpad', | ||
className: `DialtoneTokens${theme.charAt(0).toUpperCase() + theme.slice(1)}`, | ||
} | ||
] | ||
}, | ||
ios: { | ||
transforms: ['dt/ios/fonts/transformToStack', 'attribute/cti', 'name/cti/camel', 'dt/ios/color', 'dt/ios/size/pxToCGFloat', 'dt/ios/lineHeight/percentToDecimal', 'dt/stringify'], | ||
actions: ['buildDocJson'], | ||
prefix: 'dt', | ||
buildPath: 'dist/ios/', | ||
files: [ | ||
{ | ||
destination: `tokens-${theme}.swift`, | ||
format: 'ios-swift/enum.swift', | ||
className: `DialtoneTokens${theme.charAt(0).toUpperCase() + theme.slice(1)}`, | ||
}, | ||
], | ||
}, | ||
json: { | ||
prefix: 'dt', | ||
buildPath: 'dist/', | ||
transforms: ['dt/size/pxToRem', 'dt/fonts/transformToStack', 'name/cti/camel'], | ||
files: [ | ||
{ | ||
destination: `tokens-${theme}.json`, | ||
format: 'json/flat', | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
} | ||
}; | ||
|
||
exports.getStyleDictionaryConfig = getStyleDictionaryConfig; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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