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

Semantic-Tokens: Generate from token JSON export #33931

Draft
wants to merge 37 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7a48bb0
Stash initial for now
Mitch-At-Work Feb 11, 2025
13424bc
Add initial Link tokens as example
Mitch-At-Work Feb 12, 2025
5badbf8
Add tsconfig for semantic-tokens
Mitch-At-Work Feb 12, 2025
36cc985
Update indexing and add token vars as exports
Mitch-At-Work Feb 14, 2025
88cc6f4
Change files
Mitch-At-Work Feb 18, 2025
6b008bd
Fix version of react-tokens
Mitch-At-Work Feb 18, 2025
8dba624
Update and connect local build artifacts
Mitch-At-Work Feb 18, 2025
4a8db31
Lint and fix exports
Mitch-At-Work Feb 19, 2025
e2aa7f2
Update E2E for semantic tokens to a dummy test (for now)
Mitch-At-Work Feb 20, 2025
96ef49f
Fix up extra bracket and brand ref color
Mitch-At-Work Feb 20, 2025
1d6d672
remove console
Mitch-At-Work Feb 21, 2025
f478839
Alphebetize order
Mitch-At-Work Feb 24, 2025
bb81096
Update tokens so far
Mitch-At-Work Feb 28, 2025
940f605
Add script to generate
Mitch-At-Work Feb 28, 2025
44bfcdf
Initial script gen
Mitch-At-Work Feb 28, 2025
57c7867
Update tokens and script
Mitch-At-Work Feb 28, 2025
81f1e05
Update script to handle duplicated tokens
Mitch-At-Work Feb 28, 2025
6035592
Add strokeWidthThin fallback
Mitch-At-Work Feb 28, 2025
83f6a0a
Set variable path correctly
Mitch-At-Work Mar 1, 2025
e5671d7
Update latest
Mitch-At-Work Mar 3, 2025
0ed592f
Update with better fallback logic
Mitch-At-Work Mar 3, 2025
c81c862
Update script to handle fallbacks and f2 tokens better
Mitch-At-Work Mar 3, 2025
4d4bd3f
Update naming to handle brackets and spacings
Mitch-At-Work Mar 3, 2025
4609e99
Ensure fallbacks work correctly for FST
Mitch-At-Work Mar 3, 2025
9c3a7fe
Simplify script to match design and add custom fluent fallback map
Mitch-At-Work Mar 5, 2025
032d3b7
Add missing imports structure
Mitch-At-Work Mar 5, 2025
a750369
Fix imports
Mitch-At-Work Mar 5, 2025
a55568e
Update script to add exports
Mitch-At-Work Mar 5, 2025
5658e2d
Update script to handle imports/exports
Mitch-At-Work Mar 5, 2025
56e1102
Token script fixed
Mitch-At-Work Mar 5, 2025
e3a0bba
Update tokens and script
Mitch-At-Work Mar 6, 2025
58bac11
Fix token reference fallback
Mitch-At-Work Mar 6, 2025
791a838
Update api
Mitch-At-Work Mar 6, 2025
9c1c981
Fix port
Mitch-At-Work Mar 6, 2025
8884ea1
Lint all files
Mitch-At-Work Mar 6, 2025
a5bb059
Update and remove eslint rule
Mitch-At-Work Mar 6, 2025
c4719f4
Fix up the ESLint rule
Mitch-At-Work Mar 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -272,6 +272,7 @@ packages/react-components/react-virtualizer/stories @microsoft/xc-uxe @Mitch-At-
packages/react-components/react-skeleton/library @microsoft/cxe-prg
Copy link
Collaborator

@fabricteam fabricteam Feb 28, 2025

Choose a reason for hiding this comment

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

🕵🏾‍♀️ visual regressions to review in the fluentui-web-components-v3 Visual Regression Report

Accordion 1 screenshots
Image Name Diff(in Pixels) Image Type
Accordion. - Dark Mode.normal.chromium_1.png 2660 Changed
Badge 1 screenshots
Image Name Diff(in Pixels) Image Type
Badge. - Dark Mode.normal.chromium.png 511 Changed

Copy link
Collaborator

@fabricteam fabricteam Mar 3, 2025

Choose a reason for hiding this comment

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

