-
Notifications
You must be signed in to change notification settings - Fork 72
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: ensure design tokens have a valid type attribute #1992
[BD-46] feat: ensure design tokens have a valid type attribute #1992
Conversation
Thanks for the pull request, @PKulkoRaccoonGang! When this pull request is ready, tag your edX technical lead. |
Codecov ReportBase: 90.41% // Head: 90.41% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## alpha #1992 +/- ##
=======================================
Coverage 90.41% 90.41%
=======================================
Files 192 192
Lines 3120 3120
Branches 746 746
=======================================
Hits 2821 2821
Misses 283 283
Partials 16 16 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@@ -54,23 +55,17 @@ | |||
"bg": { | |||
"prev-icon": { | |||
"value": "url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='{color.carousel.control.base.value}' viewBox='0 0 8 8'%3e%3cpath d='M5.25 0l-4 4 4 4 1.5-1.5-2.5-2.5 2.5-2.5-1.5-1.5z'/%3e%3c/svg%3e\")", | |||
"type": "file", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I don't think we should use file
here, we're not loading any files with the url
, it's just an svg. Maybe we can introduce svg
type for such cases, even though it's not covered by W3C specs?
@adamstankiewicz curious what you think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viktorrusakov Good question... I'm a bit hesitant to introduce a svg
type that isn't officially covered by the W3C spec. The file type per the W3C spec seems to indicate the file
type might still be in flux as well. Given SVGs are technically files, even though its not defined as a separate file here, I'm inclined to leave these tokens as "type": "file"
for the time being.
aecd376
to
e7b2e09
Compare
} | ||
} | ||
}, | ||
"elevation": { | ||
"alert": { | ||
"box-shadow": { | ||
"value": "0 1px 2px rgba(0, 0, 0, .15), 0 1px 4px rgba(0, 0, 0, .15)", | ||
"type": "shadow", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the documentation for the shadow
token type, it is a composite token made up of multiple properties (docs):
{
"shadow-token": {
"$type": "shadow",
"$value": {
"color": "#00000080",
"offsetX": "0.5rem",
"offsetY": "0.5rem",
"blur": "1.5rem",
"spread": "0rem"
}
}
}
As is, we're defining the shadow using a CSS-specific value
. Because shadow
is a composite token, each aspect of the shadow is defined as its own property. style-dictionary
seems to have support for composite tokens but they may need custom transforms/formatters to handle them properly for each platform.
Conceptually, this makes sense; the tokens are intended to be platform agnostic such that they can be transformed into platform-specific implementations. In the current form, we're essentially assuming the shadow token will always be used as a CSS value, which wouldn't be compatible if/when we transform tokens for iOS/Android apps eventually.
There seems to be consensus in the W3C issues regarding the shadow
composite type that it should support an array for its value to define multiple layers of shadow, as is the use case for this token. While it's not officially documented, I think it's safe to assume moving in that direction makes sense.
In refactoring, we'd likely need to implement a custom transformer to deal with the composite shadow type, perhaps similar to this example.
"base": { "value": "none", "source": "$link-decoration" }, | ||
"hover": { "value": "underline", "source": "$link-hover-decoration" }, | ||
"base": { "value": "none", "type": "strokeStyle", "source": "$link-decoration" }, | ||
"hover": { "value": "underline", "type": "strokeStyle", "source": "$link-hover-decoration" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[curious] I believe strokeStyle
refers more to things like border stroke, not so much the text-decoration
. Since the underline here is related to text-decoration
, it may be an additional property on composite tokens of type typography
(docs).
Since this is still up in the air in the W3C spec, perhaps we can opt for defining a textDecoration
type here to represent the enum of choices available for text-decoration
similar to what W3C is proposing for the fontFamily
and fontWeight
token types.
{
"typography": {
"link": {
"decoration": {
"base": { "value": "none", "type": "textDecoration", "source": "$link-decoration" },
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it makes sense 👍
"size": { "value": "75%", "type": "percentage", "source": "$badge-font-size" }, | ||
"weight": { | ||
"value": "{typography.font.weight.bold}", "type": "fontWeight", "source": "$badge-font-weight" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[curious] Would love to hear your thoughts on whether we should start defining typography-related tokens as composite tokens based on the proposed spec. For example, these tokens defining the text styles for the badge component might be written as:
{
"typography": {
"badge": {
"type": "typography",
"value": {
"fontSize": "75%",
"fontWeight": "{typography.font.weight.bold}"
}
}
}
}
This would likely require implementation of a custom transform to deal with the composite typography type, perhaps similar to this example.
For example, Figma's Tokens Studio plugin allows composite typography tokens.
My biggest concern is that if we keep the distinct token approach we have now vs. refactoring to composite tokens is that if we want to switch down the road after design tokens are out in the wild, it'd be a breaking change.
Curious to hear how you feel about composite typography tokens vs. having distinct token definitions for each typography property as we currently have.
} | ||
}, | ||
"transition": { | ||
"badge": { "value": "none", "source": "$badge-transition" } | ||
"badge": { "value": "none", "type": "transition", "source": "$badge-transition" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[curious] The transition token type per the spec is a composite token. Similar question here as other comments around whether we should adopt the composite tokens vs. single token per property approach.
tokens/src/components/DataTable.json
Outdated
}, | ||
"footer-position": { "value": "center", "source": "$data-table-footer-position" } | ||
"footer-position": { "value": "center", "type": "ratio", "source": "$data-table-footer-position" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[curious] what is the ratio
type representing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viktorrusakov proposed to use the type: "position"
. Its a good type for the CSS property align-self
(start, center, end).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I don't think W3C specs have a type for such properties, position
sounds good to me.
@adamstankiewicz what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
position
sounds good here, too +1
"input": { "value": "border-color .15s ease-in-out, box-shadow .15s ease-in-out", "source": "$input-transition" }, | ||
"input": { | ||
"value": "border-color .15s ease-in-out, box-shadow .15s ease-in-out", | ||
"type": "transition", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[consideration] Curious for your thoughts on whether we should define transitions as a composite token? Primary rationale being that having the separate parts helps define the style properties in a more platform agnostic way than this CSS implementation. It would likely require a custom transform, though.
@PKulkoRaccoonGang 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
🎉 This PR is included in version 21.0.0-alpha.10 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
* build: switch base to trying a rebase (#2047) * build: pull from alpha before rebase master (#2049) * build: git checkout instead of git switch (#2051) * build: set base branch to alpha (#2053) * feat: alpha release of design tokens (#1770) * build: add alpha/beta to release CI workflow * feat: design tokens with style-dictionary BREAKING CHANGE: Introduces design tokens. * [BD-46] resolve bootstrap conflicts with design tokens (#1800) * feat: resolve some Bootstrap conflicts with design tokens Co-authored-by: Peter Kulko <93188219+PKulkoRaccoonGang@users.noreply.github.com> * feat: add ability to generate CSS utility classes through design tokens * docs: added background-color for color HEX values on CSS utility classes page * fix: add missed border utilities * docs: add ability to view CSS variables on CSS Utility Classes page * chore: remove unused import * feat: remove deprecated components BREAKING CHANGE: all of the deprecated components were removed from Paragon, these include `CheckBoxGroup`, `Checkbox`, `Fieldset`, `Input`, `InputSelect`, `InputText`, `ListBox`, `Modal`, `RadioButtonGroup`, `StatusAlert`, `Table`, `TextArea`, `ValidationFormGroup`, `Button.Deprecated`, `Tabs.Deprecated`, `Dropdown.Deprecated`. * chore: update tokens for Modal components * docs: display computed CSS variables on components' pages * refactor: update design tokens structure * feat: add CLI interface for design tokens (#1846) * fix: install dependencies in tokens module after installing Paragon * fix: remove package.json files from tokens module * refactor: update design tokens structure * refactor: replace old tables with `DataTable` on documentation site (#1859) * [BD-46] refactor: improve design tokens architecture (#1874) * refactor: update design tokens naming and add missing ones * feat: expose replace vars script to CLI Co-authored-by: Viktor Rusakov <vrusakov66@gmail.com> * build: add workflow_dispatch to alpha branch to trigger release * fix: trigger release * fix: added custom title for CSS output files (#1985) * feat: deleted value in reference design tokens (#1989) * fix: ensure design tokens have a valid type attribute (#1992) Adds `type` attribute to all design tokens per W3C design tokens spec. * fix: add missing tokens for Button component (#1924) * feat: add new tokens and cleanup after rebase * feat: alpha release of design tokens (#1770) * feat: design tokens with style-dictionary BREAKING CHANGE: Introduces design tokens. * [BD-46] resolve bootstrap conflicts with design tokens (#1800) * feat: resolve some Bootstrap conflicts with design tokens Co-authored-by: Peter Kulko <93188219+PKulkoRaccoonGang@users.noreply.github.com> * feat: add ability to generate CSS utility classes through design tokens * docs: added background-color for color HEX values on CSS utility classes page * fix: add missed border utilities * docs: add ability to view CSS variables on CSS Utility Classes page * chore: remove unused import * feat: remove deprecated components BREAKING CHANGE: all of the deprecated components were removed from Paragon, these include `CheckBoxGroup`, `Checkbox`, `Fieldset`, `Input`, `InputSelect`, `InputText`, `ListBox`, `Modal`, `RadioButtonGroup`, `StatusAlert`, `Table`, `TextArea`, `ValidationFormGroup`, `Button.Deprecated`, `Tabs.Deprecated`, `Dropdown.Deprecated`. * chore: update tokens for Modal components * refactor: update design tokens structure * feat: add CLI interface for design tokens (#1846) * fix: install dependencies in tokens module after installing Paragon * fix: remove package.json files from tokens module * refactor: update design tokens structure * [BD-46] refactor: improve design tokens architecture (#1874) * refactor: update design tokens naming and add missing ones * feat: expose replace vars script to CLI Co-authored-by: Viktor Rusakov <vrusakov66@gmail.com> * fix: trigger release * feat: deleted value in reference design tokens (#1989) * fix: ensure design tokens have a valid type attribute (#1992) Adds `type` attribute to all design tokens per W3C design tokens spec. * fix: add missing tokens for Button component (#1924) * Revert "chore(release): sync from master to alpha (#2040)" This reverts commit 14ba07c. * feat: add new tokens and cleanup after rebase --------- Co-authored-by: Adam Stankiewicz <agstanki@gmail.com> Co-authored-by: Viktor Rusakov <52399399+viktorrusakov@users.noreply.github.com> Co-authored-by: Peter Kulko <93188219+PKulkoRaccoonGang@users.noreply.github.com> Co-authored-by: Viktor Rusakov <vrusakov66@gmail.com>
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Adds `type` attribute to all design tokens per W3C design tokens spec.
Description
Ensure design tokens have a valid type attribute
Issue #1947
W3C report
Merge Checklist
example
app?wittjeff
andadamstankiewicz
as reviewers on this PR.Post-merge Checklist