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: ensure design tokens have a valid type attribute #1992

Conversation

PKulkoRaccoonGang
Copy link
Contributor

Description

Ensure design tokens have a valid type attribute
Issue #1947
W3C report

Merge Checklist

  • If your update includes visual changes, have they been reviewed by a designer? Send them a link to the Netlify deploy preview, if applicable.
  • Does your change adhere to the documented style conventions?
  • Do any prop types have missing descriptions in the Props API tables in the documentation site (check deploy preview)?
  • Were your changes tested using all available themes (see theme switcher in the header of the deploy preview, under the "Settings" icon)?
  • Were your changes tested in the example app?
  • Is there adequate test coverage for your changes?
  • Consider whether this change needs to reviewed/QA'ed for accessibility (a11y). If so, please add wittjeff and adamstankiewicz as reviewers on this PR.

Post-merge Checklist

  • Verify your changes were released to NPM at the expected version.
  • If you'd like, share your contribution in #show-and-tell.
  • 🎉 🙌 Celebrate! Thanks for your contribution.

@openedx-webhooks openedx-webhooks added the blended PR is managed through 2U's blended developmnt program label Feb 1, 2023
@openedx-webhooks
Copy link

Thanks for the pull request, @PKulkoRaccoonGang!

When this pull request is ready, tag your edX technical lead.

@codecov
Copy link

codecov bot commented Feb 1, 2023

Codecov Report

Base: 90.41% // Head: 90.41% // No change to project coverage 👍

Coverage data is based on head (2998785) compared to base (5b7ecf2).
Patch has no changes to coverable lines.

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -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",
Copy link
Contributor

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

Copy link
Member

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.

@PKulkoRaccoonGang PKulkoRaccoonGang force-pushed the Peter_Kulko/ensure-design-tokens-have-a-valid-type-attribute branch from aecd376 to e7b2e09 Compare February 12, 2023 21:06
}
}
},
"elevation": {
"alert": {
"box-shadow": {
"value": "0 1px 2px rgba(0, 0, 0, .15), 0 1px 4px rgba(0, 0, 0, .15)",
"type": "shadow",
Copy link
Member

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" },
Copy link
Member

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" },
      }
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, it makes sense 👍

Comment on lines +16 to +19
"size": { "value": "75%", "type": "percentage", "source": "$badge-font-size" },
"weight": {
"value": "{typography.font.weight.bold}", "type": "fontWeight", "source": "$badge-font-weight"
}
Copy link
Member

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.

image

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" }
Copy link
Member

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.

},
"footer-position": { "value": "center", "source": "$data-table-footer-position" }
"footer-position": { "value": "center", "type": "ratio", "source": "$data-table-footer-position" }
Copy link
Member

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?

Copy link
Contributor Author

@PKulkoRaccoonGang PKulkoRaccoonGang Feb 15, 2023

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).

Copy link
Contributor

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?

Copy link
Member

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",
Copy link
Member

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.

@adamstankiewicz adamstankiewicz merged commit 85acf33 into openedx:alpha Feb 15, 2023
@openedx-webhooks
Copy link

@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.

@edx-semantic-release
Copy link
Contributor

🎉 This PR is included in version 21.0.0-alpha.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

@adamstankiewicz adamstankiewicz linked an issue Feb 15, 2023 that may be closed by this pull request
viktorrusakov pushed a commit to viktorrusakov/paragon that referenced this pull request Feb 17, 2023
Adds `type` attribute to all design tokens per W3C design tokens spec.
adamstankiewicz pushed a commit that referenced this pull request Feb 17, 2023
Adds `type` attribute to all design tokens per W3C design tokens spec.
adamstankiewicz pushed a commit that referenced this pull request Feb 17, 2023
Adds `type` attribute to all design tokens per W3C design tokens spec.
adamstankiewicz pushed a commit that referenced this pull request Feb 17, 2023
Adds `type` attribute to all design tokens per W3C design tokens spec.
adamstankiewicz pushed a commit that referenced this pull request Feb 17, 2023
Adds `type` attribute to all design tokens per W3C design tokens spec.
edx-requirements-bot pushed a commit that referenced this pull request Feb 17, 2023
Adds `type` attribute to all design tokens per W3C design tokens spec.
edx-requirements-bot pushed a commit that referenced this pull request Feb 17, 2023
Adds `type` attribute to all design tokens per W3C design tokens spec.
edx-requirements-bot pushed a commit that referenced this pull request Feb 17, 2023
Adds `type` attribute to all design tokens per W3C design tokens spec.
edx-requirements-bot pushed a commit that referenced this pull request Feb 17, 2023
Adds `type` attribute to all design tokens per W3C design tokens spec.
edx-requirements-bot pushed a commit that referenced this pull request Feb 17, 2023
Adds `type` attribute to all design tokens per W3C design tokens spec.
edx-requirements-bot pushed a commit that referenced this pull request Feb 17, 2023
Adds `type` attribute to all design tokens per W3C design tokens spec.
edx-requirements-bot pushed a commit that referenced this pull request Feb 17, 2023
Adds `type` attribute to all design tokens per W3C design tokens spec.
edx-requirements-bot pushed a commit that referenced this pull request Feb 17, 2023
Adds `type` attribute to all design tokens per W3C design tokens spec.
edx-requirements-bot added a commit that referenced this pull request Feb 17, 2023
* 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>
adamstankiewicz pushed a commit that referenced this pull request Feb 17, 2023
Adds `type` attribute to all design tokens per W3C design tokens spec.
adamstankiewicz pushed a commit that referenced this pull request Feb 20, 2023
Adds `type` attribute to all design tokens per W3C design tokens spec.
monteri pushed a commit to raccoongang/paragon that referenced this pull request Aug 17, 2023
Adds `type` attribute to all design tokens per W3C design tokens spec.
PKulkoRaccoonGang added a commit to raccoongang/paragon that referenced this pull request Aug 18, 2023
Adds `type` attribute to all design tokens per W3C design tokens spec.
PKulkoRaccoonGang added a commit that referenced this pull request Aug 1, 2024
Adds `type` attribute to all design tokens per W3C design tokens spec.
PKulkoRaccoonGang added a commit that referenced this pull request Aug 4, 2024
Adds `type` attribute to all design tokens per W3C design tokens spec.
PKulkoRaccoonGang added a commit that referenced this pull request Aug 4, 2024
Adds `type` attribute to all design tokens per W3C design tokens spec.
PKulkoRaccoonGang added a commit that referenced this pull request Aug 5, 2024
Adds `type` attribute to all design tokens per W3C design tokens spec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blended PR is managed through 2U's blended developmnt program released on @alpha
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Ensure design tokens have a valid type attribute
5 participants