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 1 commit
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
Prev Previous commit
Next Next commit
Add strokeWidthThin fallback
  • Loading branch information
Mitch-At-Work committed Feb 28, 2025
commit 60355928f203bb86b771ede259f1c707958ca29d
4 changes: 3 additions & 1 deletion packages/semantic-tokens/scripts/tokenGen.ts
Original file line number Diff line number Diff line change
@@ -127,7 +127,9 @@ function generateTokenVariables() {

// Token fallback may be a fluent 2 token or new FST, let's check known fluent 2 tokens
if (tokenData.fallback.length > 0) {
if (tokenData.fallback.startsWith('Line-height')) {
if (tokenData.fallback === 'Thin') {
tokenFallback = `tokens.strokeWidthThin`;
} else if (tokenData.fallback.startsWith('Line-height')) {
const tokenFallbackArr = tokenData.fallback.split('/');
const tokenFallbackVal = tokenFallbackArr[tokenFallbackArr.length - 1];
tokenFallback = `tokens.lineHeightBase${tokenFallbackVal}`;
2 changes: 1 addition & 1 deletion packages/semantic-tokens/src/components/focus/tokens.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
import { tokens } from '@fluentui/tokens';

export const ctrlFocusPositionFigmaOnly = 'var(${ctrlFocusPositionFigmaOnlyRaw})';
export const ctrlFocusInnerStrokewidth = 'var(${ctrlFocusInnerStrokewidthRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const ctrlFocusInnerStrokewidth = 'var(${ctrlFocusInnerStrokewidthRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const ctrlFocusInnerStroke = 'var(${ctrlFocusInnerStrokeRaw}, ${neutralStrokeFocus1RestRaw})';
export const ctrlFocusOuterStrokewidth = 'var(${ctrlFocusOuterStrokewidthRaw}, ${thickRaw})';
export const ctrlFocusOuterStroke = 'var(${ctrlFocusOuterStrokeRaw}, var(${backgroundCtrlBrandRestRaw}, ${neutralStrokeFocus2RestRaw}))';
12 changes: 6 additions & 6 deletions packages/semantic-tokens/src/components/input/tokens.ts
Original file line number Diff line number Diff line change
@@ -8,14 +8,14 @@ export const ctrlInputBackgroundDisabled = 'var(${ctrlInputBackgroundDisabledRaw
export const ctrlInputBackgroundSelected = 'var(${ctrlInputBackgroundSelectedRaw}, var(${backgroundCtrlNeutralRestRaw}, ${neutralBackground1RestRaw}))';
export const ctrlInputBackgroundError = 'var(${ctrlInputBackgroundErrorRaw}, var(${backgroundCtrlNeutralRestRaw}, ${neutralBackground1RestRaw}))';
export const ctrlInputStrokeRest = 'var(${ctrlInputStrokeRestRaw}, var(${strokeCtrlOnoutlineRestRaw}, ${neutralStroke1RestRaw}))';
export const ctrlInputBottomlineStrokewidthRest = 'var(${ctrlInputBottomlineStrokewidthRestRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const ctrlInputStrokewidthRest = 'var(${ctrlInputStrokewidthRestRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const ctrlInputBottomlineStrokewidthRest = 'var(${ctrlInputBottomlineStrokewidthRestRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const ctrlInputStrokewidthRest = 'var(${ctrlInputStrokewidthRestRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const ctrlInputTextselectionBackground = 'var(${ctrlInputTextselectionBackgroundRaw}, var(${backgroundCtrlBrandRestRaw}, ${backgroundCtrlActivebrandRestRaw}))';
export const ctrlInputTextselectionForeground = 'var(${ctrlInputTextselectionForegroundRaw}, var(${foregroundCtrlOnbrandRestRaw}, ${neutralForeground4RestRaw}))';
export const ctrlInputStrokewidthHover = 'var(${ctrlInputStrokewidthHoverRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const ctrlInputStrokewidthPressed = 'var(${ctrlInputStrokewidthPressedRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const ctrlInputStrokewidthSelected = 'var(${ctrlInputStrokewidthSelectedRaw}, ${thinRaw})';
export const ctrlInputBottomlineStrokewidthHover = 'var(${ctrlInputBottomlineStrokewidthHoverRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const ctrlInputStrokewidthHover = 'var(${ctrlInputStrokewidthHoverRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const ctrlInputStrokewidthPressed = 'var(${ctrlInputStrokewidthPressedRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const ctrlInputStrokewidthSelected = 'var(${ctrlInputStrokewidthSelectedRaw}, ${tokens.strokeWidthThin})';
export const ctrlInputBottomlineStrokewidthHover = 'var(${ctrlInputBottomlineStrokewidthHoverRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const ctrlInputBottomlineStrokewidthPressed = 'var(${ctrlInputBottomlineStrokewidthPressedRaw}, var(${ctrlInputBottomlineStrokewidthSelectedRaw}, ${thickRaw}))';
export const ctrlInputBottomlineStrokewidthSelected = 'var(${ctrlInputBottomlineStrokewidthSelectedRaw}, ${thickRaw})';
export const ctrlInputBottomlineStrokeRest = 'var(${ctrlInputBottomlineStrokeRestRaw}, var(${foregroundCtrlNeutralSecondaryRestRaw}, ${neutralStrokeAccessibleRestRaw}))';
8 changes: 4 additions & 4 deletions packages/semantic-tokens/src/components/link/tokens.ts
Original file line number Diff line number Diff line change
@@ -2,17 +2,17 @@
import { tokens } from '@fluentui/tokens';

export const ctrlLinkForegroundNeutralRest = 'var(${ctrlLinkForegroundNeutralRestRaw}, ${foregroundCtrlNeutralPrimaryRestRaw})';
export const ctrlLinkInlineStrokewidthRest = 'var(${ctrlLinkInlineStrokewidthRestRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const ctrlLinkInlineStrokewidthHover = 'var(${ctrlLinkInlineStrokewidthHoverRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const ctrlLinkInlineStrokewidthRest = 'var(${ctrlLinkInlineStrokewidthRestRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const ctrlLinkInlineStrokewidthHover = 'var(${ctrlLinkInlineStrokewidthHoverRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const ctrlLinkInlineUnderlineDashed = 'var(${ctrlLinkInlineUnderlineDashedRaw})';
export const ctrlLinkInlineUnderlineSolidFigmaOnly = 'var(${ctrlLinkInlineUnderlineSolidFigmaOnlyRaw})';
export const ctrlLinkForegroundNeutralHover = 'var(${ctrlLinkForegroundNeutralHoverRaw}, var(${foregroundCtrlNeutralPrimaryRestRaw}, ${foregroundCtrlNeutralPrimaryHoverRaw}))';
export const ctrlLinkForegroundNeutralPressed = 'var(${ctrlLinkForegroundNeutralPressedRaw}, var(${foregroundCtrlNeutralPrimaryRestRaw}, ${foregroundCtrlNeutralPrimaryPressedRaw}))';
export const ctrlLinkForegroundBrandRest = 'var(${ctrlLinkForegroundBrandRestRaw}, ${foregroundCtrlBrandRestRaw})';
export const ctrlLinkForegroundBrandHover = 'var(${ctrlLinkForegroundBrandHoverRaw}, ${foregroundCtrlBrandHoverRaw})';
export const ctrlLinkForegroundBrandPressed = 'var(${ctrlLinkForegroundBrandPressedRaw}, ${foregroundCtrlBrandPressedRaw})';
export const ctrlLinkOnpageStrokewidthRest = 'var(${ctrlLinkOnpageStrokewidthRestRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const ctrlLinkOnpageStrokewidthHover = 'var(${ctrlLinkOnpageStrokewidthHoverRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const ctrlLinkOnpageStrokewidthRest = 'var(${ctrlLinkOnpageStrokewidthRestRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const ctrlLinkOnpageStrokewidthHover = 'var(${ctrlLinkOnpageStrokewidthHoverRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const ctrlLinkOnpageUnderlineDashed = 'var(${ctrlLinkOnpageUnderlineDashedRaw})';
export const ctrlLinkOnpageUnderlineSolidFigmaOnly = 'var(${ctrlLinkOnpageUnderlineSolidFigmaOnlyRaw})';
export const ctrlLinkShowunderlineatrest = 'var(${ctrlLinkShowunderlineatrestRaw})';
Original file line number Diff line number Diff line change
@@ -4,4 +4,4 @@ import { tokens } from '@fluentui/tokens';
export const ctrlLitefilterBackgroundSelected = 'var(${ctrlLitefilterBackgroundSelectedRaw}, ${backgroundCtrlBrandRestRaw})';
export const ctrlLitefilterStrokeSelected = 'var(${ctrlLitefilterStrokeSelectedRaw}, ${strokeCtrlOnbrandRestRaw})';
export const ctrlLitefilterForegroundSelected = 'var(${ctrlLitefilterForegroundSelectedRaw}, ${foregroundCtrlOnbrandRestRaw})';
export const ctrlLitefilterStrokewidthSelected = 'var(${ctrlLitefilterStrokewidthSelectedRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const ctrlLitefilterStrokewidthSelected = 'var(${ctrlLitefilterStrokewidthSelectedRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
4 changes: 2 additions & 2 deletions packages/semantic-tokens/src/components/split/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// eslint-disable-next-line no-restricted-imports
import { tokens } from '@fluentui/tokens';

export const ctrlSplitDividerStrokewidth = 'var(${ctrlSplitDividerStrokewidthRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const ctrlSplitDividerStrokewidthOnoutline = 'var(${ctrlSplitDividerStrokewidthOnoutlineRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const ctrlSplitDividerStrokewidth = 'var(${ctrlSplitDividerStrokewidthRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const ctrlSplitDividerStrokewidthOnoutline = 'var(${ctrlSplitDividerStrokewidthOnoutlineRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const ctrlSplitDividerStrokewidthOnsubtle = 'var(${ctrlSplitDividerStrokewidthOnsubtleRaw}, ${nullNumberRaw})';
2 changes: 1 addition & 1 deletion packages/semantic-tokens/src/control/tokens.ts
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ export const gapInsideCtrlLgTosecondaryicon = 'var(${gapInsideCtrlLgTosecondaryi
export const gapInsideCtrlTosecondaryicon = 'var(${gapInsideCtrlTosecondaryiconRaw})';
export const gapInsideCtrlTolabel = 'var(${gapInsideCtrlTolabelRaw})';
export const cornerCircular = 'var(${cornerCircularRaw}, ${circularRaw})';
export const strokewidthDefault = 'var(${strokewidthDefaultRaw}, ${thinRaw})';
export const strokewidthDefault = 'var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin})';
export const strokeCtrlOnoutlineRest = 'var(${strokeCtrlOnoutlineRestRaw}, ${neutralStroke1RestRaw})';
export const strokeCtrlOnoutlineHover = 'var(${strokeCtrlOnoutlineHoverRaw}, ${neutralStroke1HoverRaw})';
export const strokeCtrlOnoutlinePressed = 'var(${strokeCtrlOnoutlinePressedRaw}, ${neutralStroke1PressedRaw})';
12 changes: 6 additions & 6 deletions packages/semantic-tokens/src/optional/tokens.ts
Original file line number Diff line number Diff line change
@@ -98,12 +98,12 @@ export const gapBetweenCtrlLgNested = 'var(${gapBetweenCtrlLgNestedRaw}, ${paddi
export const gapBetweenCtrlSmNested = 'var(${gapBetweenCtrlSmNestedRaw}, ${paddingCtrlSmTonestedcontrolRaw})';
export const gapList = 'var(${gapListRaw}, ${gapBetweenContentXxsmallRaw})';
export const gapCard = 'var(${gapCardRaw}, ${gapBetweenContentMediumRaw})';
export const strokewidthDividerDefault = 'var(${strokewidthDividerDefaultRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const strokewidthDividerStrong = 'var(${strokewidthDividerStrongRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const strokewidthCtrlOutlineRest = 'var(${strokewidthCtrlOutlineRestRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const strokewidthCtrlOutlineHover = 'var(${strokewidthCtrlOutlineHoverRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const strokewidthCtrlOutlinePressed = 'var(${strokewidthCtrlOutlinePressedRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const strokewidthCtrlOutlineSelected = 'var(${strokewidthCtrlOutlineSelectedRaw}, var(${strokewidthDefaultRaw}, ${thinRaw}))';
export const strokewidthDividerDefault = 'var(${strokewidthDividerDefaultRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const strokewidthDividerStrong = 'var(${strokewidthDividerStrongRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const strokewidthCtrlOutlineRest = 'var(${strokewidthCtrlOutlineRestRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const strokewidthCtrlOutlineHover = 'var(${strokewidthCtrlOutlineHoverRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const strokewidthCtrlOutlinePressed = 'var(${strokewidthCtrlOutlinePressedRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const strokewidthCtrlOutlineSelected = 'var(${strokewidthCtrlOutlineSelectedRaw}, var(${strokewidthDefaultRaw}, ${tokens.strokeWidthThin}))';
export const strokewidthWindowDefault = 'var(${strokewidthWindowDefaultRaw}, ${strokewidthDefaultRaw})';
export const backgroundToolbar = 'var(${backgroundToolbarRaw}, var(${backgroundCardOnprimaryDefaultRestRaw}, ${neutralBackground1RestRaw}))';
export const strokeToolbar = 'var(${strokeToolbarRaw}, var(${strokeCardOnprimaryRestRaw}, ${neutralStrokeTransparentRestRaw}))';