Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { FieldState } from '@fluentui/react-field';
import { FlatTreeState } from '@fluentui/react-tree';
import { FluentProviderCustomStyleHooks } from '@fluentui/react-provider';
import { ImageState } from '@fluentui/react-image';
import { InfoButtonState } from '@fluentui/react-infolabel';
import { InfoLabelState } from '@fluentui/react-infolabel';
import { InlineDrawerState } from '@fluentui/react-drawer';
import { InputState } from '@fluentui/react-input';
import { LabelState } from '@fluentui/react-label';
Expand Down Expand Up @@ -137,6 +139,12 @@ export const useSemanticFlatTreeStyles: (_state: unknown) => FlatTreeState;
// @public (undocumented)
export const useSemanticImageStyles: (_state: unknown) => ImageState;

// @public
export const useSemanticInfoButtonStyles: (_state: unknown) => InfoButtonState;

// @public
export const useSemanticInfoLabelStyles: (_state: unknown) => InfoLabelState;

// @public
export const useSemanticInlineDrawerStyles: (_state: unknown) => InlineDrawerState;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@fluentui/react-input": "^9.5.6",
"@fluentui/react-icons": "^2.0.245",
"@fluentui/react-image": "^9.1.84",
"@fluentui/react-infolabel": "^9.2.0",
"@fluentui/react-jsx-runtime": "^9.0.54",
"@fluentui/react-label": "^9.1.87",
"@fluentui/react-link": "^9.4.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { useSemanticInfoButtonStyles } from './useSemanticInfoButtonStyles.styles';
export { useSemanticInfoLabelStyles } from './useSemanticInfoLabelStyles.styles';
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import { createFocusOutlineStyle } from '@fluentui/react-tabster';
import { iconFilledClassName, iconRegularClassName } from '@fluentui/react-icons';
import { makeStyles, mergeClasses, shorthands } from '@griffel/react';
import { infoButtonClassNames, type InfoButtonState } from '@fluentui/react-infolabel';
import { getSlotClassNameProp_unstable } from '@fluentui/react-utilities';
import * as semanticTokens from '@fluentui/semantic-tokens';

/**
* Styles for the root slot
*/
const useButtonStyles = makeStyles({
base: {
alignItems: 'center',
boxSizing: 'border-box',
display: 'inline-flex',
justifyContent: 'center',
textDecorationLine: 'none',
verticalAlign: 'middle',
position: 'relative',

backgroundColor: semanticTokens.nullColor,
color: semanticTokens.foregroundCtrlOnTransparentRest,

...shorthands.borderStyle('none'),
borderRadius: semanticTokens.cornerCtrlRest,
margin: '0',
padding: semanticTokens.gapInsideCtrlSmDefault,

[`& .${iconFilledClassName}`]: {
display: 'none',
},
[`& .${iconRegularClassName}`]: {
display: 'inline-flex',
},

':hover': {
backgroundColor: semanticTokens.backgroundCtrlOutlineHover,
color: semanticTokens.foregroundCtrlOnTransparentHover,
cursor: 'pointer',

[`& .${iconFilledClassName}`]: {
display: 'inline-flex',
},
[`& .${iconRegularClassName}`]: {
display: 'none',
},
},
':hover:active': {
backgroundColor: semanticTokens.backgroundCtrlOutlinePressed,
color: semanticTokens.foregroundCtrlOnTransparentPressed,
},
},

selected: {
backgroundColor: semanticTokens.nullColor,
color: semanticTokens._ctrlInfoLabelForegroundColorSelected,

[`& .${iconFilledClassName}`]: {
display: 'inline-flex',
},
[`& .${iconRegularClassName}`]: {
display: 'none',
},

'@media (forced-colors: active)': {
backgroundColor: 'Highlight',
color: 'Canvas',
},
},

highContrast: {
'@media (forced-colors: active)': {
color: 'CanvasText',

':hover,:hover:active': {
forcedColorAdjust: 'none',
backgroundColor: 'Highlight',
color: 'Canvas',
},
},
},

focusIndicator: createFocusOutlineStyle(),

large: {
padding: semanticTokens.gapBetweenContentXSmall,
},
});