🕵🏾‍♀️ visual regressions to review in the fluentuiv8 Visual Regression Report

Callout 1 screenshots
Image Name Diff(in Pixels) Image Type
Callout.No callout width specified.default.chromium.png 2319 Changed
react-charting-AreaChart 1 screenshots
Image Name Diff(in Pixels) Image Type
react-charting-AreaChart.Custom Accessibility.default.chromium.png 11 Changed
react-charting-LineChart 1 screenshots
Image Name Diff(in Pixels) Image Type
react-charting-LineChart.Gaps.default.chromium.png 1 Changed
react-charting-VerticalBarChart 1 screenshots
Image Name Diff(in Pixels) Image Type
react-charting-VerticalBarChart.Basic - Secondary Y Axis.default.chromium.png 4 Changed

packages/react-components/react-skeleton/stories @microsoft/cxe-prg
packages/tokens @microsoft/teams-prg
packages/semantic-tokens @microsoft/xc-uxe
packages/react-components/react-tags/library @microsoft/cxe-prg @microsoft/teams-prg
packages/react-components/react-tags/stories @microsoft/cxe-prg @microsoft/teams-prg
packages/react-components/react-migration-v0-v9/library @microsoft/teams-prg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat: Semantic token implementation",
"packageName": "@fluentui/react-link",
"email": "mifraser@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "feat: Initial semantic token package scaffolding",
"packageName": "@fluentui/semantic-tokens",
"email": "mifraser@microsoft.com",
"dependentChangeType": "patch"
}
1 change: 1 addition & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -151,6 +151,7 @@
"scripts/**/*",
"packages/eslint-plugin/**",
"packages/tokens/**",
"packages/semantic-tokens/**",
"packages/react-conformance/**",
"packages/react-components/**/*"
]
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
"@fluentui/react-shared-contexts": "^9.21.2",
"@fluentui/react-tabster": "^9.24.0",
"@fluentui/react-theme": "^9.1.24",
"@fluentui/semantic-tokens": "0.0.0-alpha.1",
"@fluentui/react-utilities": "^9.18.20",
"@griffel/react": "^1.5.22",
"@swc/helpers": "^0.5.1"
Original file line number Diff line number Diff line change
@@ -4,13 +4,28 @@ import { tokens } from '@fluentui/react-theme';
import type { LinkSlots, LinkState } from './Link.types';
import type { SlotClassNames } from '@fluentui/react-utilities';

import {
ctrlFocusOuterStroke,
ctrlLinkForegroundBrandHover,
ctrlLinkForegroundBrandPressed,
ctrlLinkForegroundNeutralRest,
ctrlLinkForegroundNeutralHover,
ctrlLinkForegroundNeutralPressed,
foregroundCtrlNeutralPrimaryDisabled,
textGlobalBody3Fontsize,
textStyleDefaultRegularFontfamily,
textStyleDefaultRegularWeight,
strokewidthDefault,
ctrlLinkForegroundBrandRest,
} from '@fluentui/semantic-tokens';

export const linkClassNames: SlotClassNames<LinkSlots> = {
root: 'fui-Link',
};

