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

Draft (Prototype): Control Tokens test (component design tokens) #31330

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

EdDaWord
Copy link
Contributor

@EdDaWord EdDaWord commented May 9, 2024

Add Control Tokens with Alias & Global Fallbacks

The main idea is to complete the Design Tokens spec by introducing the Control Tokens

image

Doing this through the use of var(--semanticToken, ${tokens.aliasToken} so that if the semanticTokens (control tokens) are not provided then we have Alias/Global fallbacks.

If they are provided, then it's starts becoming a pay-to-play system. Meaning the more semantic token one uses the more CSS Vars get introduced. They can be introduced at the root level or for better DOM Reflow they ought to be introduced at the lowest parent node. I.E for an app within another app 👀. Therefore it is our hypothesis that it would not affect DOM Reflow as much as having loads of Global/Alias tokens.

Prototypes & Staging links of concern:

Screen Recording 2024-05-09 at 2 23 13 PM
https://fluentuipr.z22.web.core.windows.net/pull/31330/public-docsite-v9/storybook/index.html?path=/docs/components-button-button--default#appearance

Screen Recording 2024-05-09 at 2 23 52 PM
https://fluentuipr.z22.web.core.windows.net/pull/31330/public-docsite-v9/storybook/index.html?path=/docs/components-button-togglebutton--default#appearance

switch
https://fluentuipr.z22.web.core.windows.net/pull/31330/public-docsite-v9/storybook/index.html?path=/docs/components-switch--default#checked

Screen Recording 2024-05-09 at 2 14 41 PM
https://fluentuipr.z22.web.core.windows.net/pull/31330/public-docsite-v9/storybook/index.html?path=/docs/components-combobox--default#appearance

Address concerns:

Here's a list of questions based on the notes:
Here is the cleaned-up list of questions and answers with duplicates merged:

  1. How can we ensure that:

    • Existing themes built with current tokens continue to work?
      • Through var(semantic_token, alias_token) fallbacks
    • Theme generation continues to work?
      • Working closely with folks on the Theme Designer team (Mason, Ankit, Prasanna)
      • Incorporating it into the tokens pipeline
      • Aligning with Figma (Spencer, Ethan, Jeremy)
    • Default theme needs continue to work?
      • Everything will fall back to Alias and Globals
    • UI built with FST works without it being explicitly provided?
      • Fallbacks ensure this
  2. What should the prototypes demonstrate to show how FST should work?

    • Build themes like Win11, NXT, and others
  3. How can we handle customized tokens added to teams without causing accessibility issues?

    • Unit tests should warn against mistakes
  4. How do we handle "theme creep" to ensure theme shape remains consistent?

    • Release in waves and only release semantic tokens that serve a purpose
    • Start with groups of semantic tokens like ButtonGroupForegroundColor
  5. How can we ensure that all UI continues to work in the base theme?

    • Semantic tokens fall back to Alias and Globals by default
  6. How does adding FST (Fluent Semantic Tokens) impact existing customers from a theming performance standpoint?

    • Should not impact performance since var fallbacks mean no extra CSS vars are added
  7. What could go wrong with FST implementation, and how can users potentially misuse it?

    • If users make extensive use of all the semantic tokens, CSS Var usage will increase significantly ("pay to play")
  8. How should we communicate to the Fluent Core team about extending the original tokens spec?

    • Introduce the "Control Token" step
  9. Did the team consider using var() as a fallback option previously?

    • Instances of var fallback exist throughout the code, but not clear if it was considered for creating semantic/control/component design tokens
    • Check with Miro
  10. How do we keep token creep under control?

  • Base Fluent 2 tokens on current tokens
  1. How can Fluent 2 tokens be based on the current tokens?
  • Default values will still be Alias/Global tokens
  1. How should we govern the process of exposing more and more granular tokens to components, especially regarding var() fallbacks?
  • Should be based on real product demand; add only with a genuine use case for multiple Fluent consumers
  1. Should component groups solve this at the expense of fidelity?
  • Perhaps start with Colors for Semantic Groups first
  1. Should product teams contribute controls that use component-level tokens?
  • Convert Alias and Global usages within component variants to semantic tokens per naming convention
  1. How do we ensure that all components have alias token fallbacks if component tokens are not always present?
  • Package the semantic tokens with components, ensuring each has the necessary group semantic tokens
  1. How do we handle increased bundle size due to additional verbose strings caused by bundling?
  • Perhaps hash like the Alias and Globals
  • ❓ Not sure, needs further exploration

@EdDaWord EdDaWord added the Draft label May 9, 2024
@EdDaWord EdDaWord requested review from a team, behowell, khmakoto and smhigley as code owners May 9, 2024 20:48
@spmonahan
Copy link
Contributor

spmonahan commented May 9, 2024

msedge_Ihw0ZWzpCI

You can convert this to a draft PR to signal to folks that it's not ready for review yet 🙂

@fabricteam
Copy link
Collaborator

fabricteam commented May 9, 2024

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-alert
Alert
83.737 kB
23.475 kB
86.956 kB
23.977 kB
3.219 kB
502 B
react-breadcrumb
@fluentui/react-breadcrumb - package
117.263 kB
32.241 kB
120.482 kB
32.715 kB
3.219 kB
474 B
react-button
Button
39.513 kB
11.17 kB
42.732 kB
11.583 kB
3.219 kB
413 B
react-button
CompoundButton
46.874 kB
12.662 kB
50.093 kB
13.073 kB
3.219 kB
411 B
react-button
MenuButton
44.292 kB
12.544 kB
47.511 kB
12.952 kB
3.219 kB
408 B
react-button
SplitButton
52.306 kB
14.135 kB
55.525 kB
14.586 kB
3.219 kB
451 B
react-button
ToggleButton
56.558 kB
13.068 kB
63.99 kB
13.836 kB
7.432 kB
768 B
react-combobox
Combobox (including child components)
105.628 kB
33.907 kB
107.931 kB
34.407 kB
2.303 kB
500 B
react-components
react-components: Button, FluentProvider & webLightTheme
71.55 kB
20.584 kB
74.769 kB
21.038 kB
3.219 kB
454 B
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
221.825 kB
62.568 kB
225.044 kB
63.176 kB
3.219 kB
608 B
react-components
react-components: entire library
1.139 MB
275.369 kB
1.151 MB
277.435 kB
11.949 kB
2.066 kB
react-switch
Switch
36.04 kB
11.305 kB
38.254 kB
11.456 kB
2.214 kB
151 B
react-timepicker-compat
TimePicker
107.646 kB
35.281 kB
109.949 kB
35.698 kB
2.303 kB
417 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-card
Card - All
104.438 kB
29.41 kB
react-card
Card
97.449 kB
27.681 kB
react-card
CardFooter
13.971 kB
5.626 kB
react-card
CardHeader
16.214 kB
6.386 kB
react-card
CardPreview
14.015 kB
5.752 kB
react-combobox
Dropdown (including child components)
107.043 kB
33.877 kB
react-components
react-components: FluentProvider & webLightTheme
44.037 kB
14.418 kB
react-dialog
Dialog (including children components)
100.769 kB
30.092 kB
react-message-bar
MessageBar (all components)
24.204 kB
8.983 kB
react-portal-compat
PortalCompatProvider
8.39 kB
2.64 kB
react-tag-picker
@fluentui/react-tag-picker - package
188.833 kB
55.784 kB
🤖 This report was generated against e75ee57872357641affbf1a4540c02aa1178665a

@fabricteam
Copy link
Collaborator

fabricteam commented May 9, 2024

Perf Analysis (@fluentui/react-components)

Scenario Render type Master Ticks PR Ticks Iterations Status
FluentProviderWithTheme virtual-rerender-with-unmount 77 73 10 Possible regression
All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 653 604 5000
Button mount 312 316 5000
Field mount 1143 1133 5000
FluentProvider mount 689 708 5000
FluentProviderWithTheme mount 75 78 10
FluentProviderWithTheme virtual-rerender 37 35 10
FluentProviderWithTheme virtual-rerender-with-unmount 77 73 10 Possible regression
MakeStyles mount 850 868 50000
Persona mount 1770 1707 5000
SpinButton mount 1377 1373 5000
SwatchPicker mount 1508 1524 5000

@@ -0,0 +1,109 @@
import { tokens } from '@fluentui/react-theme';
Copy link
Collaborator

@fabricteam fabricteam May 9, 2024

Choose a reason for hiding this comment

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

🕵 fluentuiv9 Open the Visual Regressions report to inspect the affected screenshots

Combobox Converged 3 screenshots
Image Name Diff(in Pixels) Image Type
Combobox Converged.With placeholder.default.chromium.png 16 Changed
Combobox Converged.With placeholder.focused.chromium.png 16 Changed
Combobox Converged.With placeholder.hover.chromium.png 16 Changed
Dialog 1 screenshots
Image Name Diff(in Pixels) Image Type
Dialog.Integration Combobox Inline.chromium.png 52 Changed
Field 1 screenshots
Image Name Diff(in Pixels) Image Type
Field.Combobox+horizontal.default.chromium.png 109 Changed
ToggleButton Converged 6 screenshots
Image Name Diff(in Pixels) Image Type
ToggleButton Converged.Checked.pressed.chromium.png 238 Changed
ToggleButton Converged.Transparent Checked.default.chromium.png 67 Changed
ToggleButton Converged.Subtle Checked.pressed.chromium.png 238 Changed
ToggleButton Converged.Subtle Checked.hover.chromium.png 265 Changed
ToggleButton Converged.Transparent Checked.pressed.chromium.png 223 Changed
ToggleButton Converged.Transparent Checked.hover.chromium.png 210 Changed

brandonthomas and others added 2 commits May 9, 2024 14:33
add all button appearnce variants

Fix mistake on transparent variant color

Remove testing

Fix error

Add Selected Button Semantic Tokens

Forgot to add the files

Add Switch Indicator semantic tokens

Add Semantic tokens for Switch Border Color

Add Switch BorderColor semantic tokens

Add combobox semantic tokens

Finish semantic tokens for Combobox Colors
@EdDaWord EdDaWord marked this pull request as draft May 9, 2024 21:37
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@@ -0,0 +1,109 @@
import { tokens } from '@fluentui/react-theme';
Copy link
Collaborator

Choose a reason for hiding this comment

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

🕵 fluentui-web-components-v3 Open the Visual Regressions report to inspect the affected screenshots

Accordion 3 screenshots
Image Name Diff(in Pixels) Image Type
Accordion.Size - RTL.normal.chromium.png 2 Changed
Accordion.Size - Dark Mode.normal.chromium.png 2 Changed
Accordion.Size.normal.chromium.png 2 Changed
Avatar 5 screenshots
Image Name Diff(in Pixels) Image Type
Avatar.Active.normal.chromium.png 5 Changed
Avatar.Active Appearance - Dark Mode.normal.chromium.png 2 Changed
Avatar.Active Appearance.normal.chromium.png 10 Changed
Avatar.Color - RTL.normal.chromium.png 1 Changed
Avatar.Color.normal.chromium.png 1 Changed
Badge 6 screenshots
Image Name Diff(in Pixels) Image Type
Badge.Appearance.normal.chromium.png 1 Changed
Badge.Appearance - Dark Mode.normal.chromium.png 15 Changed
Badge.Default.normal.chromium.png 1 Changed
Badge.Size.normal.chromium.png 6 Changed
Badge.Shape.normal.chromium.png 1 Changed
Badge.Color.normal.chromium.png 1 Changed
Button 15 screenshots
Image Name Diff(in Pixels) Image Type
Button.Large Icon Only - Dark Mode.pressed.chromium.png 5 Changed
Button.Large Icon Only - Dark Mode.hover.chromium.png 3 Changed
Button.Large Icon Only - Dark Mode.default.chromium.png 4 Changed
Button.Large With Icon - Dark Mode.pressed.chromium.png 5 Changed
Button.Large Icon Only.pressed.chromium.png 3 Changed
Button.Large With Icon - Dark Mode.default.chromium.png 4 Changed
Button.Large Icon Only.hover.chromium.png 4 Changed
Button.Large With Icon.default.chromium.png 5 Changed
Button.Large With Icon - RTL.pressed.chromium.png 3 Changed
Button.Large With Icon - RTL.default.chromium.png 5 Changed
Button.Large With Icon - Dark Mode.hover.chromium.png 3 Changed
Button.Large Icon Only.default.chromium.png 5 Changed
Button.Large With Icon.hover.chromium.png 4 Changed
Button.Large With Icon.pressed.chromium.png 3 Changed
Button.Large With Icon - RTL.hover.chromium.png 4 Changed
Divider 3 screenshots
Image Name Diff(in Pixels) Image Type
Divider.With Svg - RTL.normal.chromium.png 3 Changed
Divider.With Svg.normal.chromium.png 3 Changed
Divider.Vertical With Svg.normal.chromium.png 4 Changed
MenuList 16 screenshots
Image Name Diff(in Pixels) Image Type
MenuList.Checkbox With Icons.normal.chromium.png 4 Changed
MenuList.Checkbox - RTL.2nd selected.chromium.png 1 Changed
MenuList.Checkbox With Icons.2nd selected.chromium.png 5 Changed
MenuList.Checkbox With Icons - RTL.normal.chromium.png 4 Changed
MenuList.Radio With Icons - RTL.1st selected.chromium.png 4 Changed
MenuList.Radio With Icons - RTL.2nd selected.chromium.png 4 Changed
MenuList.Radio With Icons.normal.chromium.png 4 Changed
MenuList.With Icons.normal.chromium.png 4 Changed
MenuList.Radio With Icons.2nd selected.chromium.png 4 Changed
MenuList.Checkbox With Icons - RTL.2nd selected.chromium.png 5 Changed
MenuList.Checkbox With Icons - RTL.1st selected.chromium.png 4 Changed
MenuList.With Icons.hover menuitem.chromium.png 3 Changed
MenuList.Checkbox With Icons.1st selected.chromium.png 4 Changed
MenuList.Radio With Icons - RTL.normal.chromium.png 4 Changed
MenuList.Radio With Icons.1st selected.chromium.png 4 Changed
MenuList.Checkbox.2nd selected.chromium.png 1 Changed
Slider 2 screenshots
Image Name Diff(in Pixels) Image Type
Slider.Size Small.normal.chromium.png 1 Changed
Slider.Size Small.rightArrow.chromium.png 1 Changed
Switch 2 screenshots
Image Name Diff(in Pixels) Image Type
Switch.Checked - RTL.hover.chromium.png 1 Changed
Switch.Checked.hover.chromium.png 1 Changed
Text 1 screenshots
Image Name Diff(in Pixels) Image Type
Text.Block.normal.chromium.png 995 Changed
TextInput 1 screenshots
Image Name Diff(in Pixels) Image Type
TextInput.Size Large.normal.chromium.png 2 Changed

@EdDaWord EdDaWord changed the title Draft (Prototype): Semantic Tokens test (component design tokens) Draft (Prototype): Control Tokens test (component design tokens) May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants