Private
Public Access
1
0

feat: Fluent UI Outlook Lite + connections mockup

This commit is contained in:
2026-04-14 18:52:25 +00:00
parent 1199eff6c3
commit dfa4010406
34820 changed files with 1003813 additions and 205 deletions

View File

@@ -0,0 +1,13 @@
'use client';
import * as React from 'react';
import { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';
import { useMenuItemSwitch_unstable } from './useMenuItemSwitch';
import { renderMenuItemSwitch_unstable } from './renderMenuItemSwitch';
import { useMenuItemSwitchStyles_unstable } from './useMenuItemSwitchStyles.styles';
export const MenuItemSwitch = /*#__PURE__*/ React.forwardRef((props, ref)=>{
const state = useMenuItemSwitch_unstable(props, ref);
useMenuItemSwitchStyles_unstable(state);
useCustomStyleHook_unstable('useMenuItemSwitchStyles_unstable')(state);
return renderMenuItemSwitch_unstable(state);
});
MenuItemSwitch.displayName = 'MenuItemSwitch';

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/MenuItemSwitch/MenuItemSwitch.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\nimport { useMenuItemSwitch_unstable } from './useMenuItemSwitch';\nimport { renderMenuItemSwitch_unstable } from './renderMenuItemSwitch';\nimport { useMenuItemSwitchStyles_unstable } from './useMenuItemSwitchStyles.styles';\nimport type { MenuItemSwitchProps } from './MenuItemSwitch.types';\n\nexport const MenuItemSwitch: ForwardRefComponent<MenuItemSwitchProps> = React.forwardRef((props, ref) => {\n const state = useMenuItemSwitch_unstable(props, ref);\n\n useMenuItemSwitchStyles_unstable(state);\n useCustomStyleHook_unstable('useMenuItemSwitchStyles_unstable')(state);\n return renderMenuItemSwitch_unstable(state);\n});\n\nMenuItemSwitch.displayName = 'MenuItemSwitch';\n"],"names":["React","useCustomStyleHook_unstable","useMenuItemSwitch_unstable","renderMenuItemSwitch_unstable","useMenuItemSwitchStyles_unstable","MenuItemSwitch","forwardRef","props","ref","state","displayName"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,2BAA2B,QAAQ,kCAAkC;AAC9E,SAASC,0BAA0B,QAAQ,sBAAsB;AACjE,SAASC,6BAA6B,QAAQ,yBAAyB;AACvE,SAASC,gCAAgC,QAAQ,mCAAmC;AAGpF,OAAO,MAAMC,+BAA2DL,MAAMM,UAAU,CAAC,CAACC,OAAOC;IAC/F,MAAMC,QAAQP,2BAA2BK,OAAOC;IAEhDJ,iCAAiCK;IACjCR,4BAA4B,oCAAoCQ;IAChE,OAAON,8BAA8BM;AACvC,GAAG;AAEHJ,eAAeK,WAAW,GAAG"}

View File

@@ -0,0 +1,3 @@
/**
* State used in rendering MenuItemSwitch
*/ export { };

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/MenuItemSwitch/MenuItemSwitch.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { MenuItemSlots } from '../MenuItem/MenuItem.types';\nimport { MenuItemSelectableState } from '../../selectable/types';\nimport { MenuItemCheckboxProps } from '../MenuItemCheckbox/MenuItemCheckbox.types';\n\nexport type MenuItemSwitchSlots = Pick<MenuItemSlots, 'root' | 'content' | 'secondaryContent' | 'icon' | 'subText'> & {\n switchIndicator?: Slot<'span'>;\n};\n\n/**\n * MenuItemSwitch Props\n */\nexport type MenuItemSwitchProps = ComponentProps<MenuItemSwitchSlots> &\n Pick<MenuItemCheckboxProps, 'disabled' | 'persistOnClick' | 'name' | 'value'>;\n\n/**\n * State used in rendering MenuItemSwitch\n */\nexport type MenuItemSwitchState = ComponentState<MenuItemSwitchSlots> &\n MenuItemSelectableState &\n Required<Pick<MenuItemSwitchProps, 'disabled'>>;\n"],"names":[],"mappings":"AAeA;;CAEC,GACD,WAEkD"}

View File

@@ -0,0 +1,4 @@
export { MenuItemSwitch } from './MenuItemSwitch';
export { renderMenuItemSwitch_unstable } from './renderMenuItemSwitch';
export { useMenuItemSwitch_unstable, useMenuItemSwitchBase_unstable } from './useMenuItemSwitch';
export { circleFilledClassName, menuItemSwitchClassNames, useMenuItemSwitchStyles_unstable } from './useMenuItemSwitchStyles.styles';

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/MenuItemSwitch/index.ts"],"sourcesContent":["export { MenuItemSwitch } from './MenuItemSwitch';\nexport type { MenuItemSwitchProps, MenuItemSwitchSlots, MenuItemSwitchState } from './MenuItemSwitch.types';\nexport { renderMenuItemSwitch_unstable } from './renderMenuItemSwitch';\nexport { useMenuItemSwitch_unstable, useMenuItemSwitchBase_unstable } from './useMenuItemSwitch';\nexport {\n circleFilledClassName,\n menuItemSwitchClassNames,\n useMenuItemSwitchStyles_unstable,\n} from './useMenuItemSwitchStyles.styles';\n"],"names":["MenuItemSwitch","renderMenuItemSwitch_unstable","useMenuItemSwitch_unstable","useMenuItemSwitchBase_unstable","circleFilledClassName","menuItemSwitchClassNames","useMenuItemSwitchStyles_unstable"],"mappings":"AAAA,SAASA,cAAc,QAAQ,mBAAmB;AAElD,SAASC,6BAA6B,QAAQ,yBAAyB;AACvE,SAASC,0BAA0B,EAAEC,8BAA8B,QAAQ,sBAAsB;AACjG,SACEC,qBAAqB,EACrBC,wBAAwB,EACxBC,gCAAgC,QAC3B,mCAAmC"}

View File

@@ -0,0 +1,20 @@
import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
import { assertSlots } from '@fluentui/react-utilities';
/**
* Function that renders the final JSX of the component
*/ export const renderMenuItemSwitch_unstable = (state)=>{
assertSlots(state);
return /*#__PURE__*/ _jsxs(state.root, {
children: [
state.icon && /*#__PURE__*/ _jsx(state.icon, {}),
state.content && /*#__PURE__*/ _jsxs(state.content, {
children: [
state.content.children,
state.subText && /*#__PURE__*/ _jsx(state.subText, {})
]
}),
state.secondaryContent && /*#__PURE__*/ _jsx(state.secondaryContent, {}),
state.switchIndicator && /*#__PURE__*/ _jsx(state.switchIndicator, {})
]
});
};

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/MenuItemSwitch/renderMenuItemSwitch.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { MenuItemSwitchSlots, MenuItemSwitchState } from './MenuItemSwitch.types';\n\n/**\n * Function that renders the final JSX of the component\n */\nexport const renderMenuItemSwitch_unstable = (state: MenuItemSwitchState): JSXElement => {\n assertSlots<MenuItemSwitchSlots>(state);\n\n return (\n <state.root>\n {state.icon && <state.icon />}\n {state.content && (\n <state.content>\n {state.content.children}\n {state.subText && <state.subText />}\n </state.content>\n )}\n {state.secondaryContent && <state.secondaryContent />}\n {state.switchIndicator && <state.switchIndicator />}\n </state.root>\n );\n};\n"],"names":["assertSlots","renderMenuItemSwitch_unstable","state","root","icon","content","children","subText","secondaryContent","switchIndicator"],"mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AACjD,SAASA,WAAW,QAAQ,4BAA4B;AAIxD;;CAEC,GACD,OAAO,MAAMC,gCAAgC,CAACC;IAC5CF,YAAiCE;IAEjC,qBACE,MAACA,MAAMC,IAAI;;YACRD,MAAME,IAAI,kBAAI,KAACF,MAAME,IAAI;YACzBF,MAAMG,OAAO,kBACZ,MAACH,MAAMG,OAAO;;oBACXH,MAAMG,OAAO,CAACC,QAAQ;oBACtBJ,MAAMK,OAAO,kBAAI,KAACL,MAAMK,OAAO;;;YAGnCL,MAAMM,gBAAgB,kBAAI,KAACN,MAAMM,gBAAgB;YACjDN,MAAMO,eAAe,kBAAI,KAACP,MAAMO,eAAe;;;AAGtD,EAAE"}