const useStyles = makeStyles({
focusIndicator: createCustomFocusIndicatorStyle({
textDecorationColor: tokens.colorStrokeFocus2,
textDecorationColor: ctrlFocusOuterStroke,
textDecorationLine: 'underline',
textDecorationStyle: 'double',
outlineStyle: 'none',
@@ -22,29 +37,29 @@ const useStyles = makeStyles({
},
backgroundColor: 'transparent',
boxSizing: 'border-box',
color: tokens.colorBrandForegroundLink,
color: ctrlLinkForegroundBrandRest,
cursor: 'pointer',
display: 'inline',
fontFamily: tokens.fontFamilyBase,
fontSize: tokens.fontSizeBase300,
fontWeight: tokens.fontWeightRegular,
fontFamily: textStyleDefaultRegularFontfamily,
fontSize: textGlobalBody3Fontsize,
fontWeight: textStyleDefaultRegularWeight,
margin: '0',
padding: '0',
overflow: 'inherit',
textAlign: 'left',
textDecorationLine: 'none',
textDecorationThickness: tokens.strokeWidthThin,
textDecorationThickness: strokewidthDefault,
textOverflow: 'inherit',
userSelect: 'text',

':hover': {
textDecorationLine: 'underline',
color: tokens.colorBrandForegroundLinkHover,
color: ctrlLinkForegroundBrandHover,
},

':active': {
textDecorationLine: 'underline',
color: tokens.colorBrandForegroundLinkPressed,
color: ctrlLinkForegroundBrandPressed,
},
},
// Overrides when the Link renders as a button.
@@ -57,16 +72,16 @@ const useStyles = makeStyles({
},
// Overrides when the Link appears subtle.
subtle: {
color: tokens.colorNeutralForeground2,
color: ctrlLinkForegroundNeutralRest,

':hover': {
textDecorationLine: 'underline',
color: tokens.colorNeutralForeground2Hover,
color: ctrlLinkForegroundNeutralHover,
},

':active': {
textDecorationLine: 'underline',
color: tokens.colorNeutralForeground2Pressed,
color: ctrlLinkForegroundNeutralPressed,
},
},
// Overrides when the Link is rendered inline within text.
@@ -76,20 +91,21 @@ const useStyles = makeStyles({
// Overrides when the Link is disabled.
disabled: {
textDecorationLine: 'none',
color: tokens.colorNeutralForegroundDisabled,
color: foregroundCtrlNeutralPrimaryDisabled,
cursor: 'not-allowed',

':hover': {
textDecorationLine: 'none',
color: tokens.colorNeutralForegroundDisabled,
color: foregroundCtrlNeutralPrimaryDisabled,
},

':active': {
textDecorationLine: 'none',
color: tokens.colorNeutralForegroundDisabled,
color: foregroundCtrlNeutralPrimaryDisabled,
},
},

// TODO: Add semantic tokens for inverted colors (not yet defined).
inverted: {
color: tokens.colorBrandForegroundInverted,
':hover': {
3 changes: 3 additions & 0 deletions packages/semantic-tokens/.babelrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["annotate-pure-calls", "@babel/transform-react-pure-annotations"]
}
12 changes: 12 additions & 0 deletions packages/semantic-tokens/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": ["plugin:@fluentui/eslint-plugin/react"],
"root": true,
"rules": {
"no-restricted-imports": [
"error",
{
"patterns": ["@fluentui/*", "react", "react-dom"]
}
]
}
}
32 changes: 32 additions & 0 deletions packages/semantic-tokens/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"exclude": [
"/testing",
"/**/*.cy.ts",
"/**/*.cy.tsx",
"/**/*.spec-e2e.ts",
"/**/*.spec.ts",
"/**/*.spec.tsx",
"/**/*.test.ts",
"/**/*.test.tsx"
],
"jsc": {
"baseUrl": ".",
"parser": {
"syntax": "typescript",
"tsx": true,
"decorators": false,
"dynamicImport": false
},
"externalHelpers": true,
"transform": {
"react": {
"runtime": "classic",
"useSpread": true
}
},
"target": "es2019"
},
"minify": false,
"sourceMaps": true
}
4 changes: 4 additions & 0 deletions packages/semantic-tokens/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "@fluentui/semantic-tokens",
"entries": []
}
5 changes: 5 additions & 0 deletions packages/semantic-tokens/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Change Log - @fluentui/semantic-tokens

This log was last generated on Thurs, 2 Feb 2025 16:26:46 GMT and should not be manually modified.

<!-- Start content -->
15 changes: 15 additions & 0 deletions packages/semantic-tokens/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@fluentui/semantic-tokens

Copyright (c) Microsoft Corporation

All rights reserved.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note: Usage of the fonts and icons referenced in Fluent UI React is subject to the terms listed at https://aka.ms/fluentui-assets-license
3 changes: 3 additions & 0 deletions packages/semantic-tokens/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @fluentui/semantic-tokens

**Fluent UI Theme semantic-tokens**
6 changes: 6 additions & 0 deletions packages/semantic-tokens/config/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "@fluentui/scripts-api-extractor/api-extractor.common.v-next.json",

"mainEntryPointFilePath": "<projectFolder>/../../dist/out-tsc/types/packages/<unscopedPackageName>/src/index.d.ts"
}
1 change: 1 addition & 0 deletions packages/semantic-tokens/config/tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/** Jest test setup file. */
Loading
Oops, something went wrong.