const usePopoverSurfaceStyles = makeStyles({
base: {
maxWidth: '264px',
},
smallMedium: {
fontFamily: semanticTokens.textStyleDefaultRegularFontFamily,
fontSize: semanticTokens.textGlobalCaption1FontSize,
fontWeight: semanticTokens.textStyleDefaultRegularWeight,
lineHeight: semanticTokens.textGlobalCaption1LineHeight,
},
large: {
fontFamily: semanticTokens.textStyleDefaultRegularFontFamily,
fontSize: semanticTokens.textRampItemBodyFontSize,
fontWeight: semanticTokens.textStyleDefaultRegularWeight,
lineHeight: semanticTokens.textRampItemBodyLineHeight,
},
});

/**
* Apply styling to the InfoButton slots based on the state
*/
export const useSemanticInfoButtonStyles = (_state: unknown): InfoButtonState => {
'use no memo';

const state = _state as InfoButtonState;

const { size } = state;
const { open } = state.popover;
const buttonStyles = useButtonStyles();
const popoverSurfaceStyles = usePopoverSurfaceStyles();

state.info.className = mergeClasses(
state.info.className,
infoButtonClassNames.info,
popoverSurfaceStyles.base,
size === 'large' ? popoverSurfaceStyles.large : popoverSurfaceStyles.smallMedium,
getSlotClassNameProp_unstable(state.info),
);

state.root.className = mergeClasses(
state.root.className,
infoButtonClassNames.root,
buttonStyles.base,
buttonStyles.highContrast,
buttonStyles.focusIndicator,
open && buttonStyles.selected,
size === 'large' && buttonStyles.large,
getSlotClassNameProp_unstable(state.root),
);

return state;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { getSlotClassNameProp_unstable } from '@fluentui/react-utilities';
import { makeStyles, mergeClasses } from '@griffel/react';
import { infoLabelClassNames, type InfoLabelState } from '@fluentui/react-infolabel';
import * as semanticTokens from '@fluentui/semantic-tokens';

const useLabelStyles = makeStyles({
base: {
verticalAlign: 'top',
cursor: 'inherit',
color: 'inherit',
},
});

const useInfoButtonStyles = makeStyles({
base: {
verticalAlign: 'top',

// Negative margin to align with the text
marginTop: `calc(0px - ${semanticTokens.gapBetweenContentXSmall})`,
marginBottom: `calc(0px - ${semanticTokens.gapBetweenContentXSmall})`,
},

large: {
// Negative margin to align with the text
marginTop: '-1px',
marginBottom: '-1px',
},
});

/**
* Apply styling to the InfoLabel slots based on the state
*/
export const useSemanticInfoLabelStyles = (_state: unknown): InfoLabelState => {
'use no memo';

const state = _state as InfoLabelState;

state.root.className = mergeClasses(
state.root.className,
infoLabelClassNames.root,
getSlotClassNameProp_unstable(state.root),
);

const labelStyles = useLabelStyles();
state.label.className = mergeClasses(
state.label.className,
infoLabelClassNames.label,
labelStyles.base,
getSlotClassNameProp_unstable(state.label),
);

const infoButtonStyles = useInfoButtonStyles();
if (state.infoButton) {
state.infoButton.className = mergeClasses(
state.infoButton.className,
infoLabelClassNames.infoButton,
infoButtonStyles.base,
state.size === 'large' && infoButtonStyles.large,
getSlotClassNameProp_unstable(state.infoButton),
);
}

return state;
};
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import {
useSemanticToolbarToggleButtonStyles,
} from './Toolbar';
import { useSemanticTooltipStyles } from './Tooltip';
import { useSemanticInfoButtonStyles, useSemanticInfoLabelStyles } from './InfoLabel';

export const SEMANTIC_STYLE_HOOKS: FluentProviderCustomStyleHooks = {
// Accordion styles
Expand Down Expand Up @@ -179,4 +180,7 @@ export const SEMANTIC_STYLE_HOOKS: FluentProviderCustomStyleHooks = {
useTabListStyles_unstable: useSemanticTabListStyles,
//Tooltip styles
useTooltipStyles_unstable: useSemanticTooltipStyles,
// InfoLabel styles
useInfoButtonStyles_unstable: useSemanticInfoButtonStyles,
useInfoLabelStyles_unstable: useSemanticInfoLabelStyles,
};
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,4 @@ export {
useSemanticToolbarRadioButtonStyles,
useSemanticToolbarToggleButtonStyles,
} from './component-styles/Toolbar';
export { useSemanticInfoButtonStyles, useSemanticInfoLabelStyles } from './component-styles/InfoLabel';
7 changes: 5 additions & 2 deletions packages/semantic-tokens/etc/semantic-tokens.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,13 @@ export const backgroundCtrlOutlineDisabled = "var(--smtc-background-ctrl-outline
export const backgroundCtrlOutlineDisabledRaw = "--smtc-background-ctrl-outline-disabled";

// @public (undocumented)
export const backgroundCtrlOutlineHover = "var(--smtc-background-ctrl-outline-hover, var(--smtc-null-color, var(--colorTransparentBackground)))";
export const backgroundCtrlOutlineHover = "var(--smtc-background-ctrl-outline-hover, var(--smtc-null-color, var(--colorTransparentBackgroundHover)))";

// @public (undocumented)
export const backgroundCtrlOutlineHoverRaw = "--smtc-background-ctrl-outline-hover";

// @public (undocumented)
export const backgroundCtrlOutlinePressed = "var(--smtc-background-ctrl-outline-pressed, var(--smtc-null-color, var(--colorTransparentBackground)))";
export const backgroundCtrlOutlinePressed = "var(--smtc-background-ctrl-outline-pressed, var(--smtc-null-color, var(--colorTransparentBackgroundPressed)))";

// @public (undocumented)
export const backgroundCtrlOutlinePressedRaw = "--smtc-background-ctrl-outline-pressed";
Expand Down Expand Up @@ -1786,6 +1786,9 @@ export const ctrlFocusOuterStrokeWidth = "var(--smtc-ctrl-focus-outer-stroke-wid
// @public (undocumented)
export const ctrlFocusOuterStrokeWidthRaw = "--smtc-ctrl-focus-outer-stroke-width";

// @public
export const _ctrlInfoLabelForegroundColorSelected = "var(--smtc-foreground-ctrl-active-brand-rest, var(--smtc-foreground-ctrl-brand-rest, var(--colorNeutralForeground2BrandSelected)))";

// @public (undocumented)
export const ctrlInputBackgroundDisabled = "var(--smtc-ctrl-input-background-disabled, var(--smtc-background-ctrl-neutral-disabled, var(--colorNeutralBackgroundDisabled)))";

Expand Down
4 changes: 4 additions & 0 deletions packages/semantic-tokens/src/fluentLegacyVariants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ export const legacyFluentVariantsValues: LegacyFluentVariants = {
f2Token: 'colorTransparentStrokeInteractive',
originalToken: 'ctrlFocusOuterStroke',
},
_ctrlInfoLabelForegroundColorSelected: {
f2Token: 'colorNeutralForeground2BrandSelected',
originalToken: 'foregroundCtrlActiveBrandRest',
},
_ctrlInputBackgroundRestDarker: {
f2Token: 'colorNeutralBackground3',
originalToken: 'ctrlInputBackgroundRest',
Expand Down
4 changes: 2 additions & 2 deletions packages/semantic-tokens/src/fluentOverrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export const fluentOverrides: FluentOverrides = {
backgroundCtrlNeutralHover: { f2Token: 'colorNeutralBackground1Hover' },
backgroundCtrlNeutralPressed: { f2Token: 'colorNeutralBackground1Pressed' },
backgroundCtrlNeutralRest: { f2Token: 'colorNeutralBackground1' },
backgroundCtrlOutlineHover: { f2Token: 'colorTransparentBackground' },
backgroundCtrlOutlinePressed: { f2Token: 'colorTransparentBackground' },
backgroundCtrlOutlineHover: { f2Token: 'colorTransparentBackgroundHover' },
backgroundCtrlOutlinePressed: { f2Token: 'colorTransparentBackgroundPressed' },
backgroundCtrlOutlineRest: { f2Token: 'colorTransparentBackground' },
backgroundCtrlShapeSafeNeutralDisabled: { f2Token: 'colorNeutralForegroundDisabled' },
backgroundCtrlShapeSafeNeutralHover: { f2Token: 'colorNeutralStrokeAccessibleHover' },
Expand Down
1 change: 1 addition & 0 deletions packages/semantic-tokens/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,7 @@ export {
_ctrlFieldStatusSuccessTintForeground,
_ctrlFieldStatusWarningTintForeground,
_ctrlFocusOuterStrokeInteractive,
_ctrlInfoLabelForegroundColorSelected,
_ctrlInputBackgroundRestDarker,
_ctrlInputBackgroundRestLighter,
_ctrlInputBottomLineStrokeBrandPressed,
Expand Down
25 changes: 15 additions & 10 deletions packages/semantic-tokens/src/legacy/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ export const colorNeutralBackground1Pressed = 'var(--colorNeutralBackground1Pres
* @public
*/
export const colorNeutralBackground1 = 'var(--colorNeutralBackground1)';
/**
* CSS custom property value for the {@link @fluentui/tokens#colorTransparentBackgroundHover | `colorTransparentBackgroundHover`} design token.
* @public
*/
export const colorTransparentBackgroundHover = 'var(--colorTransparentBackgroundHover)';
/**
* CSS custom property value for the {@link @fluentui/tokens#colorTransparentBackgroundPressed | `colorTransparentBackgroundPressed`} design token.
* @public
*/
export const colorTransparentBackgroundPressed = 'var(--colorTransparentBackgroundPressed)';
/**
* CSS custom property value for the {@link @fluentui/tokens#colorTransparentBackground | `colorTransparentBackground`} design token.
* @public
Expand Down Expand Up @@ -689,6 +699,11 @@ export const spacingVerticalSNudge = 'var(--spacingVerticalSNudge)';
* @public
*/
export const colorPaletteDarkOrangeForeground1 = 'var(--colorPaletteDarkOrangeForeground1)';
/**
* CSS custom property value for the {@link @fluentui/tokens#colorNeutralForeground2BrandSelected | `colorNeutralForeground2BrandSelected`} design token.
* @public
*/
export const colorNeutralForeground2BrandSelected = 'var(--colorNeutralForeground2BrandSelected)';
/**
* CSS custom property value for the {@link @fluentui/tokens#colorNeutralForeground4 | `colorNeutralForeground4`} design token.
* @public
Expand Down Expand Up @@ -734,13 +749,3 @@ export const spacingHorizontalMNudge = 'var(--spacingHorizontalMNudge)';
* @public
*/
export const colorBrandStroke2Contrast = 'var(--colorBrandStroke2Contrast)';
/**
* CSS custom property value for the {@link @fluentui/tokens#colorTransparentBackgroundHover | `colorTransparentBackgroundHover`} design token.
* @public
*/
export const colorTransparentBackgroundHover = 'var(--colorTransparentBackgroundHover)';
/**
* CSS custom property value for the {@link @fluentui/tokens#colorTransparentBackgroundPressed | `colorTransparentBackgroundPressed`} design token.
* @public
*/
export const colorTransparentBackgroundPressed = 'var(--colorTransparentBackgroundPressed)';
10 changes: 9 additions & 1 deletion packages/semantic-tokens/src/legacyVariant/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ import {
spacingHorizontalM,
colorPaletteDarkOrangeForeground1,
colorTransparentStrokeInteractive,
colorNeutralForeground2BrandSelected,
colorNeutralBackground3,
colorNeutralForeground4,
fontSizeBase200,
Expand Down Expand Up @@ -181,6 +182,7 @@ import {
backgroundCtrlActiveBrandPressedRaw,
paddingCtrlLgTextBottomRaw,
paddingCtrlSmTextBottomRaw,
foregroundCtrlActiveBrandRestRaw,
foregroundCtrlOnSubtleHoverRaw,
foregroundCtrlNeutralPrimaryHoverRaw,
foregroundCtrlOnSubtlePressedRaw,
Expand All @@ -200,7 +202,6 @@ import {
textRampItemBodyLineHeightRaw,
foregroundCtrlActiveBrandHoverRaw,
foregroundCtrlActiveBrandPressedRaw,
foregroundCtrlActiveBrandRestRaw,
foregroundCtrlIconOnSubtleHoverRaw,
foregroundCtrlIconOnSubtlePressedRaw,
} from '../optional/variables';
Expand Down Expand Up @@ -751,6 +752,13 @@ export const _ctrlFieldStatusWarningTintForeground = `var(${statusWarningTintFor
* please use ctrlFocusOuterStroke instead.
*/
export const _ctrlFocusOuterStrokeInteractive = `var(${ctrlFocusOuterStrokeRaw}, var(${backgroundCtrlBrandRestRaw}, ${colorTransparentStrokeInteractive}))`;
/**
* This is a legacy variant for foregroundCtrlActiveBrandRest to enable backwards compatibility.
* It's purpose is to support Fluent UI legacy fallback variants only.
* This token is not intended for use in new semantic theme implementations
* please use foregroundCtrlActiveBrandRest instead.
*/
export const _ctrlInfoLabelForegroundColorSelected = `var(${foregroundCtrlActiveBrandRestRaw}, var(${foregroundCtrlBrandRestRaw}, ${colorNeutralForeground2BrandSelected}))`;
/**
* This is a legacy variant for ctrlInputBackgroundRest to enable backwards compatibility.
* It's purpose is to support Fluent UI legacy fallback variants only.
Expand Down
Loading
Loading