@superdispatch/ui-lab 0.50.5 → 0.50.7

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.
Files changed (124) hide show
  1. package/LICENSE +21 -0
  2. package/{pkg/dist-node → dist-node}/index.js +31 -23
  3. package/dist-node/index.js.map +1 -0
  4. package/{pkg/dist-src → dist-src}/navbar/Navbar.js +18 -3
  5. package/{pkg/dist-src → dist-src}/navbar/NavbarAccordion.js +9 -19
  6. package/{pkg/dist-src → dist-src}/navbar/NavbarContext.js +3 -1
  7. package/{pkg/dist-src → dist-src}/navbar/NavbarList.js +2 -1
  8. package/{pkg/dist-types → dist-types}/index.d.ts +8 -6
  9. package/{pkg/dist-web → dist-web}/index.js +31 -23
  10. package/dist-web/index.js.map +1 -0
  11. package/package.json +14 -39
  12. package/.babelrc.js +0 -5
  13. package/pkg/README.md +0 -10
  14. package/pkg/dist-node/index.js.map +0 -1
  15. package/pkg/dist-web/index.js.map +0 -1
  16. package/pkg/package.json +0 -41
  17. package/playroom.ts +0 -24
  18. package/src/alert/Alert.stories.tsx +0 -162
  19. package/src/alert/Alert.tsx +0 -135
  20. package/src/banner/Banner.stories.tsx +0 -64
  21. package/src/banner/Banner.tsx +0 -120
  22. package/src/box/Box.stories.tsx +0 -20
  23. package/src/box/Box.tsx +0 -257
  24. package/src/button/Button.stories.tsx +0 -739
  25. package/src/button/Button.tsx +0 -498
  26. package/src/button-area/ButtonArea.stories.tsx +0 -65
  27. package/src/button-area/ButtonArea.tsx +0 -90
  28. package/src/chat/Chat.stories.tsx +0 -130
  29. package/src/chat/Chat.tsx +0 -57
  30. package/src/chat/ChatMessage.tsx +0 -45
  31. package/src/chat/README.MD +0 -7
  32. package/src/chat/__tests__/Chat.spec.tsx +0 -29
  33. package/src/chat/__tests__/ChatMessage.spec.tsx +0 -39
  34. package/src/container/Container.tsx +0 -48
  35. package/src/description-item/DescriptionItem.stories.tsx +0 -163
  36. package/src/description-item/DescriptionItem.tsx +0 -104
  37. package/src/description-line-item/DescriptionLineItem.stories.tsx +0 -23
  38. package/src/description-line-item/DescriptionLineItem.tsx +0 -29
  39. package/src/email-autocomplate/CloseIcon.tsx +0 -20
  40. package/src/email-autocomplate/EmailAutocomplete.stories.tsx +0 -47
  41. package/src/email-autocomplate/EmailAutocomplete.tsx +0 -138
  42. package/src/file-drop-zone/FileDropZone.stories.tsx +0 -44
  43. package/src/file-drop-zone/FileDropZone.tsx +0 -170
  44. package/src/file-list-item/FileListItem.stories.tsx +0 -37
  45. package/src/file-list-item/FileListItem.tsx +0 -148
  46. package/src/file-list-item/__tests__/FileListItem.spec.tsx +0 -339
  47. package/src/flag-list/FlagList.stories.tsx +0 -72
  48. package/src/flag-list/FlagList.tsx +0 -54
  49. package/src/flag-list/FlagListItem.tsx +0 -126
  50. package/src/index.spec.ts +0 -53
  51. package/src/index.ts +0 -36
  52. package/src/linked-text/LinkeText.stories.tsx +0 -42
  53. package/src/linked-text/LinkedText.tsx +0 -47
  54. package/src/multiline-text/MultilineText.stories.tsx +0 -30
  55. package/src/multiline-text/MultilineText.ts +0 -16
  56. package/src/navbar/Navbar.stories.tsx +0 -137
  57. package/src/navbar/Navbar.tsx +0 -132
  58. package/src/navbar/NavbarAccordion.tsx +0 -195
  59. package/src/navbar/NavbarAvatar.tsx +0 -51
  60. package/src/navbar/NavbarBottomBar.tsx +0 -135
  61. package/src/navbar/NavbarContext.tsx +0 -22
  62. package/src/navbar/NavbarItem.tsx +0 -125
  63. package/src/navbar/NavbarList.tsx +0 -247
  64. package/src/navbar/NavbarMenu.tsx +0 -102
  65. package/src/passwordStepper/PasswordStrength.stories.tsx +0 -95
  66. package/src/passwordStepper/PasswordStrength.tsx +0 -107
  67. package/src/passwordStepper/PasswordUtils.tsx +0 -42
  68. package/src/passwordStepper/PasswordValidationComponents.tsx +0 -95
  69. package/src/sidebar/Sidebar.stories.tsx +0 -376
  70. package/src/sidebar/Sidebar.tsx +0 -75
  71. package/src/sidebar/SidebarBackButton.tsx +0 -33
  72. package/src/sidebar/SidebarContainer.tsx +0 -114
  73. package/src/sidebar/SidebarContent.tsx +0 -119
  74. package/src/sidebar/SidebarDivider.tsx +0 -15
  75. package/src/sidebar/SidebarMenuItem.tsx +0 -196
  76. package/src/sidebar/SidebarMenuItemAction.tsx +0 -27
  77. package/src/sidebar/SidebarMenuItemAvatar.tsx +0 -59
  78. package/src/sidebar/SidebarMenuItemContext.tsx +0 -33
  79. package/src/sidebar/SidebarSubheader.tsx +0 -38
  80. package/src/styled.d.ts +0 -12
  81. package/src/text-box/TextBox.stories.tsx +0 -114
  82. package/src/text-box/TextBox.tsx +0 -238
  83. package/src/utils/RuleNormalizer.ts +0 -24
  84. package/src/utils/mergeStyles.ts +0 -28
  85. package/tsconfig.json +0 -19
  86. /package/{pkg/dist-src → dist-src}/alert/Alert.js +0 -0
  87. /package/{pkg/dist-src → dist-src}/banner/Banner.js +0 -0
  88. /package/{pkg/dist-src → dist-src}/box/Box.js +0 -0
  89. /package/{pkg/dist-src → dist-src}/button/Button.js +0 -0
  90. /package/{pkg/dist-src → dist-src}/button-area/ButtonArea.js +0 -0
  91. /package/{pkg/dist-src → dist-src}/chat/Chat.js +0 -0
  92. /package/{pkg/dist-src → dist-src}/chat/ChatMessage.js +0 -0
  93. /package/{pkg/dist-src → dist-src}/container/Container.js +0 -0
  94. /package/{pkg/dist-src → dist-src}/description-item/DescriptionItem.js +0 -0
  95. /package/{pkg/dist-src → dist-src}/description-line-item/DescriptionLineItem.js +0 -0
  96. /package/{pkg/dist-src → dist-src}/email-autocomplate/CloseIcon.js +0 -0
  97. /package/{pkg/dist-src → dist-src}/email-autocomplate/EmailAutocomplete.js +0 -0
  98. /package/{pkg/dist-src → dist-src}/file-drop-zone/FileDropZone.js +0 -0
  99. /package/{pkg/dist-src → dist-src}/file-list-item/FileListItem.js +0 -0
  100. /package/{pkg/dist-src → dist-src}/flag-list/FlagList.js +0 -0
  101. /package/{pkg/dist-src → dist-src}/flag-list/FlagListItem.js +0 -0
  102. /package/{pkg/dist-src → dist-src}/index.js +0 -0
  103. /package/{pkg/dist-src → dist-src}/linked-text/LinkedText.js +0 -0
  104. /package/{pkg/dist-src → dist-src}/multiline-text/MultilineText.js +0 -0
  105. /package/{pkg/dist-src → dist-src}/navbar/NavbarAvatar.js +0 -0
  106. /package/{pkg/dist-src → dist-src}/navbar/NavbarBottomBar.js +0 -0
  107. /package/{pkg/dist-src → dist-src}/navbar/NavbarItem.js +0 -0
  108. /package/{pkg/dist-src → dist-src}/navbar/NavbarMenu.js +0 -0
  109. /package/{pkg/dist-src → dist-src}/passwordStepper/PasswordStrength.js +0 -0
  110. /package/{pkg/dist-src → dist-src}/passwordStepper/PasswordUtils.js +0 -0
  111. /package/{pkg/dist-src → dist-src}/passwordStepper/PasswordValidationComponents.js +0 -0
  112. /package/{pkg/dist-src → dist-src}/sidebar/Sidebar.js +0 -0
  113. /package/{pkg/dist-src → dist-src}/sidebar/SidebarBackButton.js +0 -0
  114. /package/{pkg/dist-src → dist-src}/sidebar/SidebarContainer.js +0 -0
  115. /package/{pkg/dist-src → dist-src}/sidebar/SidebarContent.js +0 -0
  116. /package/{pkg/dist-src → dist-src}/sidebar/SidebarDivider.js +0 -0
  117. /package/{pkg/dist-src → dist-src}/sidebar/SidebarMenuItem.js +0 -0
  118. /package/{pkg/dist-src → dist-src}/sidebar/SidebarMenuItemAction.js +0 -0
  119. /package/{pkg/dist-src → dist-src}/sidebar/SidebarMenuItemAvatar.js +0 -0
  120. /package/{pkg/dist-src → dist-src}/sidebar/SidebarMenuItemContext.js +0 -0
  121. /package/{pkg/dist-src → dist-src}/sidebar/SidebarSubheader.js +0 -0
  122. /package/{pkg/dist-src → dist-src}/text-box/TextBox.js +0 -0
  123. /package/{pkg/dist-src → dist-src}/utils/RuleNormalizer.js +0 -0
  124. /package/{pkg/dist-src → dist-src}/utils/mergeStyles.js +0 -0
