Skip to content

Commit

Permalink
Merge pull request #209 from rei/pr/expose-source-tokens
Browse files Browse the repository at this point in the history
Expose source tokens and Remove alpha property
  • Loading branch information
c4rlosviteri authored Oct 28, 2024
2 parents 1c001a9 + 989d3de commit aa1462a
Show file tree
Hide file tree
Showing 66 changed files with 8,511 additions and 6,270 deletions.
328 changes: 164 additions & 164 deletions dist/docsite/android/colors.xml

Large diffs are not rendered by default.

328 changes: 164 additions & 164 deletions dist/docsite/css/cdr-tokens.css

Large diffs are not rendered by default.

1,869 changes: 1,566 additions & 303 deletions dist/docsite/figma/figma.json

Large diffs are not rendered by default.

328 changes: 164 additions & 164 deletions dist/docsite/ios/CdrColor.m

Large diffs are not rendered by default.

328 changes: 164 additions & 164 deletions dist/docsite/js/cdr-tokens.cjs

Large diffs are not rendered by default.

328 changes: 164 additions & 164 deletions dist/docsite/js/cdr-tokens.mjs

Large diffs are not rendered by default.

662 changes: 306 additions & 356 deletions dist/docsite/json/android.json

Large diffs are not rendered by default.

662 changes: 306 additions & 356 deletions dist/docsite/json/global.json

Large diffs are not rendered by default.

662 changes: 306 additions & 356 deletions dist/docsite/json/ios.json

Large diffs are not rendered by default.

662 changes: 306 additions & 356 deletions dist/docsite/json/platform-tokens.json

Large diffs are not rendered by default.

662 changes: 306 additions & 356 deletions dist/docsite/json/web.json

Large diffs are not rendered by default.

328 changes: 164 additions & 164 deletions dist/docsite/less/cdr-tokens.less

Large diffs are not rendered by default.

328 changes: 164 additions & 164 deletions dist/docsite/scss/cdr-tokens.scss

Large diffs are not rendered by default.

268 changes: 134 additions & 134 deletions dist/rei-dot-com/android/colors.xml

Large diffs are not rendered by default.

268 changes: 134 additions & 134 deletions dist/rei-dot-com/css/cdr-tokens.css

Large diffs are not rendered by default.

1,754 changes: 1,502 additions & 252 deletions dist/rei-dot-com/figma/figma.json

Large diffs are not rendered by default.

268 changes: 134 additions & 134 deletions dist/rei-dot-com/ios/CdrColor.m

Large diffs are not rendered by default.

268 changes: 134 additions & 134 deletions dist/rei-dot-com/js/cdr-tokens.cjs

Large diffs are not rendered by default.

268 changes: 134 additions & 134 deletions dist/rei-dot-com/js/cdr-tokens.mjs

Large diffs are not rendered by default.

540 changes: 252 additions & 288 deletions dist/rei-dot-com/json/android.json

Large diffs are not rendered by default.

540 changes: 252 additions & 288 deletions dist/rei-dot-com/json/global.json

Large diffs are not rendered by default.

540 changes: 252 additions & 288 deletions dist/rei-dot-com/json/ios.json

Large diffs are not rendered by default.

540 changes: 252 additions & 288 deletions dist/rei-dot-com/json/platform-tokens.json

Large diffs are not rendered by default.

540 changes: 252 additions & 288 deletions dist/rei-dot-com/json/web.json

Large diffs are not rendered by default.

268 changes: 134 additions & 134 deletions dist/rei-dot-com/less/cdr-tokens.less

Large diffs are not rendered by default.

268 changes: 134 additions & 134 deletions dist/rei-dot-com/scss/cdr-tokens.scss

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions style-dictionary/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import { stripPx } from './transforms/size/strip-px.mjs'
import { stripAllPx } from './transforms/size/strip-all-px.mjs'
import { stripAllPxJs } from './transforms/size/strip-all-px-js.mjs'
import { float } from './transforms/size/float.mjs'
import { alpha } from './transforms/color/alpha.mjs'
import { colorCssTransitive } from './transforms/color/color-css-transitive.mjs'
import { hex8AndroidTransitive } from './transforms/color/hex8-android-transitive.mjs'
import { uiColorTransitive } from './transforms/color/uicolor-transitive.mjs'
import { shadow } from './transforms/value/shadow.mjs'

// ==== Include custom formats ====
Expand All @@ -35,7 +32,6 @@ import { includeMediaQueriesScss } from './actions/include-media-queries-scss.mj