View File

@@ -0,0 +1,48 @@
'use client';
import * as React from 'react';
import { slot } from '@fluentui/react-utilities';
import { useMenuItemCheckboxBase_unstable } from '../MenuItemCheckbox/useMenuItemCheckbox';
import { CircleFilled } from '@fluentui/react-icons';
import { circleFilledClassName } from './useMenuItemSwitchStyles.styles';
/**
* Create the state required to render MenuItemSwitch.
*
* The returned state can be modified with hooks such as useMenuItemSwitchStyles_unstable,
* before being passed to renderMenuItemSwitch_unstable.
*
* @param props - props from this instance of MenuItemSwitch
* @param ref - reference to root HTMLDivElement of MenuItemSwitch
*/ export const useMenuItemSwitch_unstable = (props, ref)=>{
const state = useMenuItemSwitchBase_unstable(props, ref);
// Set default icon for switch indicator
if (state.switchIndicator) {
var _state_switchIndicator;
var _children;
(_children = (_state_switchIndicator = state.switchIndicator).children) !== null && _children !== void 0 ? _children : _state_switchIndicator.children = /*#__PURE__*/ React.createElement(CircleFilled, {
className: circleFilledClassName
});
}
return state;
};
/**
* Base hook for MenuItemSwitch component, produces state required to render the component.
* It doesn't set any design-related props specific to MenuItemSwitch.
*
* @internal
* @param props - props from this instance of MenuItemSwitch
* @param ref - reference to root HTMLDivElement of MenuItemSwitch
*/ export const useMenuItemSwitchBase_unstable = (props, ref)=>{
const baseState = useMenuItemCheckboxBase_unstable(props, ref);
return {
...baseState,
switchIndicator: slot.optional(props.switchIndicator, {
renderByDefault: true,
elementType: 'span'
}),
components: {
// eslint-disable-next-line @typescript-eslint/no-deprecated
...baseState.components,
switchIndicator: 'span'
}
};
};

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/MenuItemSwitch/useMenuItemSwitch.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { slot } from '@fluentui/react-utilities';\nimport type { MenuItemSwitchProps, MenuItemSwitchState } from './MenuItemSwitch.types';\nimport { useMenuItemCheckboxBase_unstable } from '../MenuItemCheckbox/useMenuItemCheckbox';\nimport { CircleFilled } from '@fluentui/react-icons';\nimport { circleFilledClassName } from './useMenuItemSwitchStyles.styles';\n\n/**\n * Create the state required to render MenuItemSwitch.\n *\n * The returned state can be modified with hooks such as useMenuItemSwitchStyles_unstable,\n * before being passed to renderMenuItemSwitch_unstable.\n *\n * @param props - props from this instance of MenuItemSwitch\n * @param ref - reference to root HTMLDivElement of MenuItemSwitch\n */\nexport const useMenuItemSwitch_unstable = (\n props: MenuItemSwitchProps,\n ref: React.Ref<HTMLDivElement>,\n): MenuItemSwitchState => {\n const state = useMenuItemSwitchBase_unstable(props, ref);\n\n // Set default icon for switch indicator\n if (state.switchIndicator) {\n state.switchIndicator.children ??= <CircleFilled className={circleFilledClassName} />;\n }\n\n return state;\n};\n\n/**\n * Base hook for MenuItemSwitch component, produces state required to render the component.\n * It doesn't set any design-related props specific to MenuItemSwitch.\n *\n * @internal\n * @param props - props from this instance of MenuItemSwitch\n * @param ref - reference to root HTMLDivElement of MenuItemSwitch\n */\nexport const useMenuItemSwitchBase_unstable = (\n props: MenuItemSwitchProps,\n ref: React.Ref<HTMLDivElement>,\n): MenuItemSwitchState => {\n const baseState = useMenuItemCheckboxBase_unstable(props, ref);\n return {\n ...baseState,\n switchIndicator: slot.optional(props.switchIndicator, {\n renderByDefault: true,\n elementType: 'span',\n }),\n components: {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ...baseState.components,\n switchIndicator: 'span',\n },\n };\n};\n"],"names":["React","slot","useMenuItemCheckboxBase_unstable","CircleFilled","circleFilledClassName","useMenuItemSwitch_unstable","props","ref","state","useMenuItemSwitchBase_unstable","switchIndicator","children","className","baseState","optional","renderByDefault","elementType","components"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,IAAI,QAAQ,4BAA4B;AAEjD,SAASC,gCAAgC,QAAQ,0CAA0C;AAC3F,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,qBAAqB,QAAQ,mCAAmC;AAEzE;;;;;;;;CAQC,GACD,OAAO,MAAMC,6BAA6B,CACxCC,OACAC;IAEA,MAAMC,QAAQC,+BAA+BH,OAAOC;IAEpD,wCAAwC;IACxC,IAAIC,MAAME,eAAe,EAAE;YACzBF;;QAAAA,cAAAA,yBAAAA,MAAME,eAAe,EAACC,yDAAtBH,uBAAsBG,yBAAa,oBAACR;YAAaS,WAAWR;;IAC9D;IAEA,OAAOI;AACT,EAAE;AAEF;;;;;;;CAOC,GACD,OAAO,MAAMC,iCAAiC,CAC5CH,OACAC;IAEA,MAAMM,YAAYX,iCAAiCI,OAAOC;IAC1D,OAAO;QACL,GAAGM,SAAS;QACZH,iBAAiBT,KAAKa,QAAQ,CAACR,MAAMI,eAAe,EAAE;YACpDK,iBAAiB;YACjBC,aAAa;QACf;QACAC,YAAY;YACV,4DAA4D;YAC5D,GAAGJ,UAAUI,UAAU;YACvBP,iBAAiB;QACnB;IACF;AACF,EAAE"}

View File

@@ -0,0 +1,101 @@
'use client';
import { __styles, __resetStyles, mergeClasses, shorthands } from '@griffel/react';
import { tokens } from '@fluentui/react-theme';
import { useMenuItemStyles_unstable } from '../MenuItem/useMenuItemStyles.styles';
export const menuItemSwitchClassNames = {
root: 'fui-MenuItemSwitch',
icon: 'fui-MenuItemSwitch__icon',
content: 'fui-MenuItemSwitch__content',
secondaryContent: 'fui-MenuItemSwitch__secondaryContent',
switchIndicator: 'fui-MenuItemSwitch__switchIndicator',
subText: 'fui-MenuItemSwitch__subText'
};
export const circleFilledClassName = 'fui-MenuItemSwitch__switchIndicator__circleFilled';
// Thumb and track sizes used by the component.
const spaceBetweenThumbAndTrack = 2;
const trackHeight = 20;
const trackWidth = 40;
const thumbSize = trackHeight - spaceBetweenThumbAndTrack;
const useSwitchIndicatorBaseClassName = /*#__PURE__*/__resetStyles("r1x31n8g", "rsmcm5v", {
r: [".r1x31n8g{border-radius:var(--borderRadiusCircular);border:var(--strokeWidthThin) solid var(--colorNeutralStrokeAccessible);line-height:0;box-sizing:border-box;fill:currentColor;flex-shrink:0;font-size:18px;height:20px;transition-duration:var(--durationNormal);transition-timing-function:var(--curveEasyEase);transition-property:background,border,color;width:40px;margin-right:var(--spacingHorizontalXS);color:var(--colorNeutralStrokeAccessible);}", ".r1x31n8g:hover{color:var(--colorNeutralStrokeAccessibleHover);border-color:var(--colorNeutralStrokeAccessibleHover);}", ".r1x31n8g:hover:active{color:var(--colorNeutralStrokeAccessiblePressed);border-color:var(--colorNeutralStrokeAccessiblePressed);}", ".r1x31n8g .fui-MenuItemSwitch__switchIndicator__circleFilled{transition-duration:var(--durationNormal);transition-timing-function:var(--curveEasyEase);transition-property:transform;}", ".rsmcm5v{border-radius:var(--borderRadiusCircular);border:var(--strokeWidthThin) solid var(--colorNeutralStrokeAccessible);line-height:0;box-sizing:border-box;fill:currentColor;flex-shrink:0;font-size:18px;height:20px;transition-duration:var(--durationNormal);transition-timing-function:var(--curveEasyEase);transition-property:background,border,color;width:40px;margin-left:var(--spacingHorizontalXS);color:var(--colorNeutralStrokeAccessible);}", ".rsmcm5v:hover{color:var(--colorNeutralStrokeAccessibleHover);border-color:var(--colorNeutralStrokeAccessibleHover);}", ".rsmcm5v:hover:active{color:var(--colorNeutralStrokeAccessiblePressed);border-color:var(--colorNeutralStrokeAccessiblePressed);}", ".rsmcm5v .fui-MenuItemSwitch__switchIndicator__circleFilled{transition-duration:var(--durationNormal);transition-timing-function:var(--curveEasyEase);transition-property:transform;}"],
s: ["@media screen and (prefers-reduced-motion: reduce){.r1x31n8g{transition-duration:0.01ms;}}", "@media screen and (prefers-reduced-motion: reduce){.r1x31n8g .fui-MenuItemSwitch__switchIndicator__circleFilled{transition-duration:0.01ms;}}", "@media screen and (prefers-reduced-motion: reduce){.rsmcm5v{transition-duration:0.01ms;}}", "@media screen and (prefers-reduced-motion: reduce){.rsmcm5v .fui-MenuItemSwitch__switchIndicator__circleFilled{transition-duration:0.01ms;}}"]
});
const useSwitchIndicatorStyles = /*#__PURE__*/__styles({
checked: {
G4r02d: ["fdca5i2", "fk0rr1z"],
De3pzq: "ftywsgz",
sj55zd: "fqpbvvt",
g2u3we: "fghlq4f",
h3c5rm: ["f1gn591s", "fjscplz"],
B9xav0g: "fb073pr",
zhjwy3: ["fjscplz", "f1gn591s"],
Bi91k9c: "fz46y8r",
Jwef8y: "f1kjrvvj",
Bgoe8wy: "fpa59ij",
Bwzppfd: ["f1rhln42", "f1l1ogpg"],
oetu4i: "fz67qlh",
gg5e9n: ["f1l1ogpg", "f1rhln42"],
B2d53fq: "frlnr8d",
iro3zm: "fle2s0s",
b661bw: "f1j8ziw4",
Bk6r4ia: ["f1xzu9i0", "f1jlpvxk"],
B9zn80p: "f1i1ccxp",
Bpld233: ["f1jlpvxk", "f1xzu9i0"]
}
}, {
d: [".fdca5i2 .fui-MenuItemSwitch__switchIndicator__circleFilled{transform:translateX(20px);}", ".fk0rr1z .fui-MenuItemSwitch__switchIndicator__circleFilled{transform:translateX(-20px);}", ".ftywsgz{background-color:var(--colorCompoundBrandBackground);}", ".fqpbvvt{color:var(--colorNeutralForegroundInverted);}", ".fghlq4f{border-top-color:var(--colorTransparentStroke);}", ".f1gn591s{border-right-color:var(--colorTransparentStroke);}", ".fjscplz{border-left-color:var(--colorTransparentStroke);}", ".fb073pr{border-bottom-color:var(--colorTransparentStroke);}"],
h: [".fz46y8r:hover{color:var(--colorNeutralForegroundInverted);}", ".f1kjrvvj:hover{background-color:var(--colorCompoundBrandBackgroundHover);}", ".fpa59ij:hover{border-top-color:var(--colorTransparentStrokeInteractive);}", ".f1rhln42:hover{border-right-color:var(--colorTransparentStrokeInteractive);}", ".f1l1ogpg:hover{border-left-color:var(--colorTransparentStrokeInteractive);}", ".fz67qlh:hover{border-bottom-color:var(--colorTransparentStrokeInteractive);}", ".frlnr8d:hover:active{color:var(--colorNeutralForegroundInverted);}", ".fle2s0s:hover:active{background-color:var(--colorCompoundBrandBackgroundPressed);}", ".f1j8ziw4:hover:active{border-top-color:var(--colorTransparentStrokeInteractive);}", ".f1xzu9i0:hover:active{border-right-color:var(--colorTransparentStrokeInteractive);}", ".f1jlpvxk:hover:active{border-left-color:var(--colorTransparentStrokeInteractive);}", ".f1i1ccxp:hover:active{border-bottom-color:var(--colorTransparentStrokeInteractive);}"]
});
const useMultilineStyles = /*#__PURE__*/__styles({
"switch": {
qb2dma: "f7nlbp4"
}
}, {
d: [".f7nlbp4{align-self:center;}"]
});
/**
* Apply styling to the MenuItemSwitch slots based on the state
*/
export const useMenuItemSwitchStyles_unstable = state => {
'use no memo';
const {
checked,
subText
} = state;
const multiline = !!subText;
const switchIndicatorStyles = useSwitchIndicatorStyles();
const switchIndicatorBaseStyles = useSwitchIndicatorBaseClassName();
const multilineStyles = useMultilineStyles();
state.root.className = mergeClasses(menuItemSwitchClassNames.root, state.root.className);
if (state.content) {
state.content.className = mergeClasses(menuItemSwitchClassNames.content, state.content.className);
}
if (state.secondaryContent) {
state.secondaryContent.className = mergeClasses(menuItemSwitchClassNames.secondaryContent, state.secondaryContent.className);
}
if (state.icon) {
state.icon.className = mergeClasses(menuItemSwitchClassNames.icon, state.icon.className);
}
if (state.subText) {
state.subText.className = mergeClasses(menuItemSwitchClassNames.subText, state.subText.className);
}
if (state.switchIndicator) {
state.switchIndicator.className = mergeClasses(menuItemSwitchClassNames.switchIndicator, switchIndicatorBaseStyles, checked && switchIndicatorStyles.checked, state.switchIndicator.className, multiline && multilineStyles.switch);
}
useMenuItemStyles_unstable({
...state,
components: {
// eslint-disable-next-line @typescript-eslint/no-deprecated
...state.components,
checkmark: 'span',
submenuIndicator: 'span'
},
checkmark: undefined,
submenuIndicator: undefined,
hasSubmenu: false,
persistOnClick: true
});
return state;
};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,118 @@
'use client';
import { makeStyles, makeResetStyles, mergeClasses, shorthands } from '@griffel/react';
import { tokens } from '@fluentui/react-theme';
import { useMenuItemStyles_unstable } from '../MenuItem/useMenuItemStyles.styles';
export const menuItemSwitchClassNames = {
root: 'fui-MenuItemSwitch',
icon: 'fui-MenuItemSwitch__icon',
content: 'fui-MenuItemSwitch__content',
secondaryContent: 'fui-MenuItemSwitch__secondaryContent',
switchIndicator: 'fui-MenuItemSwitch__switchIndicator',
subText: 'fui-MenuItemSwitch__subText'
};
export const circleFilledClassName = 'fui-MenuItemSwitch__switchIndicator__circleFilled';
// Thumb and track sizes used by the component.
const spaceBetweenThumbAndTrack = 2;
const trackHeight = 20;
const trackWidth = 40;
const thumbSize = trackHeight - spaceBetweenThumbAndTrack;
const useSwitchIndicatorBaseClassName = makeResetStyles({
borderRadius: tokens.borderRadiusCircular,
border: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStrokeAccessible}`,
lineHeight: 0,
boxSizing: 'border-box',
fill: 'currentColor',
flexShrink: 0,
fontSize: `${thumbSize}px`,
height: `${trackHeight}px`,
transitionDuration: tokens.durationNormal,
transitionTimingFunction: tokens.curveEasyEase,
transitionProperty: 'background, border, color',
width: `${trackWidth}px`,
marginRight: tokens.spacingHorizontalXS,
'@media screen and (prefers-reduced-motion: reduce)': {
transitionDuration: '0.01ms'
},
color: tokens.colorNeutralStrokeAccessible,
':hover': {
color: tokens.colorNeutralStrokeAccessibleHover,
borderColor: tokens.colorNeutralStrokeAccessibleHover
},
':hover:active': {
color: tokens.colorNeutralStrokeAccessiblePressed,
borderColor: tokens.colorNeutralStrokeAccessiblePressed
},
[`& .${circleFilledClassName}`]: {
transitionDuration: tokens.durationNormal,
transitionTimingFunction: tokens.curveEasyEase,
transitionProperty: 'transform',
'@media screen and (prefers-reduced-motion: reduce)': {
transitionDuration: '0.01ms'
}
}
});
const useSwitchIndicatorStyles = makeStyles({
checked: {
[`& .${circleFilledClassName}`]: {
transform: `translateX(${trackWidth - thumbSize - spaceBetweenThumbAndTrack}px)`
},
backgroundColor: tokens.colorCompoundBrandBackground,
color: tokens.colorNeutralForegroundInverted,
...shorthands.borderColor(tokens.colorTransparentStroke),
':hover': {
color: tokens.colorNeutralForegroundInverted,
backgroundColor: tokens.colorCompoundBrandBackgroundHover,
...shorthands.borderColor(tokens.colorTransparentStrokeInteractive)
},
':hover:active': {
color: tokens.colorNeutralForegroundInverted,
backgroundColor: tokens.colorCompoundBrandBackgroundPressed,
...shorthands.borderColor(tokens.colorTransparentStrokeInteractive)
}
}
});
const useMultilineStyles = makeStyles({
switch: {
alignSelf: 'center'
}
});
/**
* Apply styling to the MenuItemSwitch slots based on the state
*/ export const useMenuItemSwitchStyles_unstable = (state)=>{
'use no memo';
const { checked, subText } = state;
const multiline = !!subText;
const switchIndicatorStyles = useSwitchIndicatorStyles();
const switchIndicatorBaseStyles = useSwitchIndicatorBaseClassName();
const multilineStyles = useMultilineStyles();
state.root.className = mergeClasses(menuItemSwitchClassNames.root, state.root.className);
if (state.content) {
state.content.className = mergeClasses(menuItemSwitchClassNames.content, state.content.className);
}
if (state.secondaryContent) {
state.secondaryContent.className = mergeClasses(menuItemSwitchClassNames.secondaryContent, state.secondaryContent.className);
}
if (state.icon) {
state.icon.className = mergeClasses(menuItemSwitchClassNames.icon, state.icon.className);
}
if (state.subText) {
state.subText.className = mergeClasses(menuItemSwitchClassNames.subText, state.subText.className);
}
if (state.switchIndicator) {
state.switchIndicator.className = mergeClasses(menuItemSwitchClassNames.switchIndicator, switchIndicatorBaseStyles, checked && switchIndicatorStyles.checked, state.switchIndicator.className, multiline && multilineStyles.switch);
}
useMenuItemStyles_unstable({
...state,
components: {
// eslint-disable-next-line @typescript-eslint/no-deprecated
...state.components,
checkmark: 'span',
submenuIndicator: 'span'
},
checkmark: undefined,
submenuIndicator: undefined,
hasSubmenu: false,
persistOnClick: true
});
return state;
};

File diff suppressed because one or more lines are too long