Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BD-46] feat: refactoring design tokens folders structure #2069

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scss/core/css/utility-classes.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* IMPORTANT: This file is the result of assembling design tokens
* Do not edit directly
* Generated on Thu, 16 Feb 2023 10:37:12 GMT
* Generated on Tue, 21 Feb 2023 22:05:27 GMT
*/

.bg-dark {
Expand Down
847 changes: 423 additions & 424 deletions scss/core/css/variables.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tokens/sass-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const chroma = require('chroma-js');
* @return chroma-js color instance (one of dark or light variants)
*/
function colorYiq(color, light, dark, threshold) {
const defaultsFile = fs.readFileSync(path.resolve(__dirname, 'src', 'global', 'other.json'), 'utf8');
const defaultsFile = fs.readFileSync(path.resolve(__dirname, 'src', 'themes/light/global', 'other.json'), 'utf8');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[curious] Is everything in the other.json file specific to the light theme variant? Or are some of the properties, possibly like theme-interval, and yiq-contrasted-threshold.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, theme-interval and yiq-contrasted-threshold are not theme-specific, moved the to the core tokens

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question] If/when we have a dark theme variant, I wonder if there is a way we might be able to future proof this colorYiq helper function to support multiple theme variants later on (e.g., pulling from themes/dark/global/other.json to generate a dark.css output)?

The approach we're opting to take here is to have a light.css and dark.css output file, which would be generated by running the StyleDictionary.buildAllPlatforms() twice: once with the light theme variant tokens, and again with the dark theme variant tokens. If there's a way to pass in the current theme variant being used into the colorYiq that might be one approach to take here. Open to other ideas of course!

Copy link
Contributor

@viktorrusakov viktorrusakov Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I've modified our functions to check whether token belongs to any theme and take theme's colors instead (defaults to light)

const defaults = JSON.parse(defaultsFile);

const {
Expand Down
54 changes: 0 additions & 54 deletions tokens/src/components/Annotation.json

This file was deleted.

26 changes: 0 additions & 26 deletions tokens/src/components/Bubble.json

This file was deleted.

42 changes: 0 additions & 42 deletions tokens/src/components/Dropzone.json

This file was deleted.

57 changes: 0 additions & 57 deletions tokens/src/components/Tooltip.json

This file was deleted.

File renamed without changes.
30 changes: 30 additions & 0 deletions tokens/src/core/components/Alert.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"spacing": {
"alert": {
"padding": {
"y": { "value": "1.5rem", "source": "$alert-padding-y" },
"x": { "value": "1.5rem", "source": "$alert-padding-x" }
},
"margin-bottom": { "value": "1rem", "source": "$alert-margin-bottom" },
"actions-gap": { "value": "{spacing.spacer.3}", "source": "$alert-actions-gap" },
"icon-space": { "value": ".8rem", "source": "$alert-icon-space" }
}
},
"typography": {
"alert": {
"font": {
"weight-link": { "value": "{typography.font.weight.normal}", "source": "$alert-link-font-weight" },
"size": { "value": ".875rem", "source": "$alert-font-size" }
},
"line-height": { "value": "1.5rem", "source": "$alert-line-height" }
}
},
"size": {
"alert": {
"border": {
"radius": { "value": "{size.border.radius.base}", "source": "$alert-border-radius" },
"width": { "value": "0", "source": "$alert-border-width" }
}
}
}
}
25 changes: 25 additions & 0 deletions tokens/src/core/components/Annotation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"spacing": {
"annotation": {
"padding": { "value": ".5rem", "source": "$annotation-padding" },
"arrow-side": {
"margin": { "value": ".25rem", "source": "$annotation-arrow-side-margin" }
}
}
},
"typography": {
"annotation": {
"font-size": { "value": "{typography.font.size.sm}", "source": "$annotation-font-size" },
"line-height": { "value": "{typography.line-height.sm}", "source": "$annotation-line-height" }
}
},
"size": {
"annotation": {
"arrow-border": {
"width": { "value": ".5rem", "source": "$annotation-arrow-border-width" }
},
"max-width": { "value": "18.75rem", "source": "$annotation-max-width" },
"border-radius": { "value": ".25rem", "source": "$annotation-border-radius" }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"color": {
"avatar": {
"border": { "value": "{color.light.300}", "type": "color", "source": "$avatar-color-border" }
}
},
"size": {
"avatar": {
"base": { "value": "3rem", "type": "dimension", "source": "$avatar-size" },
Expand Down
33 changes: 33 additions & 0 deletions tokens/src/core/components/Badge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"spacing": {
"badge": {
"padding": {
"x": {
"base": { "value": ".5rem", "source": "$badge-padding-x" },
"pill": { "value": ".6em", "source": "$badge-pill-padding-x" }
},
"y": { "value": ".125rem", "source": "$badge-padding-y" }
}
}
},
"typography": {
"badge": {
"font": {
"size": { "value": "75%", "source": "$badge-font-size" },
"weight": { "value": "{typography.font.weight.bold}", "source": "$badge-font-weight" }
}
}
},
"size": {
"badge": {
"border-radius": {
"base": { "value": ".25rem", "source": "$badge-border-radius" },
"pill": { "value": "10rem", "source": "$badge-pill-border-radius" }
},
"focus-width": { "value": "{size.input.btn.focus-width}", "source": "$badge-focus-width" }
}
},
"transition": {
"badge": { "value": "none", "source": "$badge-transition" }
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
{
"color": {
"breadcrumb": {
"bg": { "value": "{color.gray.200}", "type": "color", "source": "$breadcrumb-bg" },
"base": { "value": "{color.primary.500}", "type": "color", "source": "$breadcrumb-color" },
"divider": { "value": "{color.gray.600}", "type": "color", "source": "$breadcrumb-divider-color" },
"active": { "value": "{color.gray.500}", "type": "color", "source": "$breadcrumb-active-color" },
"inverse": {
"base": { "value": "{color.white}", "type": "color", "source": "$breadcrumb-inverse-color" },
"active": { "value": "{color.light.500}", "type": "color", "source": "$breadcrumb-inverse-active" },
"spacer": { "value": "{color.light.700}", "type": "color", "source": "$breadcrumb-inverse-spacer" }
}
}
},
"typography": {
"breadcrumb": {
"font-size": { "value": "inherit", "type": "dimension", "source": "$breadcrumb-font-size" }
Expand Down
10 changes: 10 additions & 0 deletions tokens/src/core/components/Bubble.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"spacing": {
"bubble": {
"expandable-padding": {
"y": { "value": "0", "source": "$bubble-expandable-padding-y" },
"x": { "value": ".25rem", "source": "$bubble-expandable-padding-x" }
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"color": {
"btn": {
"disabled-link": { "value": "{color.disabled}", "type": "color", "source": "$btn-link-disabled-color" }
}
},
"spacing": {
"btn": {
"padding": {
Expand Down Expand Up @@ -80,23 +75,6 @@
}
}
},
"elevation": {
"btn": {
"box-shadow": {
"base": {
"value": "none",
"type": "shadow",
"source": "$btn-box-shadow"
},
"active": { "value": "none", "type": "shadow", "source": "$btn-active-box-shadow" }
}
}
},
"other": {
"btn": {
"disabled-opacity": { "value": ".65", "type": "ratio", "source": "$btn-disabled-opacity" }
}
},
"size": {
"btn": {
"border": {
Expand Down
Loading