// ==== Include custom filters ====
import { removeSourceTokens } from './filters/remove-source-tokens.mjs'
import { iosSize } from './filters/ios-size.mjs'

// ==== Register style dictionary ====
register(StyleDictionary)
Expand All @@ -50,10 +46,7 @@ stripPx(StyleDictionary)
stripAllPx(StyleDictionary)
stripAllPxJs(StyleDictionary)
float(StyleDictionary)
alpha(StyleDictionary)
colorCssTransitive(StyleDictionary)
hex8AndroidTransitive(StyleDictionary)
uiColorTransitive(StyleDictionary)
shadow(StyleDictionary)

// ==== Register custom formats ====
Expand All @@ -73,7 +66,6 @@ includeMediaQueriesScss(StyleDictionary)

// ==== Register custom filters ====
removeSourceTokens(StyleDictionary)
iosSize(StyleDictionary)

const themes = [
'rei-dot-com',
Expand Down
17 changes: 5 additions & 12 deletions style-dictionary/configs/android.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { commonConfig } from '../utils.mjs'
import { commonConfig, filterSourceTokensAndType } from '../utils.mjs'

export const android = (theme) => ({
android: {
Expand All @@ -8,29 +8,22 @@ export const android = (theme) => ({
'size/space',
'size/dp-transitive',
'size/sp',
'color/alpha',
'color/hex8android-transitive'
'color/hex8android'
],
files: [
{
destination: 'colors.xml',
filter: {
$type: 'color'
},
filter: (token) => filterSourceTokensAndType(token, 'color'),
format: 'android/resources'
},
{
destination: 'font_dimens.xml',
filter: {
$type: 'fontSize'
},
filter: (token) => filterSourceTokensAndType(token, 'fontSize'),
format: 'android/fontDimens'
},
{
destination: 'dimens.xml',
filter: {
$type: 'dimension'
},
filter: (token) => filterSourceTokensAndType(token, 'dimension'),
format: 'android/dimens'
}
]
Expand Down
4 changes: 2 additions & 2 deletions style-dictionary/configs/css.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ export const css = (theme) => ({
'name/kebab',
'size/space',
'size/px-to-rem-transitive',
'color/alpha',
'color/css-transitive'
],
files: [
{
destination: 'cdr-tokens.css',
format: 'css/variables'
format: 'css/variables',
filter: 'remove-source-tokens'
}
]
}
Expand Down
4 changes: 1 addition & 3 deletions style-dictionary/configs/figma.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ export const figma = (theme) => ({
'name/kebab',
'size/space',
'size/px-to-rem-transitive',
'color/alpha',
'color/css-transitive'
],
files: [
{
destination: 'figma.json',
format: 'figma',
filter: 'remove-source-tokens'
format: 'figma'
}
]
}
Expand Down
17 changes: 6 additions & 11 deletions style-dictionary/configs/ios.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { commonConfig } from '../utils.mjs'
import { commonConfig, filterSourceTokensAndType } from '../utils.mjs'

export const ios = (theme) => ({
ios: {
...commonConfig(theme, 'ios'),
transforms: [
'attribute/deprecated',
'name/pascal',
'color/alpha',
'color/UIColor-transitive',
'color/UIColor',
'size/strip-px',
'size/space',
'size/float'
Expand All @@ -16,7 +15,7 @@ export const ios = (theme) => ({
{
destination: 'CdrSize.h',
format: 'ios/static.h',
filter: 'ios-size',
filter: (token) => filterSourceTokensAndType(token, ['dimension', 'fontSize']),
options: {
type: 'float',
className: 'CdrSize'
Expand All @@ -25,7 +24,7 @@ export const ios = (theme) => ({
{
destination: 'CdrSize.m',
format: 'ios/static.m',
filter: 'ios-size',
filter: (token) => filterSourceTokensAndType(token, ['dimension', 'fontSize']),
options: {
type: 'float',
className: 'CdrSize'
Expand All @@ -34,9 +33,7 @@ export const ios = (theme) => ({
{
destination: 'CdrColor.h',
format: 'ios/colors.h',
filter: {
$type: 'color'
},
filter: (token) => filterSourceTokensAndType(token, 'color'),
options: {
type: 'CdrColorName',
className: 'CdrColor'
Expand All @@ -45,9 +42,7 @@ export const ios = (theme) => ({
{
destination: 'CdrColor.m',
format: 'ios/colors.m',
filter: {
$type: 'color'
},
filter: (token) => filterSourceTokensAndType(token, 'color'),
options: {
type: 'CdrColorName',
className: 'CdrColor'
Expand Down
7 changes: 4 additions & 3 deletions style-dictionary/configs/js.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ export const js = (theme) => ({
'name/pascal',
'size/strip-all-px-js',
'size/space-js',
'color/alpha',
'color/css-transitive',
'value/shadow'
],
files: [
{
destination: 'cdr-tokens.cjs',
format: 'javascript/module-flat'
format: 'javascript/module-flat',
filter: 'remove-source-tokens'
},
{
destination: 'cdr-tokens.mjs',
Expand All @@ -24,7 +24,8 @@ export const js = (theme) => ({
},
{
format: 'typescript/es6-declarations',
destination: 'cdr-tokens.d.mts'
destination: 'cdr-tokens.d.mts',
filter: 'remove-source-tokens'
}
]
}
Expand Down
7 changes: 4 additions & 3 deletions style-dictionary/configs/less.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ export const less = (theme) => ({
'name/kebab',
'size/space',
'size/px-to-rem-transitive',
'color/alpha',
'color/css-transitive'
],
files: [
{
destination: 'cdr-variable.less',
format: 'less/variables'
format: 'less/variables',
filter: 'remove-source-tokens'
},
{
destination: 'cdr-mixins.less',
format: 'less/mixin'
format: 'less/mixin',
filter: 'remove-source-tokens'
}
],
actions: ['include-media-queries-less', 'include-display-less', 'concat-files']
Expand Down
4 changes: 2 additions & 2 deletions style-dictionary/configs/scss.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ export const scss = (theme) => ({
'name/kebab',
'size/space',
'size/px-to-rem-transitive',
'color/alpha',
'color/css-transitive'
],
files: [
{
destination: 'cdr-variable.scss',
format: 'scss/variables'
format: 'scss/variables',
filter: 'remove-source-tokens'
},
{
destination: 'cdr-mixins.scss',
Expand Down
3 changes: 1 addition & 2 deletions style-dictionary/configs/site.android.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ export const siteAndroid = (theme) => ({
'size/space',
'size/dp-transitive',
'size/sp',
'color/alpha',
'color/hex8android-transitive'
'color/hex8android'
],
files: [
{
Expand Down
1 change: 0 additions & 1 deletion style-dictionary/configs/site.global.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const siteGlobal = (theme) => ({
'name/kebab',
'size/strip-all-px-js',
'size/space-js',
'color/alpha',
'color/css-transitive',
'size/px-to-rem-transitive',
'time/seconds'
Expand Down
3 changes: 1 addition & 2 deletions style-dictionary/configs/site.ios.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ export const siteIos = (theme) => ({
transforms: [
'attribute/deprecated',
'name/pascal',
'color/alpha',
'color/UIColor-transitive',
'color/UIColor',
'size/strip-px',
'size/space',
'size/float'
Expand Down
1 change: 0 additions & 1 deletion style-dictionary/configs/site.web.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const siteWeb = (theme) => ({
'name/kebab',
'size/strip-px',
'size/space-js',
'color/alpha',
'color/css-transitive',
'size/px-to-rem-transitive',
'time/seconds'
Expand Down
6 changes: 0 additions & 6 deletions style-dictionary/filters/ios-size.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion style-dictionary/formats/figma.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const figma = (StyleDictionary) => {
StyleDictionary.registerFormat({
name: 'figma',
format: ({ dictionary }) => {
const propsToRemove = ['isSource', 'attributes', 'path', 'docs', 'newToken', 'name', 'alpha']
const propsToRemove = ['isSource', 'attributes', 'path', 'docs', 'newToken', 'name', 'docCategory', 'docExample']
const transformedTokens = cleanMeta(dictionary.tokens, { cleanMeta: propsToRemove })

return JSON.stringify(transformedTokens, null, 2)
Expand Down
17 changes: 0 additions & 17 deletions style-dictionary/transforms/color/alpha.mjs

This file was deleted.

14 changes: 0 additions & 14 deletions style-dictionary/transforms/color/hex8-android-transitive.mjs

This file was deleted.

29 changes: 0 additions & 29 deletions style-dictionary/transforms/color/uicolor-transitive.mjs

This file was deleted.

5 changes: 5 additions & 0 deletions style-dictionary/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ export const commonConfig = (theme, platform) => ({
showFileHeader: false
}
})

export const filterSourceTokensAndType = (token, type) => {
const types = Array.isArray(type) ? type : [type]
return token.path[0] !== 'options' && token.path[0] !== 'theme' && types.includes(token.$type)
}
Loading

0 comments on commit aa1462a

Please sign in to comment.