Skip to content

Commit efc6bf6

Browse files
feat(Tokens): restrict new tokens behind feature flag (#8350)
* feat(Tokens): restrict new tokens behind feature flag * chore(Tokens): properly format remaining tokens * fix(FeatureFlag): enable custom properties by default * chore(docs): add scenarios to storybook styles for testing * fix(FeatureFlag): fix if statement so tests pass * chore(example): remove example code Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 618df33 commit efc6bf6

File tree

3 files changed

+115
-0
lines changed

3 files changed

+115
-0
lines changed

packages/components/src/globals/scss/_feature-flags.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ $default-feature-flags: (
3838

3939
$feature-flags: map-merge($default-feature-flags, $feature-flags);
4040

41+
@if feature-flag-enabled('enable-2021-release') == true {
42+
@if variable-exists(css--disable-css-custom-properties) ==
43+
false or
44+
$css--disable-css-custom-properties ==
45+
false
46+
{
47+
$feature-flags: map-merge(
48+
$feature-flags,
49+
(
50+
enable-css-custom-properties: true,
51+
)
52+
);
53+
}
54+
}
55+
4156
@if map-get($feature-flags, grid) != true {
4257
// We supported a flag for experimental grid in the past that we want to keep
4358
// supporting till our next major release. These two @if statements will assign

packages/components/src/globals/scss/_theme-tokens.scss

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,99 @@
1515
// to make sure that they're in sync if one has diverged from the other.
1616
@include carbon--theme();
1717

18+
@if not feature-flag-enabled('enable-2021-release') {
19+
$background: $ui-background;
20+
$layer: $ui-01;
21+
$layer-alt: $ui-03;
22+
$field: $field-01;
23+
$background-inverse: $inverse-02;
24+
$background-brand: $interactive-01;
25+
$interactive: $interactive-04;
26+
27+
$border-subtle: $ui-03;
28+
$border-strong: $ui-04;
29+
$border-inverse: $ui-05;
30+
$border-interactive: $interactive-04;
31+
32+
$text-primary: $text-01;
33+
$text-secondary: $text-02;
34+
$text-placeholder: $text-03;
35+
$text-helper: $text-05;
36+
$text-on-color: $text-04;
37+
$text-inverse: $inverse-01;
38+
39+
$link-primary: $link-01;
40+
$link-secondary: $link-02;
41+
$link-visited: $visited-link;
42+
$link-inverse: $inverse-link;
43+
44+
$icon-primary: $icon-01;
45+
$icon-secondary: $icon-02;
46+
$icon-on-color: $icon-03;
47+
$icon-inverse: $inverse-01;
48+
49+
$support-error: $support-01;
50+
$support-success: $support-02;
51+
$support-warning: $support-03;
52+
$support-info: $support-04;
53+
$support-error-inverse: $inverse-support-01;
54+
$support-success-inverse: $inverse-support-02;
55+
$support-warning-inverse: $inverse-support-03;
56+
$support-info-inverse: $inverse-support-04;
57+
58+
$overlay: $overlay-01;
59+
$toggle-off: $ui-04;
60+
61+
$button-primary: $interactive-01;
62+
$button-secondary: $interactive-02;
63+
$button-tertiary: $interactive-03;
64+
$button-danger-primary: $danger-01;
65+
$button-danger-secondary: $danger-02;
66+
67+
$background-active: $active-ui;
68+
$layer-active: $active-ui;
69+
70+
$button-danger-active: $active-danger;
71+
$button-primary-active: $active-primary;
72+
$button-secondary-active: $active-secondary;
73+
$button-tertiary-active: $active-tertiary;
74+
75+
$focus-inset: $inverse-01;
76+
$focuse-inverse: $inverse-focus-ui;
77+
78+
$background-hover: $hover-ui;
79+
$layer-hover: $hover-ui;
80+
$field-hover: $hover-ui;
81+
$background-inverse-hover: $inverse-hover-ui;
82+
$link-primary-hover: $hover-primary-text;
83+
$button-danger-hover: $hover-danger;
84+
$button-primary-hover: $hover-primary;
85+
$button-secondary-hover: $hover-secondary;
86+
$button-tertiary-hover: $hover-tertiary;
87+
88+
$background-selected: $selected-ui;
89+
$background-selected-hover: $hover-selected-ui;
90+
$layer-selected: $selected-ui;
91+
$layer-selected-hover: $hover-selected-ui;
92+
$layer-selected-inverse: $ui-05;
93+
$border-subtle-selected: $active-ui;
94+
95+
$layer-disabled: $disabled-01;
96+
$field-disabled: $disabled-01;
97+
$border-disabled: $disabled-01;
98+
99+
$text-disabled: $disabled-02;
100+
$button-disabled: $disabled-02;
101+
$icon-disabled: $disabled-02;
102+
103+
$text-on-color-disabled: $disabled-03;
104+
$icon-on-color-disabled: $disabled-03;
105+
$layer-selected-disabled: $disabled-03;
106+
107+
$skeleton-background: $skeleton-01;
108+
$skeleton-element: $skeleton-02;
109+
}
110+
18111
/// Theme variables
19112

20113
/// @type Value

packages/components/src/globals/scss/styles.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ $css--use-experimental-grid: false !default;
6161
/// @deprecated (For v10) v10 always uses `@carbon/grid`
6262
$css--use-experimental-grid-fallback: false !default;
6363

64+
/// If `enable-2021-release` is set to `true`, it automatically enables the custom properties flag.
65+
/// If so, we need a way to disable custom properties, but use the new tokens.
66+
/// @access public
67+
/// @type Bool
68+
/// @group feature-flags
69+
$css--disable-css-custom-properties: false !default;
70+
6471
@import 'feature-flags';
6572
@import 'vars';
6673
@import 'colors';

0 commit comments

Comments
 (0)