@superdispatch/ui 0.21.6 → 0.21.13
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/.babelrc.js +5 -0
- package/.turbo/turbo-version.log +28 -0
- package/package.json +65 -39
- package/pkg/README.md +30 -0
- package/{dist-node → pkg/dist-node}/index.js +2 -1
- package/pkg/dist-node/index.js.map +1 -0
- package/{dist-src → pkg/dist-src}/number-field/NumberField.js +2 -1
- package/{dist-types → pkg/dist-types}/index.d.ts +364 -364
- package/{dist-web → pkg/dist-web}/index.js +2 -1
- package/pkg/dist-web/index.js.map +1 -0
- package/pkg/package.json +39 -0
- package/playroom.ts +31 -0
- package/src/__tests__/index.spec.ts +134 -0
- package/src/adaptive-toolbar/AdaptiveToolbar.stories.tsx +50 -0
- package/src/adaptive-toolbar/AdaptiveToolbar.tsx +199 -0
- package/src/adaptive-toolbar/__tests__/AdaptiveToolbar.spec.tsx +11 -0
- package/src/adaptive-vertical-toolbar/AdaptiveVerticalToolbar.stories.tsx +49 -0
- package/src/adaptive-vertical-toolbar/AdaptiveVerticalToolbar.tsx +171 -0
- package/src/app-bar/AppBar.stories.tsx +62 -0
- package/src/app-bar/AppBarOverrides.ts +9 -0
- package/src/app-bar/__tests__/AppBar.spec.tsx +86 -0
- package/src/autocomplete/Autocomplete.stories.tsx +76 -0
- package/src/autocomplete/AutocompleteOverrides.tsx +58 -0
- package/src/autocomplete/__tests__/Autocomplete.spec.tsx +323 -0
- package/src/avatar/Avatar.stories.tsx +17 -0
- package/src/avatar/AvatarOverrides.ts +24 -0
- package/src/avatar/__tests__/Avatar.spec.tsx +71 -0
- package/src/avatar-button/AvatarButton.stories.tsx +153 -0
- package/src/avatar-button/AvatarButton.tsx +223 -0
- package/src/avatar-button/__tests__/AvatarButton.spec.tsx +126 -0
- package/src/button/Button.tsx +51 -0
- package/src/button/ButtonOverrides.ts +375 -0
- package/src/button/__tests__/Button.spec.tsx +599 -0
- package/src/card/Card.stories.tsx +39 -0
- package/src/card/CardOverrides.ts +9 -0
- package/src/card/__tests__/Card.spec.tsx +68 -0
- package/src/card-button/CardButton.stories.tsx +36 -0
- package/src/card-button/CardButton.tsx +202 -0
- package/src/card-button/__tests__/CardButton.spec.tsx +95 -0
- package/src/checkbox/CheckboxField.stories.tsx +61 -0
- package/src/checkbox/CheckboxField.tsx +56 -0
- package/src/checkbox/CheckboxGroudField.tsx +53 -0
- package/src/checkbox/CheckboxOverrides.tsx +55 -0
- package/src/checkbox/__tests__/Checkbox.spec.tsx +105 -0
- package/src/chip/Chip.stories.tsx +26 -0
- package/src/chip/ChipOverrides.tsx +111 -0
- package/src/chip/__tests__/Chip.spec.tsx +308 -0
- package/src/columns/Column.tsx +124 -0
- package/src/columns/Columns.stories.tsx +426 -0
- package/src/columns/Columns.tsx +76 -0
- package/src/description-list/DescriptionList.spec.tsx +137 -0
- package/src/description-list/DescriptionList.stories.tsx +148 -0
- package/src/description-list/DescriptionList.tsx +170 -0
- package/src/dialog/Dialog.playroom.tsx +24 -0
- package/src/dialog/Dialog.stories.tsx +60 -0
- package/src/dialog/DialogOverrides.ts +39 -0
- package/src/dialog/__tests__/Dialog.spec.tsx +219 -0
- package/src/drawer/Drawer.playroom.tsx +22 -0
- package/src/drawer/Drawer.stories.tsx +194 -0
- package/src/drawer/DrawerActions.tsx +69 -0
- package/src/drawer/DrawerContent.tsx +30 -0
- package/src/drawer/DrawerList.tsx +60 -0
- package/src/drawer/DrawerOverrides.ts +19 -0
- package/src/drawer/DrawerTitle.tsx +143 -0
- package/src/drawer/__tests__/Drawer.spec.tsx +227 -0
- package/src/dropdown-button/DropdownButton.stories.tsx +15 -0
- package/src/dropdown-button/DropdownButton.tsx +131 -0
- package/src/grid/GridStack.tsx +45 -0
- package/src/grid/InlineGrid.tsx +56 -0
- package/src/icon-button/IconButton.stories.tsx +53 -0
- package/src/icon-button/IconButtonOverrides.ts +32 -0
- package/src/icon-button/__tests__/IconButton.spec.tsx +124 -0
- package/src/index.ts +47 -0
- package/src/info-card/InfoCard.stories.tsx +29 -0
- package/src/info-card/InfoCard.tsx +95 -0
- package/src/info-card/__tests__/InfoCard.spec.tsx +22 -0
- package/src/info-tooltip/InfoTooltip.stories.tsx +77 -0
- package/src/info-tooltip/InfoTooltip.tsx +72 -0
- package/src/info-tooltip/__tests__/InfoTooltip.spec.tsx +166 -0
- package/src/inline/Inline.stories.tsx +135 -0
- package/src/inline/Inline.tsx +144 -0
- package/src/link/Link.stories.tsx +41 -0
- package/src/link/LinkOverrides.ts +43 -0
- package/src/link/__tests__/Link.spec.tsx +98 -0
- package/src/list/ListOverrides.ts +11 -0
- package/src/list/__tests__/List.spec.tsx +182 -0
- package/src/menu/Menu.stories.tsx +35 -0
- package/src/menu/MenuOverrides.ts +17 -0
- package/src/menu/__tests__/Menu.spec.tsx +99 -0
- package/src/number-field/NumberField.stories.tsx +123 -0
- package/src/number-field/NumberField.tsx +98 -0
- package/src/overflow-text/OverflowText.stories.tsx +32 -0
- package/src/overflow-text/OverflowText.tsx +114 -0
- package/src/overflow-text/__tests__/OverflowText.spec.tsx +24 -0
- package/src/pagination/Pagination.stories.tsx +36 -0
- package/src/pagination/PaginationOverrides.ts +47 -0
- package/src/pagination/__tests__/Pagination.spec.tsx +228 -0
- package/src/paper/PaperOverrides.ts +10 -0
- package/src/paper/__tests__/Paper.spec.tsx +155 -0
- package/src/props/AlignProps.ts +22 -0
- package/src/props/CollapseProp.ts +13 -0
- package/src/props/ResponsiveProp.ts +65 -0
- package/src/props/SpaceProp.ts +40 -0
- package/src/radio/RadioField.stories.tsx +42 -0
- package/src/radio/RadioField.tsx +55 -0
- package/src/radio/RadioGroupField.tsx +64 -0
- package/src/radio/RadioOverrides.tsx +51 -0
- package/src/radio/__tests__/Radio.spec.tsx +90 -0
- package/src/responsive/CollapseBreakpoint.ts +21 -0
- package/src/responsive/MinBreakpoint.ts +21 -0
- package/src/responsive/ResponsiveContext.tsx +57 -0
- package/src/snackbar/Snackbar.stories.tsx +196 -0
- package/src/snackbar/Snackbar.tsx +83 -0
- package/src/snackbar/SnackbarContent.tsx +147 -0
- package/src/snackbar/SnackbarOverrides.ts +23 -0
- package/src/snackbar/SnackbarStack.tsx +160 -0
- package/src/snackbar/__tests__/Snackbar.spec.tsx +196 -0
- package/src/stack/Stack.stories.tsx +113 -0
- package/src/stack/Stack.tsx +86 -0
- package/src/svg-icon/SvgIcon.stories.tsx +29 -0
- package/src/svg-icon/SvgIconOverrides.ts +32 -0
- package/src/svg-icon/__tests__/SvgIcon.spec.tsx +67 -0
- package/src/switch/Switch.stories.tsx +60 -0
- package/src/switch/SwitchOverrides.ts +88 -0
- package/src/switch/__tests__/Switch.spec.tsx +204 -0
- package/src/tabs/Tabs.stories.tsx +40 -0
- package/src/tabs/TabsOverrides.ts +45 -0
- package/src/tabs/__tests__/Tabs.spec.tsx +226 -0
- package/src/tag/Tag.stories.tsx +53 -0
- package/src/tag/Tag.tsx +130 -0
- package/src/tag/__tests__/Tag.spec.tsx +82 -0
- package/src/text-field/TextField.stories.tsx +50 -0
- package/src/text-field/TextFieldOverrides.tsx +149 -0
- package/src/text-field/__tests__/TextField.spec.tsx +662 -0
- package/src/theme/Color.ts +117 -0
- package/src/theme/SuperDispatchTheme.ts +3 -0
- package/src/theme/ThemeProvider.tsx +179 -0
- package/src/theme/__tests__/CssBaseline.spec.tsx +49 -0
- package/src/theme/__tests__/ThemeProvider.spec.ts +40 -0
- package/src/theme/__tests__/__snapshots__/ThemeProvider.spec.ts.snap +204 -0
- package/src/tiles/Tiles.stories.tsx +69 -0
- package/src/tiles/Tiles.tsx +163 -0
- package/src/tiles/__tests__/Tiles.spec.tsx +221 -0
- package/src/toolbar/ToolbarOverrides.ts +14 -0
- package/src/toolbar/__tests__/Toolbar.spec.tsx +50 -0
- package/src/tooltip/Tooltip.stories.tsx +32 -0
- package/src/tooltip/TooltipOverrides.ts +34 -0
- package/src/tooltip/__tests__/Tooltip.spec.tsx +182 -0
- package/src/typography/Typography.stories.tsx +132 -0
- package/src/typography/TypographyOverrides.ts +125 -0
- package/src/typography/__tests__/Typography.spec.tsx +253 -0
- package/src/utils/ExitTransitionPlaceholder.tsx +22 -0
- package/src/utils/ResizeObserver.tsx +28 -0
- package/src/utils/VisibilityObserver.tsx +75 -0
- package/src/utils/__tests__/ExitTransitionPlaceholder.spec.tsx +34 -0
- package/src/utils/isEmptyReactNode.ts +11 -0
- package/src/utils/mergeRefs.ts +21 -0
- package/src/utils/renderChildren.ts +10 -0
- package/src/utils/useUID.ts +9 -0
- package/tsconfig.json +19 -0
- package/LICENSE +0 -21
- package/dist-node/index.js.map +0 -1
- package/dist-web/index.js.map +0 -1
- /package/{dist-src → pkg/dist-src}/adaptive-toolbar/AdaptiveToolbar.js +0 -0
- /package/{dist-src → pkg/dist-src}/adaptive-vertical-toolbar/AdaptiveVerticalToolbar.js +0 -0
- /package/{dist-src → pkg/dist-src}/app-bar/AppBarOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/autocomplete/AutocompleteOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/avatar/AvatarOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/avatar-button/AvatarButton.js +0 -0
- /package/{dist-src → pkg/dist-src}/button/Button.js +0 -0
- /package/{dist-src → pkg/dist-src}/button/ButtonOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/card/CardOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/card-button/CardButton.js +0 -0
- /package/{dist-src → pkg/dist-src}/checkbox/CheckboxField.js +0 -0
- /package/{dist-src → pkg/dist-src}/checkbox/CheckboxGroudField.js +0 -0
- /package/{dist-src → pkg/dist-src}/checkbox/CheckboxOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/chip/ChipOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/columns/Column.js +0 -0
- /package/{dist-src → pkg/dist-src}/columns/Columns.js +0 -0
- /package/{dist-src → pkg/dist-src}/description-list/DescriptionList.js +0 -0
- /package/{dist-src → pkg/dist-src}/dialog/DialogOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/drawer/DrawerActions.js +0 -0
- /package/{dist-src → pkg/dist-src}/drawer/DrawerContent.js +0 -0
- /package/{dist-src → pkg/dist-src}/drawer/DrawerList.js +0 -0
- /package/{dist-src → pkg/dist-src}/drawer/DrawerOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/drawer/DrawerTitle.js +0 -0
- /package/{dist-src → pkg/dist-src}/dropdown-button/DropdownButton.js +0 -0
- /package/{dist-src → pkg/dist-src}/grid/GridStack.js +0 -0
- /package/{dist-src → pkg/dist-src}/grid/InlineGrid.js +0 -0
- /package/{dist-src → pkg/dist-src}/icon-button/IconButtonOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/index.js +0 -0
- /package/{dist-src → pkg/dist-src}/info-card/InfoCard.js +0 -0
- /package/{dist-src → pkg/dist-src}/inline/Inline.js +0 -0
- /package/{dist-src → pkg/dist-src}/link/LinkOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/list/ListOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/menu/MenuOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/overflow-text/OverflowText.js +0 -0
- /package/{dist-src → pkg/dist-src}/pagination/PaginationOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/paper/PaperOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/props/AlignProps.js +0 -0
- /package/{dist-src → pkg/dist-src}/props/CollapseProp.js +0 -0
- /package/{dist-src → pkg/dist-src}/props/ResponsiveProp.js +0 -0
- /package/{dist-src → pkg/dist-src}/props/SpaceProp.js +0 -0
- /package/{dist-src → pkg/dist-src}/radio/RadioField.js +0 -0
- /package/{dist-src → pkg/dist-src}/radio/RadioGroupField.js +0 -0
- /package/{dist-src → pkg/dist-src}/radio/RadioOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/responsive/CollapseBreakpoint.js +0 -0
- /package/{dist-src → pkg/dist-src}/responsive/MinBreakpoint.js +0 -0
- /package/{dist-src → pkg/dist-src}/responsive/ResponsiveContext.js +0 -0
- /package/{dist-src → pkg/dist-src}/snackbar/Snackbar.js +0 -0
- /package/{dist-src → pkg/dist-src}/snackbar/SnackbarContent.js +0 -0
- /package/{dist-src → pkg/dist-src}/snackbar/SnackbarOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/snackbar/SnackbarStack.js +0 -0
- /package/{dist-src → pkg/dist-src}/stack/Stack.js +0 -0
- /package/{dist-src → pkg/dist-src}/svg-icon/SvgIconOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/switch/SwitchOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/tabs/TabsOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/tag/Tag.js +0 -0
- /package/{dist-src → pkg/dist-src}/text-field/TextFieldOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/theme/Color.js +0 -0
- /package/{dist-src → pkg/dist-src}/theme/SuperDispatchTheme.js +0 -0
- /package/{dist-src → pkg/dist-src}/theme/ThemeProvider.js +0 -0
- /package/{dist-src → pkg/dist-src}/tiles/Tiles.js +0 -0
- /package/{dist-src → pkg/dist-src}/toolbar/ToolbarOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/tooltip/TooltipOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/typography/TypographyOverrides.js +0 -0
- /package/{dist-src → pkg/dist-src}/utils/ExitTransitionPlaceholder.js +0 -0
- /package/{dist-src → pkg/dist-src}/utils/ResizeObserver.js +0 -0
- /package/{dist-src → pkg/dist-src}/utils/VisibilityObserver.js +0 -0
- /package/{dist-src → pkg/dist-src}/utils/isEmptyReactNode.js +0 -0
- /package/{dist-src → pkg/dist-src}/utils/mergeRefs.js +0 -0
- /package/{dist-src → pkg/dist-src}/utils/renderChildren.js +0 -0
- /package/{dist-src → pkg/dist-src}/utils/useUID.js +0 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { forwardRef, ReactNode } from 'react';
|
|
2
|
+
import flattenChildren from 'react-keyed-flatten-children';
|
|
3
|
+
import styled, { css, SimpleInterpolation } from 'styled-components';
|
|
4
|
+
import {
|
|
5
|
+
HorizontalAlign,
|
|
6
|
+
parseAlignProp,
|
|
7
|
+
VerticalAlign,
|
|
8
|
+
} from '../props/AlignProps';
|
|
9
|
+
import {
|
|
10
|
+
ResponsiveProp,
|
|
11
|
+
ResponsivePropTuple,
|
|
12
|
+
useResponsiveProp,
|
|
13
|
+
} from '../props/ResponsiveProp';
|
|
14
|
+
import { parseSpaceProp, SpaceProp } from '../props/SpaceProp';
|
|
15
|
+
|
|
16
|
+
function inlineRootMixin(
|
|
17
|
+
spaceProp: SpaceProp,
|
|
18
|
+
noWrap: boolean,
|
|
19
|
+
verticalAlign: VerticalAlign,
|
|
20
|
+
horizontalAlign: HorizontalAlign,
|
|
21
|
+
): readonly SimpleInterpolation[] {
|
|
22
|
+
const space = parseSpaceProp(spaceProp);
|
|
23
|
+
|
|
24
|
+
return css`
|
|
25
|
+
&:before {
|
|
26
|
+
margin-top: ${-space - 1}px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
& > div {
|
|
30
|
+
display: flex;
|
|
31
|
+
margin-left: -${space}px;
|
|
32
|
+
flex-wrap: ${noWrap ? 'nowrap' : 'wrap'};
|
|
33
|
+
align-items: ${parseAlignProp(verticalAlign)};
|
|
34
|
+
justify-content: ${parseAlignProp(horizontalAlign)};
|
|
35
|
+
|
|
36
|
+
& > div {
|
|
37
|
+
&:empty {
|
|
38
|
+
display: none;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
min-width: 0;
|
|
42
|
+
flex-shrink: 0;
|
|
43
|
+
max-width: 100%;
|
|
44
|
+
|
|
45
|
+
margin-top: ${space}px;
|
|
46
|
+
margin-left: ${space}px;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface InlineRootProps {
|
|
53
|
+
space: ResponsivePropTuple<SpaceProp>;
|
|
54
|
+
noWrap: ResponsivePropTuple<boolean>;
|
|
55
|
+
verticalAlign: ResponsivePropTuple<VerticalAlign>;
|
|
56
|
+
horizontalAlign: ResponsivePropTuple<HorizontalAlign>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const InlineRoot = styled.div<InlineRootProps>(
|
|
60
|
+
({ theme, space, noWrap, verticalAlign, horizontalAlign }) =>
|
|
61
|
+
css`
|
|
62
|
+
padding-top: 1px;
|
|
63
|
+
|
|
64
|
+
&:before {
|
|
65
|
+
content: '';
|
|
66
|
+
display: block;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
${inlineRootMixin(
|
|
70
|
+
space[0],
|
|
71
|
+
noWrap[0],
|
|
72
|
+
verticalAlign[0],
|
|
73
|
+
horizontalAlign[0],
|
|
74
|
+
)}
|
|
75
|
+
|
|
76
|
+
${theme.breakpoints.up('sm')} {
|
|
77
|
+
${inlineRootMixin(
|
|
78
|
+
space[1],
|
|
79
|
+
noWrap[1],
|
|
80
|
+
verticalAlign[1],
|
|
81
|
+
horizontalAlign[1],
|
|
82
|
+
)}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
${theme.breakpoints.up('md')} {
|
|
86
|
+
${inlineRootMixin(
|
|
87
|
+
space[2],
|
|
88
|
+
noWrap[2],
|
|
89
|
+
verticalAlign[2],
|
|
90
|
+
horizontalAlign[2],
|
|
91
|
+
)}
|
|
92
|
+
}
|
|
93
|
+
`,
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
export interface InlineProps {
|
|
97
|
+
children?: ReactNode;
|
|
98
|
+
'aria-label'?: string;
|
|
99
|
+
'aria-labelledby'?: string;
|
|
100
|
+
|
|
101
|
+
noWrap?: ResponsiveProp<boolean>;
|
|
102
|
+
space?: ResponsiveProp<SpaceProp>;
|
|
103
|
+
verticalAlign?: ResponsiveProp<VerticalAlign>;
|
|
104
|
+
horizontalAlign?: ResponsiveProp<HorizontalAlign>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export const Inline = forwardRef<HTMLDivElement, InlineProps>(
|
|
108
|
+
(
|
|
109
|
+
{
|
|
110
|
+
children,
|
|
111
|
+
'aria-label': ariaLabel,
|
|
112
|
+
'aria-labelledby': ariaLabelledBy,
|
|
113
|
+
|
|
114
|
+
noWrap: noWrapProp = false,
|
|
115
|
+
space: spaceProp = 'xsmall',
|
|
116
|
+
verticalAlign: verticalAlignProp = 'top',
|
|
117
|
+
horizontalAlign: horizontalAlignProp = 'left',
|
|
118
|
+
},
|
|
119
|
+
ref,
|
|
120
|
+
) => {
|
|
121
|
+
const space = useResponsiveProp(spaceProp);
|
|
122
|
+
const noWrap = useResponsiveProp(noWrapProp);
|
|
123
|
+
const verticalAlign = useResponsiveProp(verticalAlignProp);
|
|
124
|
+
const horizontalAlign = useResponsiveProp(horizontalAlignProp);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<InlineRoot
|
|
128
|
+
ref={ref}
|
|
129
|
+
space={space}
|
|
130
|
+
noWrap={noWrap}
|
|
131
|
+
verticalAlign={verticalAlign}
|
|
132
|
+
horizontalAlign={horizontalAlign}
|
|
133
|
+
aria-label={ariaLabel}
|
|
134
|
+
aria-labelledby={ariaLabelledBy}
|
|
135
|
+
>
|
|
136
|
+
<div>
|
|
137
|
+
{flattenChildren(children).map((child, idx) => (
|
|
138
|
+
<div key={idx}>{child}</div>
|
|
139
|
+
))}
|
|
140
|
+
</div>
|
|
141
|
+
</InlineRoot>
|
|
142
|
+
);
|
|
143
|
+
},
|
|
144
|
+
);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Link, Typography } from '@material-ui/core';
|
|
2
|
+
import { Meta } from '@storybook/react';
|
|
3
|
+
import { Box } from '@superdispatch/ui-lab';
|
|
4
|
+
import { Stack } from '../stack/Stack';
|
|
5
|
+
|
|
6
|
+
export default { title: 'Navigation/Link' } as Meta;
|
|
7
|
+
|
|
8
|
+
export const basic = () => (
|
|
9
|
+
<Typography>
|
|
10
|
+
This is a{' '}
|
|
11
|
+
<Link href="#" target="_blank">
|
|
12
|
+
link
|
|
13
|
+
</Link>{' '}
|
|
14
|
+
in text with a <Link component="button">button link</Link>.
|
|
15
|
+
</Typography>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export const multiline = () => (
|
|
19
|
+
<Box maxWidth="64px">
|
|
20
|
+
<Link href="#" target="_blank">
|
|
21
|
+
This is multi-line link
|
|
22
|
+
</Link>
|
|
23
|
+
</Box>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export const multilineButton = () => (
|
|
27
|
+
<Box maxWidth="64px">
|
|
28
|
+
<Link component="button">This is multi-line button link</Link>
|
|
29
|
+
</Box>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export const colors = () => (
|
|
33
|
+
<Stack>
|
|
34
|
+
<Link href="#" target="_blank" color="primary">
|
|
35
|
+
Primary
|
|
36
|
+
</Link>
|
|
37
|
+
<Link href="#" target="_blank" color="textPrimary">
|
|
38
|
+
Text Primary
|
|
39
|
+
</Link>
|
|
40
|
+
</Stack>
|
|
41
|
+
);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Color } from '../theme/Color';
|
|
2
|
+
import { SuperDispatchTheme } from '../theme/SuperDispatchTheme';
|
|
3
|
+
|
|
4
|
+
function line(color: string): string {
|
|
5
|
+
return `linear-gradient(to right, ${color} 0%, ${color} 100%)`;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function overrideLink(theme: SuperDispatchTheme): void {
|
|
9
|
+
theme.props.MuiLink = { underline: 'none', color: 'textPrimary' };
|
|
10
|
+
|
|
11
|
+
theme.overrides.MuiLink = {
|
|
12
|
+
root: {
|
|
13
|
+
backgroundSize: '100% 1px',
|
|
14
|
+
backgroundRepeat: 'repeat-x',
|
|
15
|
+
backgroundPosition: '0 100%',
|
|
16
|
+
backgroundColor: Color.Transparent,
|
|
17
|
+
|
|
18
|
+
'&:focus': { outline: 'none' },
|
|
19
|
+
'&:hover, &:active': { backgroundImage: line('currentColor') },
|
|
20
|
+
|
|
21
|
+
'&.MuiTypography-colorTextPrimary': {
|
|
22
|
+
backgroundImage: line(Color.Silver500),
|
|
23
|
+
|
|
24
|
+
'&:focus, &:hover, &:active': {
|
|
25
|
+
color: Color.Blue300,
|
|
26
|
+
backgroundImage: line(Color.Blue300),
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
button: {
|
|
32
|
+
// Reset button styles.
|
|
33
|
+
backgroundColor: undefined,
|
|
34
|
+
|
|
35
|
+
// Override browser defaults.
|
|
36
|
+
fontSize: 'inherit',
|
|
37
|
+
textAlign: 'inherit',
|
|
38
|
+
lineHeight: 'inherit',
|
|
39
|
+
userSelect: 'inherit',
|
|
40
|
+
verticalAlign: 'inherit',
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Link } from '@material-ui/core';
|
|
2
|
+
import { renderCSS, renderTheme } from '@superdispatch/ui-testutils';
|
|
3
|
+
|
|
4
|
+
it('checks default props', () => {
|
|
5
|
+
const { props } = renderTheme();
|
|
6
|
+
|
|
7
|
+
expect(props.MuiLink).toMatchInlineSnapshot(`
|
|
8
|
+
Object {
|
|
9
|
+
"color": "textPrimary",
|
|
10
|
+
"underline": "none",
|
|
11
|
+
}
|
|
12
|
+
`);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('checks component css', () => {
|
|
16
|
+
expect(renderCSS(<Link>Text</Link>, ['MuiLink'])).toMatchInlineSnapshot(`
|
|
17
|
+
.MuiLink-root {
|
|
18
|
+
background-size: 100% 1px;
|
|
19
|
+
background-color: Color.Transparent;
|
|
20
|
+
background-repeat: repeat-x;
|
|
21
|
+
background-position: 0 100%;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.MuiLink-root:focus {
|
|
25
|
+
outline: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.MuiLink-root:hover,
|
|
29
|
+
.MuiLink-root:active {
|
|
30
|
+
background-image: linear-gradient(
|
|
31
|
+
to right,
|
|
32
|
+
currentColor 0%,
|
|
33
|
+
currentColor 100%
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.MuiLink-root.MuiTypography-colorTextPrimary {
|
|
38
|
+
background-image: linear-gradient(
|
|
39
|
+
to right,
|
|
40
|
+
Color.Silver500 0%,
|
|
41
|
+
Color.Silver500 100%
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.MuiLink-root.MuiTypography-colorTextPrimary:focus,
|
|
46
|
+
.MuiLink-root.MuiTypography-colorTextPrimary:hover,
|
|
47
|
+
.MuiLink-root.MuiTypography-colorTextPrimary:active {
|
|
48
|
+
color: Color.Blue300;
|
|
49
|
+
background-image: linear-gradient(
|
|
50
|
+
to right,
|
|
51
|
+
Color.Blue300 0%,
|
|
52
|
+
Color.Blue300 100%
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.MuiLink-underlineNone {
|
|
57
|
+
text-decoration: none;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.MuiLink-underlineHover {
|
|
61
|
+
text-decoration: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.MuiLink-underlineHover:hover {
|
|
65
|
+
text-decoration: underline;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.MuiLink-underlineAlways {
|
|
69
|
+
text-decoration: underline;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.MuiLink-button {
|
|
73
|
+
border: 0;
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
margin: 0;
|
|
76
|
+
outline: 0;
|
|
77
|
+
padding: 0;
|
|
78
|
+
position: relative;
|
|
79
|
+
font-size: inherit;
|
|
80
|
+
text-align: inherit;
|
|
81
|
+
line-height: inherit;
|
|
82
|
+
user-select: inherit;
|
|
83
|
+
border-radius: 0;
|
|
84
|
+
vertical-align: inherit;
|
|
85
|
+
-moz-appearance: none;
|
|
86
|
+
-webkit-appearance: none;
|
|
87
|
+
-webkit-tap-highlight-color: transparent;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.MuiLink-button::-moz-focus-inner {
|
|
91
|
+
border-style: none;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.MuiLink-button.Mui-focusVisible {
|
|
95
|
+
outline: auto;
|
|
96
|
+
}
|
|
97
|
+
`);
|
|
98
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Color } from '../theme/Color';
|
|
2
|
+
import { SuperDispatchTheme } from '../theme/SuperDispatchTheme';
|
|
3
|
+
|
|
4
|
+
export function overrideList(theme: SuperDispatchTheme): void {
|
|
5
|
+
theme.overrides.MuiListItem = {
|
|
6
|
+
root: {
|
|
7
|
+
'&$selected, &$selected:hover': { backgroundColor: Color.Blue50 },
|
|
8
|
+
'& .MuiTouchRipple-root': { color: Color.Blue100 },
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import {
|
|
2
|
+
List,
|
|
3
|
+
ListItem,
|
|
4
|
+
ListItemAvatar,
|
|
5
|
+
ListItemIcon,
|
|
6
|
+
ListItemSecondaryAction,
|
|
7
|
+
ListItemText,
|
|
8
|
+
} from '@material-ui/core';
|
|
9
|
+
import { renderCSS, renderTheme } from '@superdispatch/ui-testutils';
|
|
10
|
+
|
|
11
|
+
it('checks default props', () => {
|
|
12
|
+
const { props } = renderTheme();
|
|
13
|
+
|
|
14
|
+
expect(props.MuiList).toMatchInlineSnapshot(`undefined`);
|
|
15
|
+
expect(props.MuiListItem).toMatchInlineSnapshot(`undefined`);
|
|
16
|
+
expect(props.MuiListItemAvatar).toMatchInlineSnapshot(`undefined`);
|
|
17
|
+
expect(props.MuiListItemIcon).toMatchInlineSnapshot(`undefined`);
|
|
18
|
+
expect(props.MuiListItemSecondaryAction).toMatchInlineSnapshot(`undefined`);
|
|
19
|
+
expect(props.MuiListItemText).toMatchInlineSnapshot(`undefined`);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('checks component css', () => {
|
|
23
|
+
expect(
|
|
24
|
+
renderCSS(
|
|
25
|
+
<List>
|
|
26
|
+
<ListItem>
|
|
27
|
+
<ListItemAvatar>
|
|
28
|
+
<span />
|
|
29
|
+
</ListItemAvatar>
|
|
30
|
+
|
|
31
|
+
<ListItemIcon>
|
|
32
|
+
<span />
|
|
33
|
+
</ListItemIcon>
|
|
34
|
+
|
|
35
|
+
<ListItemText />
|
|
36
|
+
<ListItemSecondaryAction />
|
|
37
|
+
</ListItem>
|
|
38
|
+
|
|
39
|
+
<ListItem button={true} />
|
|
40
|
+
</List>,
|
|
41
|
+
[
|
|
42
|
+
'MuiList',
|
|
43
|
+
'MuiListItem',
|
|
44
|
+
'MuiListItemAvatar',
|
|
45
|
+
'MuiListItemIcon',
|
|
46
|
+
'MuiListItemSecondaryAction',
|
|
47
|
+
'MuiListItemText',
|
|
48
|
+
],
|
|
49
|
+
),
|
|
50
|
+
).toMatchInlineSnapshot(`
|
|
51
|
+
.MuiList-root {
|
|
52
|
+
margin: 0;
|
|
53
|
+
padding: 0;
|
|
54
|
+
position: relative;
|
|
55
|
+
list-style: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.MuiList-padding {
|
|
59
|
+
padding-top: 8px;
|
|
60
|
+
padding-bottom: 8px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.MuiList-subheader {
|
|
64
|
+
padding-top: 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.MuiListItem-root {
|
|
68
|
+
width: 100%;
|
|
69
|
+
display: flex;
|
|
70
|
+
position: relative;
|
|
71
|
+
box-sizing: border-box;
|
|
72
|
+
text-align: left;
|
|
73
|
+
align-items: center;
|
|
74
|
+
padding-top: 8px;
|
|
75
|
+
padding-bottom: 8px;
|
|
76
|
+
justify-content: flex-start;
|
|
77
|
+
text-decoration: none;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.MuiListItem-root.Mui-focusVisible {
|
|
81
|
+
background-color: Color.Silver300;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.MuiListItem-root.Mui-selected,
|
|
85
|
+
.MuiListItem-root.Mui-selected:hover {
|
|
86
|
+
background-color: Color.Blue50;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.MuiListItem-root.Mui-disabled {
|
|
90
|
+
opacity: 0.5;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.MuiListItem-root .MuiTouchRipple-root {
|
|
94
|
+
color: Color.Blue100;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.MuiListItem-container {
|
|
98
|
+
position: relative;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.MuiListItem-dense {
|
|
102
|
+
padding-top: 4px;
|
|
103
|
+
padding-bottom: 4px;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.MuiListItem-alignItemsFlexStart {
|
|
107
|
+
align-items: flex-start;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.MuiListItem-divider {
|
|
111
|
+
border-bottom: 1px solid Color.Silver400;
|
|
112
|
+
background-clip: padding-box;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.MuiListItem-gutters {
|
|
116
|
+
padding-left: 16px;
|
|
117
|
+
padding-right: 16px;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.MuiListItem-button {
|
|
121
|
+
transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.MuiListItem-button:hover {
|
|
125
|
+
text-decoration: none;
|
|
126
|
+
background-color: Color.Silver100;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@media (hover: none) {
|
|
130
|
+
.MuiListItem-button:hover {
|
|
131
|
+
background-color: transparent;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.MuiListItem-secondaryAction {
|
|
136
|
+
padding-right: 48px;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.MuiListItemAvatar-root {
|
|
140
|
+
min-width: 56px;
|
|
141
|
+
flex-shrink: 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.MuiListItemAvatar-alignItemsFlexStart {
|
|
145
|
+
margin-top: 8px;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.MuiListItemIcon-root {
|
|
149
|
+
color: rgba(0, 0, 0, 0.54);
|
|
150
|
+
display: inline-flex;
|
|
151
|
+
min-width: 56px;
|
|
152
|
+
flex-shrink: 0;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.MuiListItemIcon-alignItemsFlexStart {
|
|
156
|
+
margin-top: 8px;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.MuiListItemSecondaryAction-root {
|
|
160
|
+
top: 50%;
|
|
161
|
+
right: 16px;
|
|
162
|
+
position: absolute;
|
|
163
|
+
transform: translateY(-50%);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.MuiListItemText-root {
|
|
167
|
+
flex: 1 1 auto;
|
|
168
|
+
min-width: 0;
|
|
169
|
+
margin-top: 4px;
|
|
170
|
+
margin-bottom: 4px;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.MuiListItemText-multiline {
|
|
174
|
+
margin-top: 6px;
|
|
175
|
+
margin-bottom: 6px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.MuiListItemText-inset {
|
|
179
|
+
padding-left: 56px;
|
|
180
|
+
}
|
|
181
|
+
`);
|
|
182
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Button, Menu, MenuItem } from '@material-ui/core';
|
|
2
|
+
import { Meta } from '@storybook/react';
|
|
3
|
+
import { UseState } from '@superdispatch/ui-docs';
|
|
4
|
+
|
|
5
|
+
export default { title: 'Navigation/Menu' } as Meta;
|
|
6
|
+
|
|
7
|
+
export const basic = () => (
|
|
8
|
+
<UseState initialState={null}>
|
|
9
|
+
{(state, setState) => (
|
|
10
|
+
<>
|
|
11
|
+
<Button
|
|
12
|
+
color="primary"
|
|
13
|
+
variant="contained"
|
|
14
|
+
onClick={(event) => {
|
|
15
|
+
setState(event.currentTarget);
|
|
16
|
+
}}
|
|
17
|
+
>
|
|
18
|
+
Menu
|
|
19
|
+
</Button>
|
|
20
|
+
|
|
21
|
+
<Menu
|
|
22
|
+
open={!!state}
|
|
23
|
+
anchorEl={state}
|
|
24
|
+
onClose={() => {
|
|
25
|
+
setState(false);
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
<MenuItem>Option 1</MenuItem>
|
|
29
|
+
<MenuItem>Option 2</MenuItem>
|
|
30
|
+
<MenuItem>Option 3</MenuItem>
|
|
31
|
+
</Menu>
|
|
32
|
+
</>
|
|
33
|
+
)}
|
|
34
|
+
</UseState>
|
|
35
|
+
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SuperDispatchTheme } from '../theme/SuperDispatchTheme';
|
|
2
|
+
|
|
3
|
+
export function overrideMenu(theme: SuperDispatchTheme): void {
|
|
4
|
+
theme.props.MuiMenu = {
|
|
5
|
+
getContentAnchorEl: null,
|
|
6
|
+
anchorOrigin: { vertical: 'bottom', horizontal: 'left' },
|
|
7
|
+
transformOrigin: { vertical: 'top', horizontal: 'left' },
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
theme.overrides.MuiMenuItem = {
|
|
11
|
+
root: {
|
|
12
|
+
...theme.typography.body2,
|
|
13
|
+
paddingTop: theme.spacing(1),
|
|
14
|
+
paddingBottom: theme.spacing(1),
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Menu, MenuItem } from '@material-ui/core';
|
|
2
|
+
import { renderCSS, renderTheme } from '@superdispatch/ui-testutils';
|
|
3
|
+
|
|
4
|
+
it('checks default props', () => {
|
|
5
|
+
const { props } = renderTheme();
|
|
6
|
+
|
|
7
|
+
expect(props.MuiMenu).toMatchInlineSnapshot(`
|
|
8
|
+
Object {
|
|
9
|
+
"anchorOrigin": Object {
|
|
10
|
+
"horizontal": "left",
|
|
11
|
+
"vertical": "bottom",
|
|
12
|
+
},
|
|
13
|
+
"getContentAnchorEl": null,
|
|
14
|
+
"transformOrigin": Object {
|
|
15
|
+
"horizontal": "left",
|
|
16
|
+
"vertical": "top",
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
`);
|
|
20
|
+
expect(props.MuiMenuItem).toMatchInlineSnapshot(`undefined`);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('checks component css', () => {
|
|
24
|
+
expect(
|
|
25
|
+
renderCSS(
|
|
26
|
+
<Menu open={true} anchorEl={document.body}>
|
|
27
|
+
<MenuItem />
|
|
28
|
+
</Menu>,
|
|
29
|
+
[
|
|
30
|
+
'MuiMenu',
|
|
31
|
+
'MuiMenuItem',
|
|
32
|
+
// Move to `Popover` component styles.
|
|
33
|
+
'MuiPopover',
|
|
34
|
+
],
|
|
35
|
+
),
|
|
36
|
+
).toMatchInlineSnapshot(`
|
|
37
|
+
.MuiMenu-paper {
|
|
38
|
+
max-height: calc(100% - 96px);
|
|
39
|
+
-webkit-overflow-scrolling: touch;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.MuiMenu-list {
|
|
43
|
+
outline: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.MuiMenuItem-root {
|
|
47
|
+
width: auto;
|
|
48
|
+
overflow: hidden;
|
|
49
|
+
font-size: 14px;
|
|
50
|
+
box-sizing: border-box;
|
|
51
|
+
min-height: 48px;
|
|
52
|
+
font-family: 'Inter', sans-serif;
|
|
53
|
+
font-weight: 400;
|
|
54
|
+
line-height: 20px;
|
|
55
|
+
padding-top: 8px;
|
|
56
|
+
white-space: nowrap;
|
|
57
|
+
padding-bottom: 8px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@media (min-width: 0px) and (max-width: 599.95px) {
|
|
61
|
+
.MuiMenuItem-root {
|
|
62
|
+
font-size: 16px;
|
|
63
|
+
line-height: 24px;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@media (min-width: 600px) {
|
|
68
|
+
.MuiMenuItem-root {
|
|
69
|
+
min-height: auto;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.MuiMenuItem-dense {
|
|
74
|
+
font-size: 14px;
|
|
75
|
+
min-height: auto;
|
|
76
|
+
font-family: 'Inter', sans-serif;
|
|
77
|
+
font-weight: 400;
|
|
78
|
+
line-height: 20px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@media (min-width: 0px) and (max-width: 599.95px) {
|
|
82
|
+
.MuiMenuItem-dense {
|
|
83
|
+
font-size: 16px;
|
|
84
|
+
line-height: 24px;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.MuiPopover-paper {
|
|
89
|
+
outline: 0;
|
|
90
|
+
position: absolute;
|
|
91
|
+
max-width: calc(100% - 32px);
|
|
92
|
+
min-width: 16px;
|
|
93
|
+
max-height: calc(100% - 32px);
|
|
94
|
+
min-height: 16px;
|
|
95
|
+
overflow-x: hidden;
|
|
96
|
+
overflow-y: auto;
|
|
97
|
+
}
|
|
98
|
+
`);
|
|
99
|
+
});
|