-
Notifications
You must be signed in to change notification settings - Fork 2.9k
add toolbar to semantic style hooks #34840
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
Merged
Mitch-At-Work
merged 2 commits into
microsoft:extended-tokens
from
rachethecreator:ryoo/toolbar-semantic-tokens
Jul 17, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...act-components/semantic-style-hooks-preview/library/src/component-styles/Toolbar/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| export { useSemanticToolbarStyles } from './useSemanticToolbarStyles.styles'; | ||
| export { useSemanticToolbarButtonStyles } from './useSemanticToolbarButtonStyles.styles'; | ||
| export { useSemanticToolbarDividerStyles } from './useSemanticToolbarDividerStyles.styles'; | ||
| export { useSemanticToolbarGroupStyles } from './useSemanticToolbarGroupStyles.styles'; | ||
| export { useSemanticToolbarRadioButtonStyles } from './useSemanticToolbarRadioButtonStyles.styles'; | ||
| export { useSemanticToolbarToggleButtonStyles } from './useSemanticToolbarToggleButtonStyles.styles'; |
40 changes: 40 additions & 0 deletions
40
...oks-preview/library/src/component-styles/Toolbar/useSemanticToolbarButtonStyles.styles.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { makeStyles, mergeClasses } from '@griffel/react'; | ||
| import { useSemanticButtonStyles } from '../Button/useSemanticButtonStyles.styles'; | ||
| import { type ToolbarButtonState } from '@fluentui/react-toolbar'; | ||
| import { getSlotClassNameProp_unstable } from '@fluentui/react-utilities'; | ||
| import * as semanticTokens from '@fluentui/semantic-tokens'; | ||
|
|
||
| const useBaseStyles = makeStyles({ | ||
| vertical: { | ||
| flexDirection: 'column', | ||
| }, | ||
| verticalIcon: { | ||
| fontSize: semanticTokens.sizeCtrlLgIcon, | ||
| margin: '0', | ||
| }, | ||
| }); | ||
|
|
||
| /** | ||
| * Apply styling to the ToolbarButton slots based on the state | ||
| */ | ||
| export const useSemanticToolbarButtonStyles = (_state: unknown) => { | ||
| 'use no memo'; | ||
|
|
||
| const state = _state as ToolbarButtonState; | ||
|
|
||
| useSemanticButtonStyles(state); | ||
| const buttonStyles = useBaseStyles(); | ||
|
|
||
| state.root.className = mergeClasses( | ||
| state.root.className, | ||
| state.vertical && buttonStyles.vertical, | ||
| getSlotClassNameProp_unstable(state.root), | ||
| ); | ||
| if (state.icon) { | ||
| state.icon.className = mergeClasses( | ||
| state.icon.className, | ||
| state.vertical && buttonStyles.verticalIcon, | ||
| getSlotClassNameProp_unstable(state.icon), | ||
| ); | ||
| } | ||
| }; |
37 changes: 37 additions & 0 deletions
37
...ks-preview/library/src/component-styles/Toolbar/useSemanticToolbarDividerStyles.styles.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { makeStyles, mergeClasses } from '@griffel/react'; | ||
| import { useSemanticDividerStyles } from '../Divider/useSemanticDividerStyles.styles'; | ||
| import { type ToolbarDividerState } from '@fluentui/react-toolbar'; | ||
| import { getSlotClassNameProp_unstable } from '@fluentui/react-utilities'; | ||
| import * as semanticTokens from '@fluentui/semantic-tokens'; | ||
|
|
||
| const useBaseStyles = makeStyles({ | ||
| // Base styles | ||
| root: { | ||
| display: 'inline-flex', | ||
| maxWidth: semanticTokens.strokeWidthDefault, | ||
| padding: `${semanticTokens.paddingContentNone} ${semanticTokens.paddingCtrlHorizontalDefault}`, | ||
| }, | ||
| vertical: { | ||
| maxWidth: 'initial', | ||
| }, | ||
| }); | ||
|
|
||
| /** | ||
| * Apply styling to the ToolbarDivider slots based on the state | ||
| */ | ||
| export const useSemanticToolbarDividerStyles = (_state: unknown): ToolbarDividerState => { | ||
| 'use no memo'; | ||
|
|
||
| const state = _state as ToolbarDividerState; | ||
|
|
||
| useSemanticDividerStyles(state); | ||
| const { vertical } = state; | ||
| const toolbarDividerStyles = useBaseStyles(); | ||
| state.root.className = mergeClasses( | ||
| state.root.className, | ||
| toolbarDividerStyles.root, | ||
| !vertical && toolbarDividerStyles.vertical, | ||
| getSlotClassNameProp_unstable(state.root), | ||
| ); | ||
| return state; | ||
| }; |
20 changes: 20 additions & 0 deletions
20
...ooks-preview/library/src/component-styles/Toolbar/useSemanticToolbarGroupStyles.styles.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { getSlotClassNameProp_unstable } from '@fluentui/react-utilities'; | ||
| import { mergeClasses } from '@griffel/react'; | ||
| import { toolbarGroupClassNames, type ToolbarGroupState } from '@fluentui/react-toolbar'; | ||
|
|
||
| /** | ||
| * Apply styling to the Toolbar slots based on the state | ||
| */ | ||
| export const useSemanticToolbarGroupStyles = (_state: unknown): ToolbarGroupState => { | ||
| 'use no memo'; | ||
|
|
||
| const state = _state as ToolbarGroupState; | ||
|
|
||
| state.root.className = mergeClasses( | ||
| state.root.className, | ||
| toolbarGroupClassNames.root, | ||
| getSlotClassNameProp_unstable(state.root), | ||
| ); | ||
|
|
||
| return state; | ||
| }; |
45 changes: 45 additions & 0 deletions
45
...review/library/src/component-styles/Toolbar/useSemanticToolbarRadioButtonStyles.styles.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { tokens } from '@fluentui/react-theme'; | ||
| import { makeStyles, mergeClasses } from '@griffel/react'; | ||
| import { useSemanticToggleButtonStyles } from '../Button/useSemanticToggleButtonStyles.styles'; | ||
| import { type ToolbarRadioButtonState } from '@fluentui/react-toolbar'; | ||
| import { getSlotClassNameProp_unstable } from '@fluentui/react-utilities'; | ||
|
|
||
| const useBaseStyles = makeStyles({ | ||
| /* use subtle ToggleButton selected styles for Toolbar Radio selected state */ | ||
| selected: { | ||
| backgroundColor: tokens.colorSubtleBackgroundSelected, | ||
| color: tokens.colorNeutralForeground2Selected, | ||
| }, | ||
|
|
||
| iconSelected: { | ||
| color: tokens.colorNeutralForeground2BrandSelected, | ||
| }, | ||
| }); | ||
|
|
||
| /** | ||
| * Apply styling to the ToolbarRadioButton slots based on the state | ||
| */ | ||
| export const useSemanticToolbarRadioButtonStyles = (_state: unknown): ToolbarRadioButtonState => { | ||
| 'use no memo'; | ||
|
|
||
| const state = _state as ToolbarRadioButtonState; | ||
|
|
||
| useSemanticToggleButtonStyles(state); | ||
| const toggleButtonStyles = useBaseStyles(); | ||
|
|
||
| state.root.className = mergeClasses( | ||
| state.root.className, | ||
| state.checked && toggleButtonStyles.selected, | ||
| getSlotClassNameProp_unstable(state.root), | ||
| ); | ||
|
|
||
| if (state.icon) { | ||
| state.icon.className = mergeClasses( | ||
| state.icon.className, | ||
| state.checked && toggleButtonStyles.iconSelected, | ||
| getSlotClassNameProp_unstable(state.icon), | ||
| ); | ||
| } | ||
|
|
||
| return state; | ||
| }; | ||
46 changes: 46 additions & 0 deletions
46
...yle-hooks-preview/library/src/component-styles/Toolbar/useSemanticToolbarStyles.styles.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { getSlotClassNameProp_unstable } from '@fluentui/react-utilities'; | ||
| import { makeStyles, mergeClasses } from '@griffel/react'; | ||
| import { toolbarClassNames, type ToolbarState } from '@fluentui/react-toolbar'; | ||
| import * as semanticTokens from '@fluentui/semantic-tokens'; | ||
|
|
||
| /** | ||
| * Styles for the root slot | ||
| */ | ||
| const useStyles = makeStyles({ | ||
| root: { | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| padding: `4px ${semanticTokens.ctrlChoicePaddingHorizontal}`, | ||
| }, | ||
| vertical: { | ||
| flexDirection: 'column', | ||
| width: 'fit-content', | ||
| }, | ||
| small: { padding: '0px 4px' }, | ||
| medium: { padding: `4px ${semanticTokens.ctrlChoicePaddingHorizontal}` }, | ||
| large: { padding: '4px 20px' }, | ||
| }); | ||
|
|
||
| /** | ||
| * Apply styling to the Toolbar slots based on the state | ||
| */ | ||
| export const useSemanticToolbarStyles = (_state: unknown): ToolbarState => { | ||
| 'use no memo'; | ||
|
|
||
| const state = _state as ToolbarState; | ||
|
|
||
| const styles = useStyles(); | ||
| const { vertical, size } = state; | ||
| state.root.className = mergeClasses( | ||
| state.root.className, | ||
| toolbarClassNames.root, | ||
| styles.root, | ||
| vertical && styles.vertical, | ||
| size === 'small' && !vertical && styles.small, | ||
| size === 'medium' && !vertical && styles.medium, | ||
| size === 'large' && !vertical && styles.large, | ||
| getSlotClassNameProp_unstable(state.root), | ||
| ); | ||
|
|
||
| return state; | ||
| }; |
45 changes: 45 additions & 0 deletions
45
...eview/library/src/component-styles/Toolbar/useSemanticToolbarToggleButtonStyles.styles.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { tokens } from '@fluentui/react-theme'; | ||
| import { makeStyles, mergeClasses } from '@griffel/react'; | ||
| import { useSemanticToggleButtonStyles } from '../Button/useSemanticToggleButtonStyles.styles'; | ||
| import { type ToolbarToggleButtonState } from '@fluentui/react-toolbar'; | ||
| import { getSlotClassNameProp_unstable } from '@fluentui/react-utilities'; | ||
|
|
||
| const useBaseStyles = makeStyles({ | ||
| /* use subtle ToggleButton selected styles for Toolbar Radio selected state */ | ||
| selected: { | ||
| backgroundColor: tokens.colorSubtleBackgroundSelected, | ||
|
mltejera marked this conversation as resolved.
|
||
| color: tokens.colorNeutralForeground2Selected, | ||
| }, | ||
|
|
||
| iconSelected: { | ||
| color: tokens.colorNeutralForeground2BrandSelected, | ||
| }, | ||
| }); | ||
|
|
||
| /** | ||
| * Apply styling to the ToolbarToggleButton slots based on the state | ||
| */ | ||
| export const useSemanticToolbarToggleButtonStyles = (_state: unknown): ToolbarToggleButtonState => { | ||
| 'use no memo'; | ||
|
|
||
| const state = _state as ToolbarToggleButtonState; | ||
|
|
||
| useSemanticToggleButtonStyles(state); | ||
| const toggleButtonStyles = useBaseStyles(); | ||
|
|
||
| state.root.className = mergeClasses( | ||
| state.root.className, | ||
| state.checked && toggleButtonStyles.selected, | ||
| getSlotClassNameProp_unstable(state.root), | ||
| ); | ||
|
|
||
| if (state.icon) { | ||
| state.icon.className = mergeClasses( | ||
| state.icon.className, | ||
| state.checked && toggleButtonStyles.iconSelected, | ||
| getSlotClassNameProp_unstable(state.icon), | ||
| ); | ||
| } | ||
|
|
||
| return state; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.