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

react-tooltip: Replacing use of functions in makeStyles with direct use of tokens #21058

Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Replacing use of functions in makeStyles with direct use of tokens.",
"packageName": "@fluentui/react-tooltip",
"email": "[email protected]",
"dependentChangeType": "patch"
}
33 changes: 17 additions & 16 deletions packages/react-tooltip/src/components/Tooltip/useTooltipStyles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { shorthands, makeStyles, mergeClasses } from '@fluentui/react-make-styles';
import { createArrowStyles } from '@fluentui/react-positioning';
import { tokens } from '@fluentui/react-theme';
import type { TooltipState } from './Tooltip.types';

export const tooltipClassName = 'fui-Tooltip';
Expand All @@ -8,35 +9,35 @@ export const tooltipClassName = 'fui-Tooltip';
* Styles for the tooltip
*/
const useStyles = makeStyles({
root: theme => ({
root: {
display: 'none',
boxSizing: 'border-box',
maxWidth: '240px',
cursor: 'default',
fontFamily: theme.fontFamilyBase,
fontSize: theme.fontSizeBase200,
lineHeight: theme.lineHeightBase200,
fontFamily: tokens.fontFamilyBase,
fontSize: tokens.fontSizeBase200,
lineHeight: tokens.lineHeightBase200,

...shorthands.borderRadius(theme.borderRadiusMedium), // Must match tooltipBorderRadius in useTooltip.tsx
...shorthands.border('1px', 'solid', theme.colorTransparentStroke),
...shorthands.borderRadius(tokens.borderRadiusMedium), // Must match tooltipBorderRadius in useTooltip.tsx
...shorthands.border('1px', 'solid', tokens.colorTransparentStroke),
...shorthands.padding('4px', '11px', '6px', '11px'), // '5px 12px 7px 12px' minus the border width '1px'
backgroundColor: theme.colorNeutralBackground1,
color: theme.colorNeutralForeground1,
backgroundColor: tokens.colorNeutralBackground1,
color: tokens.colorNeutralForeground1,

// TODO need to add versions of theme.alias.shadow.shadow8, etc. that work with filter
// TODO need to add versions of tokens.alias.shadow.shadow8, etc. that work with filter
filter:
`drop-shadow(0 0 2px ${theme.colorNeutralShadowAmbient}) ` +
`drop-shadow(0 4px 8px ${theme.colorNeutralShadowKey})`,
}),
`drop-shadow(0 0 2px ${tokens.colorNeutralShadowAmbient}) ` +
`drop-shadow(0 4px 8px ${tokens.colorNeutralShadowKey})`,
},

visible: {
display: 'block',
},

inverted: theme => ({
backgroundColor: theme.colorNeutralBackgroundInverted,
color: theme.colorNeutralForegroundInverted,
}),
inverted: {
backgroundColor: tokens.colorNeutralBackgroundInverted,
color: tokens.colorNeutralForegroundInverted,
},

arrow: createArrowStyles({ arrowHeight: 6 }), // Must match arrowHeight in useTooltip.tsx
});
Expand Down