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

Component Token Refactor #9358

Closed
2 tasks
Tracked by #9243
joshblack opened this issue Jul 28, 2021 · 0 comments · Fixed by #9663
Closed
2 tasks
Tracked by #9243

Component Token Refactor #9358

joshblack opened this issue Jul 28, 2021 · 0 comments · Fixed by #9663
Assignees

Comments

@joshblack
Copy link
Contributor

joshblack commented Jul 28, 2021

This issue tracks the work needed to refactor how we offer component tokens in v11. In v10, we offer minimal support for this in two ways:

  • Static Sass Variables that could be overridden,
  • Sass Variables whose value changed depending on the current theme (notification, tag)

The structure used for representing component tokens whose values changed based on the theme was:

$tokens: (
  token-name: (
    // Fallback used if no theme could be detected that matched
    fallback: value,
    values: (
      (
        theme: $theme-value,
        value: value,
      )
    ),
  ),
);

In v11, we would like to stabilize support for component tokens while keeping existing functionality. As a result, this work has the following requirements:

  • Configurable through @use 'mod' with ...;
  • Token values can be added as CSS Custom Properties to support inline theming / zoning / etc

Some examples of intended usage for the notification and button components:

// entrypoint
@use '@carbon/styles' with (
  notification-background-error: $custom-red,
  button-primary: $custom-color
);

// component entrypoint
@use '@carbon/styles/scss/components/notification' with (
  background-error: $custom-red,
);
@use '@carbon/styles/scss/components/button' with (
  primary: $custom-color,
);
@use '@carbon/styles/scss/themes';
@use '@carbon/styles/scss/theme';
@use '@carbon/styles/scss/components/notification';

// Theming
.light-mode {
  @include theme.theme();
}

.dark-mode {
  @include theme.theme(themes.$g100);
}

Explorations

@joshblack joshblack changed the title Update component tokens to be automatically registered in the theme Component Token Refactor Jul 28, 2021
@joshblack joshblack self-assigned this Jul 29, 2021
@joshblack joshblack mentioned this issue Aug 9, 2021
55 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant