@atlaskit/menu 1.1.3 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/dist/cjs/internal/components/menu-item-primitive.js +200 -0
- package/dist/cjs/menu-item/button-item.js +31 -25
- package/dist/cjs/menu-item/custom-item.js +31 -32
- package/dist/cjs/menu-item/heading-item.js +25 -7
- package/dist/cjs/menu-item/link-item.js +50 -45
- package/dist/cjs/menu-item/skeleton-heading-item.js +42 -14
- package/dist/cjs/menu-item/skeleton-item.js +93 -13
- package/dist/cjs/menu-section/menu-group.js +11 -8
- package/dist/cjs/menu-section/section.js +83 -29
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/internal/components/menu-item-primitive.js +180 -0
- package/dist/es2019/menu-item/button-item.js +28 -21
- package/dist/es2019/menu-item/custom-item.js +32 -24
- package/dist/es2019/menu-item/heading-item.js +22 -6
- package/dist/es2019/menu-item/link-item.js +31 -26
- package/dist/es2019/menu-item/skeleton-heading-item.js +37 -11
- package/dist/es2019/menu-item/skeleton-item.js +89 -11
- package/dist/es2019/menu-section/menu-group.js +12 -8
- package/dist/es2019/menu-section/section.js +83 -31
- package/dist/es2019/version.json +1 -1
- package/dist/esm/internal/components/menu-item-primitive.js +184 -0
- package/dist/esm/menu-item/button-item.js +30 -24
- package/dist/esm/menu-item/custom-item.js +32 -26
- package/dist/esm/menu-item/heading-item.js +22 -8
- package/dist/esm/menu-item/link-item.js +49 -45
- package/dist/esm/menu-item/skeleton-heading-item.js +38 -14
- package/dist/esm/menu-item/skeleton-item.js +89 -13
- package/dist/esm/menu-section/menu-group.js +12 -8
- package/dist/esm/menu-section/section.js +82 -32
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internal/components/menu-item-primitive.d.ts +17 -0
- package/dist/types/menu-item/button-item.d.ts +1 -1
- package/dist/types/menu-item/custom-item.d.ts +2 -1
- package/dist/types/menu-item/skeleton-heading-item.d.ts +1 -2
- package/dist/types/menu-item/skeleton-item.d.ts +1 -2
- package/dist/types/types.d.ts +27 -7
- package/package.json +4 -2
- package/dist/cjs/internal/components/base-item.js +0 -65
- package/dist/cjs/internal/styles/menu-item/base-item.js +0 -152
- package/dist/cjs/internal/styles/menu-item/button-item.js +0 -28
- package/dist/cjs/internal/styles/menu-item/custom-item.js +0 -24
- package/dist/cjs/internal/styles/menu-item/heading-item.js +0 -28
- package/dist/cjs/internal/styles/menu-item/link-item.js +0 -22
- package/dist/cjs/internal/styles/menu-item/skeleton-heading-item.js +0 -50
- package/dist/cjs/internal/styles/menu-item/skeleton-item.js +0 -98
- package/dist/cjs/internal/styles/menu-section/menu-group.js +0 -24
- package/dist/cjs/internal/styles/menu-section/section.js +0 -83
- package/dist/es2019/internal/components/base-item.js +0 -51
- package/dist/es2019/internal/styles/menu-item/base-item.js +0 -122
- package/dist/es2019/internal/styles/menu-item/button-item.js +0 -9
- package/dist/es2019/internal/styles/menu-item/custom-item.js +0 -5
- package/dist/es2019/internal/styles/menu-item/heading-item.js +0 -16
- package/dist/es2019/internal/styles/menu-item/link-item.js +0 -3
- package/dist/es2019/internal/styles/menu-item/skeleton-heading-item.js +0 -25
- package/dist/es2019/internal/styles/menu-item/skeleton-item.js +0 -75
- package/dist/es2019/internal/styles/menu-section/menu-group.js +0 -14
- package/dist/es2019/internal/styles/menu-section/section.js +0 -62
- package/dist/esm/internal/components/base-item.js +0 -55
- package/dist/esm/internal/styles/menu-item/base-item.js +0 -124
- package/dist/esm/internal/styles/menu-item/button-item.js +0 -16
- package/dist/esm/internal/styles/menu-item/custom-item.js +0 -12
- package/dist/esm/internal/styles/menu-item/heading-item.js +0 -16
- package/dist/esm/internal/styles/menu-item/link-item.js +0 -10
- package/dist/esm/internal/styles/menu-item/skeleton-heading-item.js +0 -33
- package/dist/esm/internal/styles/menu-item/skeleton-item.js +0 -81
- package/dist/esm/internal/styles/menu-section/menu-group.js +0 -15
- package/dist/esm/internal/styles/menu-section/section.js +0 -67
- package/dist/types/internal/components/base-item.d.ts +0 -9
- package/dist/types/internal/styles/menu-item/base-item.d.ts +0 -23
- package/dist/types/internal/styles/menu-item/button-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-item/custom-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-item/heading-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-item/link-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-item/skeleton-heading-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-item/skeleton-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-section/menu-group.d.ts +0 -3
- package/dist/types/internal/styles/menu-section/section.d.ts +0 -2
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { B100, N20, N200, N30 } from '@atlaskit/theme/colors';
|
|
2
|
-
import { fontSize as fontSizeFn, gridSize as gridSizeFn } from '@atlaskit/theme/constants';
|
|
3
|
-
import { headingSizes } from '@atlaskit/theme/typography';
|
|
4
|
-
import { token } from '@atlaskit/tokens';
|
|
5
|
-
const gridSize = gridSizeFn();
|
|
6
|
-
const fontSize = fontSizeFn();
|
|
7
|
-
const itemTopBottomPadding = gridSize;
|
|
8
|
-
const itemSidePadding = gridSize * 2.5;
|
|
9
|
-
const itemElemSpacing = gridSize * 1.5;
|
|
10
|
-
const itemDescriptionSpacing = gridSize * 0.375;
|
|
11
|
-
const itemMinHeight = gridSize * 5;
|
|
12
|
-
const itemContentMinHeight = itemMinHeight - itemTopBottomPadding * 2;
|
|
13
|
-
const disabledStyles = {
|
|
14
|
-
cursor: 'not-allowed',
|
|
15
|
-
'&, &:hover, &:focus, &:active': {
|
|
16
|
-
backgroundColor: 'transparent',
|
|
17
|
-
color: token('color.text.disabled', N200)
|
|
18
|
-
},
|
|
19
|
-
'&:focus': {
|
|
20
|
-
boxShadow: 'none'
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const selectedStyles = {
|
|
24
|
-
backgroundColor: token('color.background.selected.resting', N20),
|
|
25
|
-
// Suppress the need for a fallback as selected color isn't used in the non-tokens world.
|
|
26
|
-
// When removing fallbacks make sure to remove this supression.
|
|
27
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
28
|
-
color: token('color.text.selected'),
|
|
29
|
-
':hover': {
|
|
30
|
-
backgroundColor: token('color.background.selected.hover', N20),
|
|
31
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
32
|
-
color: token('color.text.selected')
|
|
33
|
-
},
|
|
34
|
-
':active': {
|
|
35
|
-
backgroundColor: token('color.background.selected.pressed', N30),
|
|
36
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
37
|
-
color: token('color.text.selected')
|
|
38
|
-
},
|
|
39
|
-
':visited': {
|
|
40
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
41
|
-
color: token('color.text.selected')
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
export const baseItemCSS = (isDisabled, isSelected) => ({
|
|
45
|
-
padding: `${itemTopBottomPadding}px ${itemSidePadding}px`,
|
|
46
|
-
cursor: 'pointer',
|
|
47
|
-
fontSize: fontSize,
|
|
48
|
-
// IE11 fix - wrapping container needs to be flex as well for vertical centering to work.
|
|
49
|
-
display: 'flex',
|
|
50
|
-
boxSizing: 'border-box',
|
|
51
|
-
color: 'currentColor',
|
|
52
|
-
userSelect: 'none',
|
|
53
|
-
'&:visited': {
|
|
54
|
-
color: 'currentColor'
|
|
55
|
-
},
|
|
56
|
-
'&:hover': {
|
|
57
|
-
color: 'currentColor',
|
|
58
|
-
backgroundColor: token('color.background.transparentNeutral.hover', N20),
|
|
59
|
-
textDecoration: 'none'
|
|
60
|
-
},
|
|
61
|
-
'&:focus': {
|
|
62
|
-
outline: 'none',
|
|
63
|
-
boxShadow: `${token('color.border.focus', B100)} 0 0 0 2px inset`
|
|
64
|
-
},
|
|
65
|
-
'&:active': {
|
|
66
|
-
boxShadow: 'none',
|
|
67
|
-
color: 'currentColor',
|
|
68
|
-
backgroundColor: token('color.background.transparentNeutral.pressed', N30)
|
|
69
|
-
},
|
|
70
|
-
'::-moz-focus-inner': {
|
|
71
|
-
border: 0
|
|
72
|
-
},
|
|
73
|
-
...(isSelected && selectedStyles),
|
|
74
|
-
...(isDisabled && disabledStyles)
|
|
75
|
-
});
|
|
76
|
-
export const contentCSS = {
|
|
77
|
-
flexGrow: 1,
|
|
78
|
-
textAlign: 'left',
|
|
79
|
-
overflow: 'hidden',
|
|
80
|
-
outline: 'none',
|
|
81
|
-
display: 'flex',
|
|
82
|
-
flexDirection: 'column',
|
|
83
|
-
// Fix - avoid clipped text descenders when using standard 16px line-height
|
|
84
|
-
lineHeight: 1.22
|
|
85
|
-
};
|
|
86
|
-
export const truncateCSS = {
|
|
87
|
-
display: 'block',
|
|
88
|
-
overflow: 'hidden',
|
|
89
|
-
textOverflow: 'ellipsis',
|
|
90
|
-
whiteSpace: 'nowrap'
|
|
91
|
-
};
|
|
92
|
-
export const wrapTextCSS = {
|
|
93
|
-
wordBreak: 'break-word'
|
|
94
|
-
};
|
|
95
|
-
export const elemBeforeCSS = {
|
|
96
|
-
display: 'flex',
|
|
97
|
-
flexShrink: 0,
|
|
98
|
-
marginRight: itemElemSpacing
|
|
99
|
-
};
|
|
100
|
-
export const elemAfterCSS = {
|
|
101
|
-
display: 'flex',
|
|
102
|
-
flexShrink: 0,
|
|
103
|
-
marginLeft: itemElemSpacing
|
|
104
|
-
};
|
|
105
|
-
const descriptionBaseCSS = {
|
|
106
|
-
color: token('color.text.lowEmphasis', N200),
|
|
107
|
-
marginTop: itemDescriptionSpacing,
|
|
108
|
-
fontSize: headingSizes.h200.size
|
|
109
|
-
};
|
|
110
|
-
export const wrapDescriptionCSS = { ...wrapTextCSS,
|
|
111
|
-
...descriptionBaseCSS
|
|
112
|
-
};
|
|
113
|
-
export const descriptionCSS = { ...truncateCSS,
|
|
114
|
-
...descriptionBaseCSS
|
|
115
|
-
};
|
|
116
|
-
export const contentCSSWrapper = {
|
|
117
|
-
display: 'flex',
|
|
118
|
-
minHeight: itemContentMinHeight,
|
|
119
|
-
alignItems: 'center',
|
|
120
|
-
// IE11 fix - used with flex above to fix vertical centering.
|
|
121
|
-
width: '100%'
|
|
122
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { N200 } from '@atlaskit/theme/colors';
|
|
2
|
-
import { gridSize as gridSizeFn } from '@atlaskit/theme/constants';
|
|
3
|
-
import { headingSizes } from '@atlaskit/theme/typography';
|
|
4
|
-
import { token } from '@atlaskit/tokens';
|
|
5
|
-
const gridSize = gridSizeFn();
|
|
6
|
-
const itemSidePadding = gridSize * 2.5;
|
|
7
|
-
const itemHeadingContentHeight = headingSizes.h100.lineHeight;
|
|
8
|
-
const itemHeadingFontSize = headingSizes.h100.size;
|
|
9
|
-
export const headingItemCSS = {
|
|
10
|
-
textTransform: 'uppercase',
|
|
11
|
-
fontSize: itemHeadingFontSize,
|
|
12
|
-
lineHeight: itemHeadingContentHeight / itemHeadingFontSize,
|
|
13
|
-
fontWeight: 700,
|
|
14
|
-
color: token('color.text.lowEmphasis', N200),
|
|
15
|
-
padding: `0 ${itemSidePadding}px`
|
|
16
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { keyframes } from '@emotion/core';
|
|
2
|
-
import { skeleton as skeletonColorFn } from '@atlaskit/theme/colors';
|
|
3
|
-
import { gridSize as gridSizeFn, skeletonShimmer } from '@atlaskit/theme/constants';
|
|
4
|
-
import { token } from '@atlaskit/tokens';
|
|
5
|
-
import { headingItemCSS } from './heading-item';
|
|
6
|
-
const gridSize = gridSizeFn();
|
|
7
|
-
const skeletonTextBorderRadius = 100;
|
|
8
|
-
const skeletonHeadingHeight = gridSize;
|
|
9
|
-
const skeletonColor = token('color.background.subtleNeutral.resting', skeletonColorFn());
|
|
10
|
-
const shimmer = skeletonShimmer();
|
|
11
|
-
const shimmerKeyframes = keyframes(shimmer.keyframes);
|
|
12
|
-
export const skeletonHeadingItemCSS = (width, isShimmering) => ({ ...headingItemCSS,
|
|
13
|
-
'&::after': {
|
|
14
|
-
// This renders the skeleton heading "text".
|
|
15
|
-
backgroundColor: skeletonColor,
|
|
16
|
-
...(isShimmering && { ...shimmer.css,
|
|
17
|
-
animationName: `${shimmerKeyframes}`
|
|
18
|
-
}),
|
|
19
|
-
height: skeletonHeadingHeight,
|
|
20
|
-
width: width || '30%',
|
|
21
|
-
borderRadius: skeletonTextBorderRadius,
|
|
22
|
-
display: 'block',
|
|
23
|
-
content: '""'
|
|
24
|
-
}
|
|
25
|
-
});
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { keyframes } from '@emotion/core';
|
|
2
|
-
import { skeleton as skeletonColorFn } from '@atlaskit/theme/colors';
|
|
3
|
-
import { borderRadius as borderRadiusFn, gridSize as gridSizeFn, skeletonShimmer } from '@atlaskit/theme/constants';
|
|
4
|
-
import { token } from '@atlaskit/tokens';
|
|
5
|
-
import { baseItemCSS } from './base-item';
|
|
6
|
-
const gridSize = gridSizeFn();
|
|
7
|
-
const borderRadius = borderRadiusFn();
|
|
8
|
-
const itemElemSpacing = gridSize * 1.5;
|
|
9
|
-
const itemExpectedElemSize = gridSize * 3;
|
|
10
|
-
const itemMinHeight = gridSize * 5;
|
|
11
|
-
const skeletonItemElemSize = gridSize * 2.5;
|
|
12
|
-
const itemElemSkeletonOffset = (itemExpectedElemSize - skeletonItemElemSize) / 2;
|
|
13
|
-
const skeletonTextBorderRadius = 100;
|
|
14
|
-
const skeletonContentHeight = 9;
|
|
15
|
-
const skeletonColor = token('color.background.subtleNeutral.resting', skeletonColorFn());
|
|
16
|
-
const shimmer = skeletonShimmer();
|
|
17
|
-
const shimmerKeyframes = keyframes(shimmer.keyframes);
|
|
18
|
-
export const skeletonItemCSS = (hasAvatar, hasIcon, width, isShimmering) => ({ ...baseItemCSS(false, false),
|
|
19
|
-
pointerEvents: 'none',
|
|
20
|
-
display: 'flex',
|
|
21
|
-
alignItems: 'center',
|
|
22
|
-
minHeight: itemMinHeight,
|
|
23
|
-
// Stagger alternate skeleton items if no width is passed
|
|
24
|
-
...(!width && {
|
|
25
|
-
'&:nth-child(1n)::after': {
|
|
26
|
-
flexBasis: '70%'
|
|
27
|
-
},
|
|
28
|
-
'&:nth-child(2n)::after': {
|
|
29
|
-
flexBasis: '50%'
|
|
30
|
-
},
|
|
31
|
-
'&:nth-child(3n)::after': {
|
|
32
|
-
flexBasis: '60%'
|
|
33
|
-
},
|
|
34
|
-
'&:nth-child(4n)::after': {
|
|
35
|
-
flexBasis: '90%'
|
|
36
|
-
},
|
|
37
|
-
'&:nth-child(5n)::after': {
|
|
38
|
-
flexBasis: '35%'
|
|
39
|
-
},
|
|
40
|
-
'&:nth-child(6n)::after': {
|
|
41
|
-
flexBasis: '77%'
|
|
42
|
-
}
|
|
43
|
-
}),
|
|
44
|
-
...((hasAvatar || hasIcon) && {
|
|
45
|
-
'&::before': {
|
|
46
|
-
// This will render a skeleton in the "elemBefore" position.
|
|
47
|
-
content: '""',
|
|
48
|
-
backgroundColor: skeletonColor,
|
|
49
|
-
...(isShimmering && { ...shimmer.css,
|
|
50
|
-
animationName: `${shimmerKeyframes}`
|
|
51
|
-
}),
|
|
52
|
-
marginRight: itemElemSpacing + itemElemSkeletonOffset,
|
|
53
|
-
width: skeletonItemElemSize,
|
|
54
|
-
height: skeletonItemElemSize,
|
|
55
|
-
marginLeft: itemElemSkeletonOffset,
|
|
56
|
-
borderRadius: hasAvatar ? '100%' : borderRadius,
|
|
57
|
-
flexShrink: 0
|
|
58
|
-
}
|
|
59
|
-
}),
|
|
60
|
-
'&::after': {
|
|
61
|
-
// This will render the skeleton "text".
|
|
62
|
-
content: '""',
|
|
63
|
-
backgroundColor: skeletonColor,
|
|
64
|
-
...(isShimmering && { ...shimmer.css,
|
|
65
|
-
animationName: `${shimmerKeyframes}`
|
|
66
|
-
}),
|
|
67
|
-
// This is a little bespoke but we need to push everything down 1px
|
|
68
|
-
// because the skeleton content should align to the bottom of the text.
|
|
69
|
-
// Confirm VR test failures before accepting a change.
|
|
70
|
-
marginTop: 1,
|
|
71
|
-
height: skeletonContentHeight,
|
|
72
|
-
borderRadius: skeletonTextBorderRadius,
|
|
73
|
-
flexBasis: width || '100%'
|
|
74
|
-
}
|
|
75
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { N30A } from '@atlaskit/theme/colors';
|
|
2
|
-
import { gridSize as gridSizeFn } from '@atlaskit/theme/constants';
|
|
3
|
-
import { headingSizes } from '@atlaskit/theme/typography';
|
|
4
|
-
import { token } from '@atlaskit/tokens';
|
|
5
|
-
const gridSize = gridSizeFn();
|
|
6
|
-
const itemHeadingTopMargin = gridSize * 2.5;
|
|
7
|
-
const itemHeadingBottomMargin = gridSize * 0.75; // Skeleton content is slightly shorter than the real content.
|
|
8
|
-
// Because of that we slightly increase the top margin to offset this so the
|
|
9
|
-
// containing size both real and skeleton always equal approx 30px.
|
|
10
|
-
|
|
11
|
-
const itemHeadingContentHeight = headingSizes.h100.lineHeight;
|
|
12
|
-
const skeletonHeadingHeight = gridSize;
|
|
13
|
-
const skeletonHeadingMarginOffset = 3;
|
|
14
|
-
const skeletonHeadingTopMargin = itemHeadingTopMargin + (itemHeadingContentHeight - skeletonHeadingHeight) - skeletonHeadingMarginOffset; // We want to move the entire body up by 3px without affecting the height of the skeleton container.
|
|
15
|
-
|
|
16
|
-
const skeletonHeadingBottomMargin = itemHeadingBottomMargin + skeletonHeadingMarginOffset;
|
|
17
|
-
const sectionPaddingTopBottom = gridSize * 0.75;
|
|
18
|
-
const VAR_SEPARATOR_COLOR = '--ds-menu-seperator-color';
|
|
19
|
-
export const sectionCSS = (isScrollable, hasSeparator) => {
|
|
20
|
-
return {
|
|
21
|
-
'&:before, &:after': {
|
|
22
|
-
content: '" "',
|
|
23
|
-
display: 'block',
|
|
24
|
-
height: sectionPaddingTopBottom
|
|
25
|
-
},
|
|
26
|
-
'& [data-ds--menu--heading-item]': {
|
|
27
|
-
'&:first-of-type': {
|
|
28
|
-
marginTop: itemHeadingTopMargin - sectionPaddingTopBottom
|
|
29
|
-
},
|
|
30
|
-
marginTop: itemHeadingTopMargin,
|
|
31
|
-
marginBottom: itemHeadingBottomMargin
|
|
32
|
-
},
|
|
33
|
-
'& [data-ds--menu--skeleton-heading-item]': {
|
|
34
|
-
'&:first-of-type': {
|
|
35
|
-
marginTop: skeletonHeadingTopMargin - sectionPaddingTopBottom
|
|
36
|
-
},
|
|
37
|
-
marginTop: skeletonHeadingTopMargin,
|
|
38
|
-
marginBottom: skeletonHeadingBottomMargin
|
|
39
|
-
},
|
|
40
|
-
...(isScrollable ? {
|
|
41
|
-
flexShrink: 1,
|
|
42
|
-
overflow: 'auto'
|
|
43
|
-
} : {
|
|
44
|
-
flexShrink: 0
|
|
45
|
-
}),
|
|
46
|
-
...(hasSeparator ? {
|
|
47
|
-
borderTop: `2px solid var(${VAR_SEPARATOR_COLOR}, ${token('color.border.neutral', N30A)})`
|
|
48
|
-
} : {
|
|
49
|
-
// this is to ensure that adjacent sections without separators don't get additional margins.
|
|
50
|
-
'[data-section] + &': {
|
|
51
|
-
marginTop: -6
|
|
52
|
-
}
|
|
53
|
-
}),
|
|
54
|
-
'&:focus': {
|
|
55
|
-
// NOTE: Firefox allows elements that have "overflow: auto" to gain focus (as if it had tab-index="0")
|
|
56
|
-
// We have made a deliberate choice to leave this behaviour as is.
|
|
57
|
-
// This makes the outline go inside by 1px so it can actually be displayed
|
|
58
|
-
// else it gets cut off from the overflow: scroll from the parent menu group.
|
|
59
|
-
outlineOffset: -1
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { memo } from 'react';
|
|
3
|
-
import { ClassNames, jsx } from '@emotion/core';
|
|
4
|
-
import { contentCSS, contentCSSWrapper, descriptionCSS, elemAfterCSS, elemBeforeCSS, truncateCSS, wrapDescriptionCSS, wrapTextCSS } from '../styles/menu-item/base-item';
|
|
5
|
-
|
|
6
|
-
var defaultRender = function defaultRender(Component, props) {
|
|
7
|
-
return jsx(Component, props);
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* __Base item__
|
|
11
|
-
*
|
|
12
|
-
* A base item should be composed for all item experiences.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var BaseItem = /*#__PURE__*/memo(function (_ref) {
|
|
17
|
-
var children = _ref.children,
|
|
18
|
-
description = _ref.description,
|
|
19
|
-
iconAfter = _ref.iconAfter,
|
|
20
|
-
iconBefore = _ref.iconBefore,
|
|
21
|
-
overrides = _ref.overrides,
|
|
22
|
-
_ref$shouldTitleWrap = _ref.shouldTitleWrap,
|
|
23
|
-
shouldTitleWrap = _ref$shouldTitleWrap === void 0 ? false : _ref$shouldTitleWrap,
|
|
24
|
-
_ref$shouldDescriptio = _ref.shouldDescriptionWrap,
|
|
25
|
-
shouldDescriptionWrap = _ref$shouldDescriptio === void 0 ? false : _ref$shouldDescriptio;
|
|
26
|
-
var renderTitle = overrides && overrides.Title && overrides.Title.render || defaultRender;
|
|
27
|
-
return (// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
28
|
-
jsx("div", {
|
|
29
|
-
css: contentCSSWrapper
|
|
30
|
-
}, iconBefore && // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
31
|
-
jsx("span", {
|
|
32
|
-
"data-item-elem-before": true,
|
|
33
|
-
css: elemBeforeCSS
|
|
34
|
-
}, iconBefore), children && // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
35
|
-
jsx("span", {
|
|
36
|
-
css: contentCSS
|
|
37
|
-
}, jsx(ClassNames, null, function (_ref2) {
|
|
38
|
-
var css = _ref2.css;
|
|
39
|
-
return renderTitle('span', {
|
|
40
|
-
children: children,
|
|
41
|
-
className: css(shouldTitleWrap ? wrapTextCSS : truncateCSS),
|
|
42
|
-
'data-item-title': true
|
|
43
|
-
});
|
|
44
|
-
}), description && jsx("span", {
|
|
45
|
-
"data-item-description": true,
|
|
46
|
-
css: // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
47
|
-
shouldDescriptionWrap ? wrapDescriptionCSS : descriptionCSS
|
|
48
|
-
}, description)), iconAfter && // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
49
|
-
jsx("span", {
|
|
50
|
-
"data-item-elem-after": true,
|
|
51
|
-
css: elemAfterCSS
|
|
52
|
-
}, iconAfter))
|
|
53
|
-
);
|
|
54
|
-
});
|
|
55
|
-
export default BaseItem;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
-
|
|
7
|
-
import { B100, N20, N200, N30 } from '@atlaskit/theme/colors';
|
|
8
|
-
import { fontSize as fontSizeFn, gridSize as gridSizeFn } from '@atlaskit/theme/constants';
|
|
9
|
-
import { headingSizes } from '@atlaskit/theme/typography';
|
|
10
|
-
import { token } from '@atlaskit/tokens';
|
|
11
|
-
var gridSize = gridSizeFn();
|
|
12
|
-
var fontSize = fontSizeFn();
|
|
13
|
-
var itemTopBottomPadding = gridSize;
|
|
14
|
-
var itemSidePadding = gridSize * 2.5;
|
|
15
|
-
var itemElemSpacing = gridSize * 1.5;
|
|
16
|
-
var itemDescriptionSpacing = gridSize * 0.375;
|
|
17
|
-
var itemMinHeight = gridSize * 5;
|
|
18
|
-
var itemContentMinHeight = itemMinHeight - itemTopBottomPadding * 2;
|
|
19
|
-
var disabledStyles = {
|
|
20
|
-
cursor: 'not-allowed',
|
|
21
|
-
'&, &:hover, &:focus, &:active': {
|
|
22
|
-
backgroundColor: 'transparent',
|
|
23
|
-
color: token('color.text.disabled', N200)
|
|
24
|
-
},
|
|
25
|
-
'&:focus': {
|
|
26
|
-
boxShadow: 'none'
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var selectedStyles = {
|
|
30
|
-
backgroundColor: token('color.background.selected.resting', N20),
|
|
31
|
-
// Suppress the need for a fallback as selected color isn't used in the non-tokens world.
|
|
32
|
-
// When removing fallbacks make sure to remove this supression.
|
|
33
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
34
|
-
color: token('color.text.selected'),
|
|
35
|
-
':hover': {
|
|
36
|
-
backgroundColor: token('color.background.selected.hover', N20),
|
|
37
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
38
|
-
color: token('color.text.selected')
|
|
39
|
-
},
|
|
40
|
-
':active': {
|
|
41
|
-
backgroundColor: token('color.background.selected.pressed', N30),
|
|
42
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
43
|
-
color: token('color.text.selected')
|
|
44
|
-
},
|
|
45
|
-
':visited': {
|
|
46
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
47
|
-
color: token('color.text.selected')
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
export var baseItemCSS = function baseItemCSS(isDisabled, isSelected) {
|
|
51
|
-
return _objectSpread(_objectSpread({
|
|
52
|
-
padding: "".concat(itemTopBottomPadding, "px ").concat(itemSidePadding, "px"),
|
|
53
|
-
cursor: 'pointer',
|
|
54
|
-
fontSize: fontSize,
|
|
55
|
-
// IE11 fix - wrapping container needs to be flex as well for vertical centering to work.
|
|
56
|
-
display: 'flex',
|
|
57
|
-
boxSizing: 'border-box',
|
|
58
|
-
color: 'currentColor',
|
|
59
|
-
userSelect: 'none',
|
|
60
|
-
'&:visited': {
|
|
61
|
-
color: 'currentColor'
|
|
62
|
-
},
|
|
63
|
-
'&:hover': {
|
|
64
|
-
color: 'currentColor',
|
|
65
|
-
backgroundColor: token('color.background.transparentNeutral.hover', N20),
|
|
66
|
-
textDecoration: 'none'
|
|
67
|
-
},
|
|
68
|
-
'&:focus': {
|
|
69
|
-
outline: 'none',
|
|
70
|
-
boxShadow: "".concat(token('color.border.focus', B100), " 0 0 0 2px inset")
|
|
71
|
-
},
|
|
72
|
-
'&:active': {
|
|
73
|
-
boxShadow: 'none',
|
|
74
|
-
color: 'currentColor',
|
|
75
|
-
backgroundColor: token('color.background.transparentNeutral.pressed', N30)
|
|
76
|
-
},
|
|
77
|
-
'::-moz-focus-inner': {
|
|
78
|
-
border: 0
|
|
79
|
-
}
|
|
80
|
-
}, isSelected && selectedStyles), isDisabled && disabledStyles);
|
|
81
|
-
};
|
|
82
|
-
export var contentCSS = {
|
|
83
|
-
flexGrow: 1,
|
|
84
|
-
textAlign: 'left',
|
|
85
|
-
overflow: 'hidden',
|
|
86
|
-
outline: 'none',
|
|
87
|
-
display: 'flex',
|
|
88
|
-
flexDirection: 'column',
|
|
89
|
-
// Fix - avoid clipped text descenders when using standard 16px line-height
|
|
90
|
-
lineHeight: 1.22
|
|
91
|
-
};
|
|
92
|
-
export var truncateCSS = {
|
|
93
|
-
display: 'block',
|
|
94
|
-
overflow: 'hidden',
|
|
95
|
-
textOverflow: 'ellipsis',
|
|
96
|
-
whiteSpace: 'nowrap'
|
|
97
|
-
};
|
|
98
|
-
export var wrapTextCSS = {
|
|
99
|
-
wordBreak: 'break-word'
|
|
100
|
-
};
|
|
101
|
-
export var elemBeforeCSS = {
|
|
102
|
-
display: 'flex',
|
|
103
|
-
flexShrink: 0,
|
|
104
|
-
marginRight: itemElemSpacing
|
|
105
|
-
};
|
|
106
|
-
export var elemAfterCSS = {
|
|
107
|
-
display: 'flex',
|
|
108
|
-
flexShrink: 0,
|
|
109
|
-
marginLeft: itemElemSpacing
|
|
110
|
-
};
|
|
111
|
-
var descriptionBaseCSS = {
|
|
112
|
-
color: token('color.text.lowEmphasis', N200),
|
|
113
|
-
marginTop: itemDescriptionSpacing,
|
|
114
|
-
fontSize: headingSizes.h200.size
|
|
115
|
-
};
|
|
116
|
-
export var wrapDescriptionCSS = _objectSpread(_objectSpread({}, wrapTextCSS), descriptionBaseCSS);
|
|
117
|
-
export var descriptionCSS = _objectSpread(_objectSpread({}, truncateCSS), descriptionBaseCSS);
|
|
118
|
-
export var contentCSSWrapper = {
|
|
119
|
-
display: 'flex',
|
|
120
|
-
minHeight: itemContentMinHeight,
|
|
121
|
-
alignItems: 'center',
|
|
122
|
-
// IE11 fix - used with flex above to fix vertical centering.
|
|
123
|
-
width: '100%'
|
|
124
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
-
|
|
7
|
-
import { baseItemCSS } from './base-item';
|
|
8
|
-
export var buttonItemCSS = function buttonItemCSS(isDisabled, isSelected) {
|
|
9
|
-
return _objectSpread({
|
|
10
|
-
backgroundColor: 'transparent',
|
|
11
|
-
border: 0,
|
|
12
|
-
outline: 0,
|
|
13
|
-
margin: 0,
|
|
14
|
-
width: '100%'
|
|
15
|
-
}, baseItemCSS(isDisabled, isSelected));
|
|
16
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
-
|
|
7
|
-
import { baseItemCSS } from './base-item';
|
|
8
|
-
export var customItemCSS = function customItemCSS(isDisabled, isSelected) {
|
|
9
|
-
return _objectSpread({
|
|
10
|
-
color: 'currentColor'
|
|
11
|
-
}, baseItemCSS(isDisabled, isSelected));
|
|
12
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { N200 } from '@atlaskit/theme/colors';
|
|
2
|
-
import { gridSize as gridSizeFn } from '@atlaskit/theme/constants';
|
|
3
|
-
import { headingSizes } from '@atlaskit/theme/typography';
|
|
4
|
-
import { token } from '@atlaskit/tokens';
|
|
5
|
-
var gridSize = gridSizeFn();
|
|
6
|
-
var itemSidePadding = gridSize * 2.5;
|
|
7
|
-
var itemHeadingContentHeight = headingSizes.h100.lineHeight;
|
|
8
|
-
var itemHeadingFontSize = headingSizes.h100.size;
|
|
9
|
-
export var headingItemCSS = {
|
|
10
|
-
textTransform: 'uppercase',
|
|
11
|
-
fontSize: itemHeadingFontSize,
|
|
12
|
-
lineHeight: itemHeadingContentHeight / itemHeadingFontSize,
|
|
13
|
-
fontWeight: 700,
|
|
14
|
-
color: token('color.text.lowEmphasis', N200),
|
|
15
|
-
padding: "0 ".concat(itemSidePadding, "px")
|
|
16
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
-
|
|
7
|
-
import { baseItemCSS } from './base-item';
|
|
8
|
-
export var linkItemCSS = function linkItemCSS(isDisabled, isSelected) {
|
|
9
|
-
return _objectSpread({}, baseItemCSS(isDisabled, isSelected));
|
|
10
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
-
|
|
7
|
-
import { keyframes } from '@emotion/core';
|
|
8
|
-
import { skeleton as skeletonColorFn } from '@atlaskit/theme/colors';
|
|
9
|
-
import { gridSize as gridSizeFn, skeletonShimmer } from '@atlaskit/theme/constants';
|
|
10
|
-
import { token } from '@atlaskit/tokens';
|
|
11
|
-
import { headingItemCSS } from './heading-item';
|
|
12
|
-
var gridSize = gridSizeFn();
|
|
13
|
-
var skeletonTextBorderRadius = 100;
|
|
14
|
-
var skeletonHeadingHeight = gridSize;
|
|
15
|
-
var skeletonColor = token('color.background.subtleNeutral.resting', skeletonColorFn());
|
|
16
|
-
var shimmer = skeletonShimmer();
|
|
17
|
-
var shimmerKeyframes = keyframes(shimmer.keyframes);
|
|
18
|
-
export var skeletonHeadingItemCSS = function skeletonHeadingItemCSS(width, isShimmering) {
|
|
19
|
-
return _objectSpread(_objectSpread({}, headingItemCSS), {}, {
|
|
20
|
-
'&::after': _objectSpread(_objectSpread({
|
|
21
|
-
// This renders the skeleton heading "text".
|
|
22
|
-
backgroundColor: skeletonColor
|
|
23
|
-
}, isShimmering && _objectSpread(_objectSpread({}, shimmer.css), {}, {
|
|
24
|
-
animationName: "".concat(shimmerKeyframes)
|
|
25
|
-
})), {}, {
|
|
26
|
-
height: skeletonHeadingHeight,
|
|
27
|
-
width: width || '30%',
|
|
28
|
-
borderRadius: skeletonTextBorderRadius,
|
|
29
|
-
display: 'block',
|
|
30
|
-
content: '""'
|
|
31
|
-
})
|
|
32
|
-
});
|
|
33
|
-
};
|