@@ -1,376 +0,0 @@
1
- import { InputAdornment, TextField } from '@material-ui/core';
2
- import AddIcon from '@material-ui/icons/Add';
3
- import DeleteIcon from '@material-ui/icons/Delete';
4
- import EditIcon from '@material-ui/icons/Edit';
5
- import NotificationsIcon from '@material-ui/icons/Notifications';
6
- import NotificationsOffIcon from '@material-ui/icons/NotificationsOff';
7
- import SearchIcon from '@material-ui/icons/Search';
8
- import SettingsIcon from '@material-ui/icons/Settings';
9
- import { Meta } from '@storybook/react';
10
- import { Stack } from '@superdispatch/ui';
11
- import { Button } from '@superdispatch/ui-lab';
12
- import { Placeholder } from '../../../__docs__';
13
- import { Box } from '../box/Box';
14
- import { Sidebar } from './Sidebar';
15
- import { SidebarContainer } from './SidebarContainer';
16
- import { SidebarContent } from './SidebarContent';
17
- import { SidebarDivider } from './SidebarDivider';
18
- import { SidebarMenuItem } from './SidebarMenuItem';
19
- import { SidebarMenuItemAction } from './SidebarMenuItemAction';
20
- import { SidebarMenuItemAvatar } from './SidebarMenuItemAvatar';
21
- import { SidebarSubheader } from './SidebarSubheader';
22
-
23
- export default {
24
- title: 'Lab/Sidebar',
25
- component: Sidebar,
26
- subcomponents: {
27
- SidebarContainer,
28
- SidebarDivider,
29
- SidebarMenuItem,
30
- SidebarMenuItemAction,
31
- SidebarMenuItemAvatar,
32
- SidebarSubheader,
33
- },
34
- } as Meta;
35
-
36
- export const basic = () => (
37
- <SidebarContainer
38
- sidebar={
39
- <Sidebar title="Settings">
40
- <SidebarMenuItem selected={true}>General</SidebarMenuItem>
41
- <SidebarMenuItem>Terminals</SidebarMenuItem>
42
- <SidebarMenuItem>Driver App</SidebarMenuItem>
43
- <SidebarMenuItem>Billing</SidebarMenuItem>
44
- <SidebarMenuItem>Factoring</SidebarMenuItem>
45
- <SidebarMenuItem external={true}>
46
- Quickbooks Integration
47
- </SidebarMenuItem>
48
- <SidebarMenuItem>Subscription Details</SidebarMenuItem>
49
- <SidebarMenuItem external={true}>Notification Emails</SidebarMenuItem>
50
- <SidebarMenuItem external={true}>
51
- Loadboard Notifications
52
- </SidebarMenuItem>
53
- </Sidebar>
54
- }
55
- >
56
- <Placeholder height="100%" width="100%" text="Content" />
57
- </SidebarContainer>
58
- );
59
-
60
- export const list = () => (
61
- <SidebarContainer
62
- sidebar={
63
- <Sidebar
64
- title="Drivers"
65
- count={9}
66
- header={
67
- <Stack space="small">
68
- <Button fullWidth={true} variant="primary" startIcon={<AddIcon />}>
69
- Create New
70
- </Button>
71
-
72
- <TextField
73
- fullWidth={true}
74
- placeholder="Search for drivers…"
75
- InputProps={{
76
- startAdornment: (
77
- <InputAdornment position="start">
78
- <SearchIcon />
79
- </InputAdornment>
80
- ),
81
- }}
82
- />
83
- </Stack>
84
- }
85
- >
86
- <SidebarMenuItem
87
- badge={1}
88
- selected={true}
89
- openContentOnClick={true}
90
- avatar={<SidebarMenuItemAvatar>Eirwen Minoo</SidebarMenuItemAvatar>}
91
- secondaryActions={
92
- <SidebarMenuItemAction title="Edit">
93
- <EditIcon />
94
- </SidebarMenuItemAction>
95
- }
96
- >
97
- Eirwen Minoo
98
- </SidebarMenuItem>
99
- <SidebarMenuItem
100
- badge={1}
101
- openContentOnClick={true}
102
- avatar={<SidebarMenuItemAvatar>Ole Kielo</SidebarMenuItemAvatar>}
103
- secondaryActions={
104
- <SidebarMenuItemAction title="Edit">
105
- <EditIcon />
106
- </SidebarMenuItemAction>
107
- }
108
- >
109
- Ole Kielo
110
- </SidebarMenuItem>
111
- <SidebarMenuItem
112
- openContentOnClick={true}
113
- avatar={
114
- <SidebarMenuItemAvatar>Virve Vivi Wangi</SidebarMenuItemAvatar>
115
- }
116
- >
117
- Virve Vivi Wangi
118
- </SidebarMenuItem>
119
- <SidebarMenuItem
120
- openContentOnClick={true}
121
- avatar={
122
- <SidebarMenuItemAvatar>
123
- Radulf Čedomir Niĉjo Aparna
124
- </SidebarMenuItemAvatar>
125
- }
126
- >
127
- Radulf Čedomir Niĉjo Aparna
128
- </SidebarMenuItem>
129
- <SidebarMenuItem
130
- openContentOnClick={true}
131
- avatar={
132
- <SidebarMenuItemAvatar>Léane Audovacar</SidebarMenuItemAvatar>
133
- }
134
- >
135
- Léane Audovacar
136
- </SidebarMenuItem>
137
- <SidebarMenuItem
138
- avatar={<SidebarMenuItemAvatar>Devon Vesta</SidebarMenuItemAvatar>}
139
- >
140
- Devon Vesta
141
- </SidebarMenuItem>
142
- <SidebarMenuItem
143
- avatar={<SidebarMenuItemAvatar>Xenagoras Ares</SidebarMenuItemAvatar>}
144
- >
145
- Xenagoras Ares
146
- </SidebarMenuItem>
147
- <SidebarMenuItem
148
- avatar={<SidebarMenuItemAvatar>Nithya Phebe</SidebarMenuItemAvatar>}
149
- >
150
- Nithya Phebe
151
- </SidebarMenuItem>
152
- <SidebarMenuItem
153
- avatar={<SidebarMenuItemAvatar>Nitin Paulette</SidebarMenuItemAvatar>}
154
- >
155
- Nitin Paulette
156
- </SidebarMenuItem>
157
- </Sidebar>
158
- }
159
- >
160
- <SidebarContent
161
- title="List"
162
- action={<Button variant="primary">Create</Button>}
163
- >
164
- <Placeholder height="100%" width="100%" text="Content" />
165
- </SidebarContent>
166
- </SidebarContainer>
167
- );
168
-
169
- export const checkbox = () => (
170
- <SidebarContainer
171
- sidebar={
172
- <Sidebar title="Drivers">
173
- <SidebarMenuItem
174
- selected={true}
175
- openContentOnClick={true}
176
- avatar={
177
- <SidebarMenuItemAvatar value={false}>
178
- Eirwen Minoo
179
- </SidebarMenuItemAvatar>
180
- }
181
- >
182
- Eirwen Minoo
183
- </SidebarMenuItem>
184
- <SidebarMenuItem
185
- openContentOnClick={true}
186
- avatar={
187
- <SidebarMenuItemAvatar value={true}>
188
- Ole Kielo
189
- </SidebarMenuItemAvatar>
190
- }
191
- >
192
- Ole Kielo
193
- </SidebarMenuItem>
194
- <SidebarMenuItem
195
- openContentOnClick={true}
196
- avatar={
197
- <SidebarMenuItemAvatar value={false}>
198
- Virve Vivi Wangi
199
- </SidebarMenuItemAvatar>
200
- }
201
- >
202
- Virve Vivi Wangi
203
- </SidebarMenuItem>
204
- <SidebarMenuItem
205
- avatar={
206
- <SidebarMenuItemAvatar value={false}>
207
- Radulf Čedomir Niĉjo Aparna
208
- </SidebarMenuItemAvatar>
209
- }
210
- >
211
- Radulf Čedomir Niĉjo Aparna
212
- </SidebarMenuItem>
213
- </Sidebar>
214
- }
215
- >
216
- <SidebarContent title="">
217
- <Placeholder height="100%" width="100%" text="Content" />
218
- </SidebarContent>
219
- </SidebarContainer>
220
- );
221
-
222
- export const checkboxMany = () => {
223
- const items = Array(25)
224
- .fill(null)
225
- .map((_, index) => (
226
- <SidebarMenuItem
227
- key={index}
228
- openContentOnClick={true}
229
- avatar={
230
- <SidebarMenuItemAvatar value={false}>
231
- {`Eirwen Minoo (${index})`}
232
- </SidebarMenuItemAvatar>
233
- }
234
- >
235
- {`Eirwen Minoo (${index})`}
236
- </SidebarMenuItem>
237
- ));
238
-
239
- return (
240
- <SidebarContainer sidebar={<Sidebar title="Drivers List">{items}</Sidebar>}>
241
- <SidebarContent title="">
242
- <Placeholder height="100%" width="100%" text="Content" />
243
- </SidebarContent>
244
- </SidebarContainer>
245
- );
246
- };
247
-
248
- export const complex = () => (
249
- <SidebarContainer
250
- sidebar={
251
- <Sidebar title="Super Loadboard">
252
- <SidebarMenuItem selected={true} badge={320}>
253
- Available
254
- </SidebarMenuItem>
255
- <SidebarMenuItem badge={5}>Requested</SidebarMenuItem>
256
- <SidebarMenuItem badge={12}>Booked</SidebarMenuItem>
257
- <SidebarMenuItem badge={56}>Suggested</SidebarMenuItem>
258
-
259
- <SidebarDivider />
260
-
261
- <SidebarSubheader
262
- action={
263
- <SidebarMenuItemAction
264
- placement="right"
265
- title="Loadboard Notifications"
266
- >
267
- <SettingsIcon />
268
- </SidebarMenuItemAction>
269
- }
270
- >
271
- Load Alerts
272
- </SidebarSubheader>
273
-
274
- <SidebarMenuItem
275
- action={
276
- <SidebarMenuItemAction title="Mute">
277
- <NotificationsIcon color="primary" />
278
- </SidebarMenuItemAction>
279
- }
280
- secondaryActions={
281
- <>
282
- <SidebarMenuItemAction title="Edit">
283
- <EditIcon />
284
- </SidebarMenuItemAction>
285
-
286
- <SidebarMenuItemAction title="Delete">
287
- <DeleteIcon />
288
- </SidebarMenuItemAction>
289
- </>
290
- }
291
- >
292
- New York, NY - Kansas City, MO
293
- </SidebarMenuItem>
294
-
295
- <SidebarMenuItem
296
- action={
297
- <SidebarMenuItemAction title="Unmute">
298
- <NotificationsOffIcon />
299
- </SidebarMenuItemAction>
300
- }
301
- >
302
- Kansas City, MO - New York, NY
303
- </SidebarMenuItem>
304
-
305
- <SidebarMenuItem
306
- action={
307
- <SidebarMenuItemAction title="Unmute">
308
- <NotificationsOffIcon />
309
- </SidebarMenuItemAction>
310
- }
311
- >
312
- New York, NY - Kansas City, KS
313
- </SidebarMenuItem>
314
-
315
- <SidebarMenuItem
316
- action={
317
- <SidebarMenuItemAction title="Unmute">
318
- <NotificationsOffIcon />
319
- </SidebarMenuItemAction>
320
- }
321
- >
322
- Kansas City, MO - New York, NY
323
- </SidebarMenuItem>
324
-
325
- <SidebarMenuItem
326
- action={
327
- <SidebarMenuItemAction title="Unmute">
328
- <NotificationsOffIcon />
329
- </SidebarMenuItemAction>
330
- }
331
- >
332
- New York, NY - Kansas City, KS
333
- </SidebarMenuItem>
334
-
335
- <SidebarMenuItem
336
- action={
337
- <SidebarMenuItemAction title="Unmute">
338
- <NotificationsOffIcon />
339
- </SidebarMenuItemAction>
340
- }
341
- >
342
- Kansas City, MO - New York, NY
343
- </SidebarMenuItem>
344
-
345
- <SidebarMenuItem
346
- action={
347
- <SidebarMenuItemAction title="Unmute">
348
- <NotificationsOffIcon />
349
- </SidebarMenuItemAction>
350
- }
351
- >
352
- New York, NY - Kansas City, KS
353
- </SidebarMenuItem>
354
-
355
- <Box
356
- bottom={0}
357
- position="sticky"
358
- paddingTop="small"
359
- paddingBottom="small"
360
- paddingLeft="medium"
361
- paddingRight="medium"
362
- >
363
- <Button
364
- fullWidth={true}
365
- startIcon={<NotificationsOffIcon color="action" />}
366
- variant="neutral"
367
- >
368
- Create Load Alert
369
- </Button>
370
- </Box>
371
- </Sidebar>
372
- }
373
- >
374
- <Placeholder height="100%" width="100%" text="Content" />
375
- </SidebarContainer>
376
- );
@@ -1,75 +0,0 @@
1
- import { ColorDynamic, Column, Columns, useUID } from '@superdispatch/ui';
2
- import { forwardRef, ReactNode } from 'react';
3
- import styled from 'styled-components';
4
- import { TextBox } from '../text-box/TextBox';
5
-
6
- const SidebarRoot = styled.aside`
7
- top: 0;
8
- position: sticky;
9
- overflow-y: auto;
10
- overflow-x: hidden;
11
-
12
- height: 100vh;
13
- background-color: ${ColorDynamic.White};
14
- border-right: 1px solid ${ColorDynamic.Silver400};
15
- `;
16
-
17
- const SidebarHeader = styled.div`
18
- top: 0;
19
- z-index: 2;
20
- position: sticky;
21
- padding-left: 24px;
22
- padding-right: 24px;
23
- padding-bottom: 8px;
24
- background-color: ${ColorDynamic.White};
25
- `;
26
-
27
- const SidebarTitle = styled.div`
28
- height: 64px;
29
- max-height: 64px;
30
- display: flex;
31
- align-items: center;
32
- `;
33
-
34
- export interface SidebarProps {
35
- id?: string;
36
- title?: ReactNode;
37
- count?: null | number;
38
- header?: ReactNode;
39
- children?: ReactNode;
40
- }
41
-
42
- export const Sidebar = forwardRef<HTMLDivElement, SidebarProps>(
43
- ({ title, count, header, children, id: idProp }, ref) => {
44
- const id = useUID(idProp);
45
- const titleID = `${id}-title`;
46
-
47
- return (
48
- <SidebarRoot id={id} ref={ref}>
49
- <SidebarHeader>
50
- {title && (
51
- <SidebarTitle>
52
- <Columns space="xsmall" align="center">
53
- <Column width="fluid">
54
- <TextBox variant="heading-2" noWrap={true} id={titleID}>
55
- {title}
56
- </TextBox>
57
- </Column>
58
-
59
- {!!count && (
60
- <Column width="content">
61
- <TextBox color="secondary">{count}</TextBox>
62
- </Column>
63
- )}
64
- </Columns>
65
- </SidebarTitle>
66
- )}
67
-
68
- {header}
69
- </SidebarHeader>
70
-
71
- <div aria-labelledby={titleID}>{children}</div>
72
- </SidebarRoot>
73
- );
74
- },
75
- );
@@ -1,33 +0,0 @@
1
- import { IconButton, IconButtonProps } from '@material-ui/core';
2
- import { ArrowBack } from '@material-ui/icons';
3
- import { useCollapseBreakpoint } from '@superdispatch/ui';
4
- import { ReactElement } from 'react';
5
- import { useSidebarContext } from './SidebarContainer';
6
-
7
- export function SidebarBackButton({
8
- onClick,
9
- children = <ArrowBack fontSize="small" />,
10
- ...props
11
- }: IconButtonProps): ReactElement | null {
12
- const isCollapsed = useCollapseBreakpoint('sm');
13
- const { openSidebar } = useSidebarContext();
14
-
15
- if (!isCollapsed) {
16
- return null;
17
- }
18
-
19
- return (
20
- <IconButton
21
- {...props}
22
- size="small"
23
- onClick={(event) => {
24
- onClick?.(event);
25
- if (!event.isDefaultPrevented()) {
26
- openSidebar();
27
- }
28
- }}
29
- >
30
- {children}
31
- </IconButton>
32
- );
33
- }
@@ -1,114 +0,0 @@
1
- import { useCollapseBreakpoint } from '@superdispatch/ui';
2
- import {
3
- createContext,
4
- forwardRef,
5
- ReactChild,
6
- ReactNode,
7
- useContext,
8
- useMemo,
9
- useState,
10
- } from 'react';
11
- import styled from 'styled-components';
12
-
13
- interface SidebarContext {
14
- openSidebar: () => void;
15
- openSidebarContent: () => void;
16
- }
17
-
18
- const Context = createContext<SidebarContext | null>(null);
19
-
20
- export function useSidebarContext(): SidebarContext {
21
- const context = useContext(Context);
22
-
23
- if (!context) {
24
- throw new Error('SidebarContext is used outside Provider');
25
- }
26
-
27
- return context;
28
- }
29
-
30
- const SidebarContainerSidebar = styled.div`
31
- height: inherit;
32
- max-height: inherit;
33
- min-height: inherit;
34
-
35
- width: 240px;
36
- `;
37
-
38
- const SidebarContainerContent = styled.div`
39
- height: inherit;
40
- max-height: inherit;
41
- min-height: inherit;
42
- `;
43
-
44
- const SidebarContainerRoot = styled.div`
45
- display: flex;
46
-
47
- height: inherit;
48
- max-height: inherit;
49
- min-height: inherit;
50
-
51
- & ${SidebarContainerContent} {
52
- width: calc(100% - 240px);
53
- min-width: calc(100% - 240px);
54
- max-width: calc(100% - 240px);
55
- }
56
-
57
- &[data-visibility='sidebar'] ${SidebarContainerSidebar} {
58
- width: 100%;
59
- }
60
-
61
- &[data-visibility='sidebar'] ${SidebarContainerContent} {
62
- display: none;
63
- }
64
-
65
- &[data-visibility='content'] ${SidebarContainerSidebar} {
66
- display: none;
67
- }
68
-
69
- &[data-visibility='content'] ${SidebarContainerContent} {
70
- width: 100%;
71
- max-width: unset;
72
- }
73
- `;
74
-
75
- export interface SidebarContainerProps {
76
- sidebar: ReactChild;
77
- children?: ReactNode;
78
- }
79
-
80
- type SidebarContainerVisibility = 'both' | 'sidebar' | 'content';
81
-
82
- export const SidebarContainer = forwardRef<
83
- HTMLDivElement,
84
- SidebarContainerProps
85
- >(({ sidebar, children }, ref) => {
86
- const isCollapsed = useCollapseBreakpoint('sm');
87
- const [visibilityState, setVisibilityState] =
88
- useState<SidebarContainerVisibility>('sidebar');
89
-
90
- const visibility: SidebarContainerVisibility = isCollapsed
91
- ? visibilityState
92
- : 'both';
93
-
94
- const context = useMemo<SidebarContext>(() => {
95
- return {
96
- openSidebar: () => {
97
- setVisibilityState('sidebar');
98
- },
99
- openSidebarContent: () => {
100
- setVisibilityState('content');
101
- },
102
- };
103
- }, []);
104
-
105
- return (
106
- <Context.Provider value={context}>
107
- <SidebarContainerRoot ref={ref} data-visibility={visibility}>
108
- <SidebarContainerSidebar>{sidebar}</SidebarContainerSidebar>
109
-
110
- <SidebarContainerContent>{children}</SidebarContainerContent>
111
- </SidebarContainerRoot>
112
- </Context.Provider>
113
- );
114
- });