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

feat!: refactor design tokens and token transformer #8149

Closed
wants to merge 5 commits into from

Conversation

alisonailea
Copy link
Contributor

@alisonailea alisonailea commented Nov 8, 2023

Related Issue: #7325 #8141

Summary

This is a complete refactor of the token transformer. This introduces breaking changes to tokens.

BREAKING CHANGE:

  • removes tokens with “light” and “dark” in their names in favor of composite color mode tokens which now have separate outputs.
  • new platform output files. Replaces “headless” with “global” and removes “calcite” from filenames.
  • tokens no longer include "app" or "ui" in their names
  • breakpoint tokens are no longer included in "global" CSS or SCSS output
  • breakpoint tokens have been renamed to "container-size" (i.e --calcite-app-breakpoint-width-lg-min is now --calcite-container-size-width-lg-min)
  • global tokens have been refactored to use ordinal t-shirt sizing. These tokens reference the nominal token values in core. If you still need the nominal values you may import "core" tokens but this is not recommended.
  • tokens using the word "sizing" in their names now use "size"
  • remove duplicates in token names border-border-width is now border-width

@alisonailea alisonailea added the future breaking change Issues and pull requests with deprecation(s), requires a breaking change in a future milestone. label Nov 8, 2023
@alisonailea alisonailea self-assigned this Nov 8, 2023
@alisonailea alisonailea marked this pull request as draft November 8, 2023 20:57
@alisonailea alisonailea force-pushed the astump/7325-reduce-tokens-output branch from c2f17f2 to 34d4a6e Compare November 16, 2023 00:57
@alisonailea alisonailea added 2 - in development Issues that are actively being worked on. and removed 2 - in development Issues that are actively being worked on. labels Nov 16, 2023
@alisonailea alisonailea added this to the 2023 November Priorities milestone Nov 16, 2023
@alisonailea alisonailea marked this pull request as ready for review November 16, 2023 01:01
@alisonailea alisonailea changed the title WIP: reduce tokens output feat!: design tokens refactor Nov 16, 2023
@jcfranco
Copy link
Member

@alisonailea Awesome! Some pre-review notes:

@alisonailea alisonailea changed the title feat!: design tokens refactor feat (design tokens)!: refactor Nov 16, 2023
@jcfranco
Copy link
Member

jcfranco commented Nov 16, 2023

It also looks like this is addressing #8141. If so, can this be rolled back and tackled separately to have more focused PRs? If not, can you comment on this and cover it in the breaking changes notes?

@jcfranco
Copy link
Member

BREAKING CHANGES

This must be singular to adhere to the spec.

@alisonailea alisonailea changed the base branch from main to rc November 16, 2023 18:07
set old core tokens for deprecation
update token types
align token reference syntax with design token standards
BREAKING CHANGE: removes “light” and “dark” tokens in favor of composite color mode tokens
BREAKING CHANGE: new platform output files. Replaces “headless” with “global” and removes “calcite” from filenames.

Significantly reduces the filesize of platform output files.
Now supports composite color mode tokens and typography tokens
Adds multi-file output, including ./index files
removes unused $metadata
@alisonailea alisonailea force-pushed the astump/7325-reduce-tokens-output branch from 34d4a6e to 5b10c62 Compare November 16, 2023 18:29
@alisonailea alisonailea changed the title feat (design tokens)!: refactor feat (calcite-design-tokens)!: refactor Nov 16, 2023
@alisonailea alisonailea changed the title feat (calcite-design-tokens)!: refactor feat (calcite-design-tokens)!: refactor design tokens and token transformer Nov 16, 2023
@jcfranco jcfranco changed the title feat (calcite-design-tokens)!: refactor design tokens and token transformer feat!: refactor design tokens and token transformer Nov 16, 2023
@jcfranco jcfranco added breaking change Issues and pull requests with code changes that are not backwards compatible. and removed future breaking change Issues and pull requests with deprecation(s), requires a breaking change in a future milestone. labels Nov 16, 2023
Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

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

This is looking great, @alisonailea!

