-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathuseTooltipStyles.styles.ts
More file actions
76 lines (63 loc) · 2.14 KB
/
useTooltipStyles.styles.ts
File metadata and controls
76 lines (63 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
'use client';
import { makeStyles, mergeClasses } from '@griffel/react';
import { createArrowStyles } from '@fluentui/react-positioning';
import { tokens } from '@fluentui/react-theme';
import { arrowHeight } from './private/constants';
import type { TooltipSlots, TooltipState } from './Tooltip.types';
import type { SlotClassNames } from '@fluentui/react-utilities';
export const tooltipClassNames: SlotClassNames<TooltipSlots> = {
content: 'fui-Tooltip__content',
};
/**
* Styles for the tooltip
*/
const useStyles = makeStyles({
root: {
display: 'none',
boxSizing: 'border-box',
maxWidth: '240px',
cursor: 'default',
fontFamily: tokens.fontFamilyBase,
fontSize: tokens.fontSizeBase200,
lineHeight: tokens.lineHeightBase200,
overflowWrap: 'break-word',
borderRadius: tokens.borderRadiusMedium,
border: `1px solid ${tokens.colorTransparentStroke}`,
padding: '4px 11px 6px 11px', // '5px 12px 7px 12px' minus the border width '1px'
backgroundColor: tokens.colorNeutralBackground1,
color: tokens.colorNeutralForeground1,
// TODO need to add versions of tokens.alias.shadow.shadow8, etc. that work with filter
filter:
`drop-shadow(0 0 2px ${tokens.colorNeutralShadowAmbient}) ` +
`drop-shadow(0 4px 8px ${tokens.colorNeutralShadowKey})`,
},
visible: {
display: 'block',
},
inverted: {
backgroundColor: tokens.colorNeutralBackgroundStatic,
color: tokens.colorNeutralForegroundStaticInverted,
},
brand: {
backgroundColor: tokens.colorBrandBackground,
color: tokens.colorNeutralForegroundOnBrand,
},
arrow: createArrowStyles({ arrowHeight }),
});
/**
* Apply styling to the Tooltip slots based on the state
*/
export const useTooltipStyles_unstable = (state: TooltipState): TooltipState => {
'use no memo';
const styles = useStyles();
state.content.className = mergeClasses(
tooltipClassNames.content,
styles.root,
state.appearance === 'inverted' && styles.inverted,
state.appearance === 'brand' && styles.brand,
state.visible && styles.visible,
state.content.className,
);
state.arrowClassName = styles.arrow;
return state;
};