-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMenuItem.ts
86 lines (80 loc) · 2.24 KB
/
MenuItem.ts
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
77
78
79
80
81
82
83
84
85
86
import { css, CSSObject } from '../utils';
export const element = 'button';
export const className = 'menu-item';
const variants = ['success', 'info', 'error', 'warning'] as const;
/**
* We export the objects as well for compatibilty with 3rd party libs like react-select
*/
/**
*
* @alias menuItemStateStylesObjects
*/
export const stateStylesObjects: Record<
'focus' | 'selected' | 'active' | 'hover',
CSSObject
> = {
active: {
background: 'var(--surface-active)'
},
focus: {
background: 'var(--surface-hover)'
},
selected: {
background: 'var(--surface-active)'
},
hover: {
background: 'var(--surface-hover)'
}
};
export const fullStylesObject: CSSObject = {
font: 'var(--body-1)',
'&, &:any-link, &:hover': {
color: 'var(--text)'
},
padding: 'var(--spacing-l2)',
borderRadius: 'var(--border-radius-small)',
display: 'grid',
gridGap: 'var(--spacing-l2)',
gridAutoFlow: 'column',
alignItems: 'center',
flex: '1 1 100%',
justifyContent: 'flex-start',
textDecoration: 'none !important',
outline: 'none',
'&:is(button, :any-link), &:matches(button, :any-link)': {
cursor: 'pointer'
},
'&[data-variant="success"]': {
color: 'var(--success)'
},
'&[data-variant="info"]': {
color: 'var(--info)'
},
'&[data-variant="error"]': {
color: 'var(--error)'
},
'&[data-variant="warning"]': {
color: 'var(--warning)'
}
};
export interface Props {
'data-selected'?: boolean;
'data-variant'?: (typeof variants)[number];
}
// eslint-disable-next-line @emotion/syntax-preference
export const fullStyles = css({
...fullStylesObject,
'&:matches(button, :any-link):matches(:active, [data-pseudo="active"])':
stateStylesObjects.active,
'&:is(button, :any-link):is(:active, [data-pseudo="active"])':
stateStylesObjects.active,
'&:matches(button, :any-link):matches(:focus, [data-pseudo="focus"])':
stateStylesObjects.focus,
'&:is(button, :any-link):is(:focus, [data-pseudo="focus"])':
stateStylesObjects.focus,
'&:matches(button, :any-link):matches(:hover, [data-pseudo="hover"])':
stateStylesObjects.hover,
'&:is(button, :any-link):is(:hover, [data-pseudo="hover"])':
stateStylesObjects.hover,
'&[data-selected=true]': stateStylesObjects.selected
});