Regarding the spell checker, I think we can use a very terse explainer for ignored lines we can reuse for now. If we can separate files extended from sd-transforms, we can ignore those entirely.

},
"23": {
"value": "144px",
"type": "sizing"
"type": "sizing",
"description": "For backwards compatibility only. This token will be removed from the published tokens in the next major version because the type \"size\" is prefered by designer",
Copy link
Member

Choose a reason for hiding this comment

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

Great job on adding a deprecation notice for these. ✨⭐✨

},
"24": {
"value": "160px",
"type": "sizing"
"type": "sizing",
"description": "For backwards compatibility only. This token will be removed from the published tokens in the next major version because the type \"size\" is prefered by designer",
Copy link
Member

Choose a reason for hiding this comment

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

Typo: prefered ➡️ preferred.

Question: should designer be pluralized?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for the catch. Should be "preferred by design"

"border-radius": {
"value": "{core.border.border-radius.none}",
"type": "borderRadius",
"description": "For backwards compatibility only. This token will be removed from the published tokens in the next major version in favor of removing the \"ui\" level that doesn't match the naming schema.",
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs to be updated according to the latest breaking change notes in the description:

  • exported token no longer include "app" or "ui"

Applies to other items with the same description.

"light": {
"value": "{core.font.font-weight.light}",
"type": "fontWeights",
"description": "only for Avenir Next World (secondary font family)"
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: For consistency, this description should also start capitalized.

"7": {
"value": "{core.font.font-size.7}",
"type": "fontSizes",
"description": "For backwards compatibility only. This token will be removed from the published tokens in the next major version in favor of t-shirt sizing tokens.",
Copy link
Member

Choose a reason for hiding this comment

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

t-shirt sizing

TIL 🌠🤩


export function formatTokens(dictionary: Dictionary, args: MappedFormatterArguments): FormattedTokens {
const allTokens = [...dictionary.allTokens].sort(sortByReference(dictionary));
// const formatting = FormattingRules[args.options.platform] || FormattingRules.default;
Copy link
Member

Choose a reason for hiding this comment

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

Please remove all commented-out code.

@@ -0,0 +1,52 @@
/**
* This is a copy/extension of sd-transforms/src/parsers/resolveReference.ts but now with better types!
Copy link
Member

Choose a reason for hiding this comment

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

Can you make sure all copies have a note on them? I think we need a way to separate them.

How will we keep these in sync with the upstream source?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't have to. I pulled in the fuctions they use that I think are helpful but since design is moving away from Token Studio we should not need to keep track of the upstream source.

import { Options } from "../../../types/styleDictionary/options.js";
import { PossibleRegistryArgs } from "../utils.js";
import { PlatformOptions } from "../../../types/styleDictionary/platform.js";
// import { TransformedToken } from "../../../types/styleDictionary/transformedToken.js";
Copy link
Member

Choose a reason for hiding this comment

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

Please remove commented-out code.

tokens: TransformedTokens;
allProperties: TransformedToken[];
properties: TransformedTokens;
usesReference: (value: any) => boolean;
Copy link
Member

Choose a reason for hiding this comment

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

Can the type be narrowed or is it unknown?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could potentially be anything at this point.

"value": "$semantic.ui.color.foreground.1.dark",
"type": "color"
}
"value": "{semantic.ui.color.foreground.1}",
Copy link
Member

Choose a reason for hiding this comment

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

I noticed this was the only component-level token that has a description. Is it intentional? If so, will others be updated as well?

On a similar note, this was the only one I found where background entry that didn't have a default nor light/dark keys right under it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

component tokens haven't been fully updated yet

@jcfranco
Copy link
Member

@alisonailea Thanks for updating the PR title/description, btw!

@benelan benelan deleted the branch rc November 17, 2023 05:32
@benelan benelan closed this Nov 17, 2023
@jcfranco
Copy link
Member

jcfranco commented Nov 17, 2023

@alisonailea, we had to recreate rc and it unfortunately closed this PR. I think you can resubmit the PR by doing the following:

  1. Delete your GitHub branch or run git push origin :astump/7325-reduce-tokens-output
  2. Run git branch --unset-upstream on astump/7325-reduce-tokens-output
  3. Run git fetch origin
  4. Run git push origin astump/7325-reduce-tokens-output
  5. Use that new branch to create a new PR.

Sorry for the trouble! 🙇


Recreated PR: #8215

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Issues and pull requests with code changes that are not backwards compatible.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants