@hyphen/hyphen-components 2.24.0 → 2.25.0
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/dist/components/Sidebar/Sidebar.d.ts +50 -0
- package/dist/components/Sidebar/Sidebar.stories.d.ts +6 -0
- package/dist/css/reset.css +10 -0
- package/dist/css/utilities.css +331 -0
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hyphen-components.cjs.development.js +666 -110
- package/dist/hyphen-components.cjs.development.js.map +1 -1
- package/dist/hyphen-components.cjs.production.min.js +1 -1
- package/dist/hyphen-components.cjs.production.min.js.map +1 -1
- package/dist/hyphen-components.esm.js +634 -111
- package/dist/hyphen-components.esm.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/package.json +2 -1
- package/src/components/DropdownMenu/DropdownMenu.tsx +1 -1
- package/src/components/ResponsiveProvider/ResponsiveProvider.tsx +1 -1
- package/src/components/Sidebar/Sidebar.stories.tsx +392 -0
- package/src/components/Sidebar/Sidebar.tsx +629 -0
- package/src/hooks/index.ts +1 -1
- package/src/hooks/useBreakpoint/useBreakpoint.ts +1 -1
- package/src/index.ts +2 -0
- package/src/styles/animation.scss +0 -1
- package/src/styles/reset.scss +10 -0
- package/src/styles/transform.scss +305 -0
- package/src/styles/utilities.scss +30 -2
- /package/dist/hooks/useIsomorphicLayoutEffect/{useIsomorphicLayouEffect.d.ts → useIsomorphicLayoutEffect.d.ts} +0 -0
- /package/src/hooks/useIsomorphicLayoutEffect/{useIsomorphicLayouEffect.ts → useIsomorphicLayoutEffect.ts} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from './components/DatePicker/DatePicker';
|
|
|
11
11
|
export * from './components/Details/Details';
|
|
12
12
|
export * from './components/Details/DetailsSummary';
|
|
13
13
|
export * from './components/Drawer/Drawer';
|
|
14
|
+
export * from './components/DropdownMenu/DropdownMenu';
|
|
14
15
|
export * from './components/FormControl/FormControl';
|
|
15
16
|
export * from './components/Formik/FormikCheckboxInput/FormikCheckboxInput';
|
|
16
17
|
export * from './components/Formik/FormikRadioGroup/FormikRadioGroup';
|
|
@@ -36,6 +37,7 @@ export * from './components/ResponsiveProvider/ResponsiveProvider';
|
|
|
36
37
|
export * from './components/SelectInput/SelectInput';
|
|
37
38
|
export * from './components/SelectInputInset/SelectInputInset';
|
|
38
39
|
export * from './components/SelectInputNative/SelectInputNative';
|
|
40
|
+
export * from './components/Sidebar/Sidebar';
|
|
39
41
|
export * from './components/Spinner/Spinner';
|
|
40
42
|
export * from './components/Table/Table';
|
|
41
43
|
export * from './components/TextareaInput/TextareaInput';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyphen/hyphen-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.25.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "@hyphen"
|
|
@@ -126,6 +126,7 @@
|
|
|
126
126
|
"@popperjs/core": "^2.11.8",
|
|
127
127
|
"@radix-ui/react-collapsible": "^1.1.1",
|
|
128
128
|
"@radix-ui/react-dropdown-menu": "^2.1.2",
|
|
129
|
+
"@radix-ui/react-slot": "^1.1.0",
|
|
129
130
|
"@types/react-modal": "^3.16.3",
|
|
130
131
|
"classnames": "^2.5.1",
|
|
131
132
|
"date-fns": "^2.16.1",
|
|
@@ -25,7 +25,7 @@ const DropdownMenuItem = React.forwardRef<
|
|
|
25
25
|
<DropdownMenuPrimitive.Item
|
|
26
26
|
ref={ref}
|
|
27
27
|
className={classNames(
|
|
28
|
-
'font-size-sm position-relative cursor-default display-flex br-sm align-items-center p-sm g-sm
|
|
28
|
+
'font-size-sm position-relative cursor-default display-flex br-sm align-items-center p-sm g-sm outline-none hover:background-color-secondary focus:background-color-secondary',
|
|
29
29
|
inset && 'p-left-md',
|
|
30
30
|
className
|
|
31
31
|
)}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, createContext } from 'react';
|
|
2
|
-
import { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect/
|
|
2
|
+
import { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';
|
|
3
3
|
|
|
4
4
|
export interface ResponsiveContextShape {
|
|
5
5
|
isCreated: boolean;
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta } from '@storybook/react';
|
|
3
|
+
import {
|
|
4
|
+
SidebarProvider,
|
|
5
|
+
Sidebar,
|
|
6
|
+
SidebarRail,
|
|
7
|
+
SidebarInset,
|
|
8
|
+
SidebarHeader,
|
|
9
|
+
SidebarFooter,
|
|
10
|
+
SidebarContent,
|
|
11
|
+
SidebarMenu,
|
|
12
|
+
SidebarMenuItem,
|
|
13
|
+
SidebarGroup,
|
|
14
|
+
SidebarGroupLabel,
|
|
15
|
+
SidebarMenuSub,
|
|
16
|
+
SidebarMenuSubItem,
|
|
17
|
+
SidebarMenuButton,
|
|
18
|
+
SidebarMenuSubButton,
|
|
19
|
+
SidebarMenuAction,
|
|
20
|
+
SidebarMenuBadge,
|
|
21
|
+
SidebarTrigger,
|
|
22
|
+
} from './Sidebar';
|
|
23
|
+
import { allModes } from '../../modes';
|
|
24
|
+
import { Card } from '../Card/Card';
|
|
25
|
+
import { Icon } from '../Icon/Icon';
|
|
26
|
+
import {
|
|
27
|
+
Collapsible,
|
|
28
|
+
CollapsibleContent,
|
|
29
|
+
CollapsibleTrigger,
|
|
30
|
+
} from '../Collapsible/Collapsible';
|
|
31
|
+
import {
|
|
32
|
+
DropdownMenu,
|
|
33
|
+
DropdownMenuContent,
|
|
34
|
+
DropdownMenuGroup,
|
|
35
|
+
DropdownMenuItem,
|
|
36
|
+
DropdownMenuLabel,
|
|
37
|
+
DropdownMenuSeparator,
|
|
38
|
+
DropdownMenuShortcut,
|
|
39
|
+
DropdownMenuTrigger,
|
|
40
|
+
} from '../DropdownMenu/DropdownMenu';
|
|
41
|
+
import { Box } from '../Box/Box';
|
|
42
|
+
import { IconName } from 'src/types';
|
|
43
|
+
import { useIsMobile } from '../../hooks/useIsMobile/useIsMobile';
|
|
44
|
+
import { ResponsiveProvider } from '../ResponsiveProvider/ResponsiveProvider';
|
|
45
|
+
|
|
46
|
+
const meta: Meta<typeof Sidebar> = {
|
|
47
|
+
title: 'Components/Sidebar',
|
|
48
|
+
component: Sidebar,
|
|
49
|
+
parameters: {
|
|
50
|
+
layout: 'fullscreen',
|
|
51
|
+
overrideDecorator: true,
|
|
52
|
+
chromatic: {
|
|
53
|
+
modes: {
|
|
54
|
+
light: allModes['light'],
|
|
55
|
+
dark: allModes['dark'],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default meta;
|
|
62
|
+
|
|
63
|
+
// This is sample data.
|
|
64
|
+
const data = {
|
|
65
|
+
user: {
|
|
66
|
+
name: 'taylor anderson',
|
|
67
|
+
email: 'taylor.anderson@hyphen.ai',
|
|
68
|
+
avatar: '/avatars/avatar.jpg',
|
|
69
|
+
},
|
|
70
|
+
teams: [
|
|
71
|
+
{
|
|
72
|
+
name: 'Acme Inc',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'Acme Corp.',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'Evil Corp.',
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
navMain: [
|
|
82
|
+
{
|
|
83
|
+
title: 'Dashboard',
|
|
84
|
+
url: '#',
|
|
85
|
+
icon: 'dashboard',
|
|
86
|
+
isActive: true,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
title: 'Teams',
|
|
90
|
+
url: '#',
|
|
91
|
+
icon: 'users',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
title: 'Link',
|
|
95
|
+
url: '#',
|
|
96
|
+
icon: 'logo-link',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
title: 'ENV',
|
|
100
|
+
url: '#',
|
|
101
|
+
icon: 'logo-env',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
title: 'Toggle',
|
|
105
|
+
url: '#',
|
|
106
|
+
icon: 'logo-toggle',
|
|
107
|
+
items: [
|
|
108
|
+
{
|
|
109
|
+
title: 'Feature Toggles',
|
|
110
|
+
url: '#',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
title: 'Segments',
|
|
114
|
+
url: '#',
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
title: 'Integrations',
|
|
120
|
+
url: '#',
|
|
121
|
+
icon: 'stack',
|
|
122
|
+
count: 23,
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
title: 'Settings',
|
|
126
|
+
url: '#',
|
|
127
|
+
icon: 'settings',
|
|
128
|
+
items: [
|
|
129
|
+
{
|
|
130
|
+
title: 'General',
|
|
131
|
+
url: '#',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
title: 'Members',
|
|
135
|
+
url: '#',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
title: 'Billing',
|
|
139
|
+
url: '#',
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
favorites: [
|
|
145
|
+
{
|
|
146
|
+
name: 'Project One',
|
|
147
|
+
url: '#',
|
|
148
|
+
icon: 'block',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'Spring Campaign Link',
|
|
152
|
+
url: '#',
|
|
153
|
+
icon: 'logo-link',
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: 'Fall Campaign Link',
|
|
157
|
+
url: '#',
|
|
158
|
+
icon: 'logo-link',
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// type Story = StoryObj<typeof Sidebar>;
|
|
164
|
+
|
|
165
|
+
export const SidebarExample = () => {
|
|
166
|
+
const [activeTeam, setActiveTeam] = React.useState(data.teams[0]);
|
|
167
|
+
const isMobile = useIsMobile();
|
|
168
|
+
return (
|
|
169
|
+
<ResponsiveProvider>
|
|
170
|
+
<SidebarProvider>
|
|
171
|
+
<Sidebar side="left" collapsible="offcanvas">
|
|
172
|
+
<SidebarHeader>
|
|
173
|
+
<SidebarMenu>
|
|
174
|
+
<SidebarMenuItem>
|
|
175
|
+
<DropdownMenu>
|
|
176
|
+
<DropdownMenuTrigger asChild>
|
|
177
|
+
<SidebarMenuButton>
|
|
178
|
+
<Box
|
|
179
|
+
flex="auto"
|
|
180
|
+
direction="row"
|
|
181
|
+
gap="sm"
|
|
182
|
+
alignItems="center"
|
|
183
|
+
>
|
|
184
|
+
<Box
|
|
185
|
+
background="black"
|
|
186
|
+
borderColor="subtle"
|
|
187
|
+
borderWidth="sm"
|
|
188
|
+
width="4xl"
|
|
189
|
+
height="4xl"
|
|
190
|
+
alignItems="center"
|
|
191
|
+
justifyContent="center"
|
|
192
|
+
radius="md"
|
|
193
|
+
></Box>
|
|
194
|
+
<span className="font-weight-semibold">
|
|
195
|
+
{activeTeam.name}
|
|
196
|
+
</span>
|
|
197
|
+
</Box>
|
|
198
|
+
<Icon name="caret-up-down" />
|
|
199
|
+
</SidebarMenuButton>
|
|
200
|
+
</DropdownMenuTrigger>
|
|
201
|
+
<DropdownMenuContent
|
|
202
|
+
align="start"
|
|
203
|
+
side="bottom"
|
|
204
|
+
sideOffset={4}
|
|
205
|
+
>
|
|
206
|
+
<DropdownMenuLabel className="text-xs text-muted-foreground">
|
|
207
|
+
Organizations
|
|
208
|
+
</DropdownMenuLabel>
|
|
209
|
+
{data.teams.map((team, index) => (
|
|
210
|
+
<DropdownMenuItem
|
|
211
|
+
key={team.name}
|
|
212
|
+
onClick={() => setActiveTeam(team)}
|
|
213
|
+
>
|
|
214
|
+
{team.name}
|
|
215
|
+
<DropdownMenuShortcut>
|
|
216
|
+
⌘{index + 1}
|
|
217
|
+
</DropdownMenuShortcut>
|
|
218
|
+
</DropdownMenuItem>
|
|
219
|
+
))}
|
|
220
|
+
<DropdownMenuSeparator />
|
|
221
|
+
<DropdownMenuItem>
|
|
222
|
+
<a
|
|
223
|
+
href="#"
|
|
224
|
+
className="display-flex flex-direction-row g-sm align-items-center"
|
|
225
|
+
>
|
|
226
|
+
<Icon name="add" color="tertiary" />
|
|
227
|
+
<span>Create Organization</span>
|
|
228
|
+
</a>
|
|
229
|
+
</DropdownMenuItem>
|
|
230
|
+
</DropdownMenuContent>
|
|
231
|
+
</DropdownMenu>
|
|
232
|
+
</SidebarMenuItem>
|
|
233
|
+
</SidebarMenu>
|
|
234
|
+
</SidebarHeader>
|
|
235
|
+
<SidebarContent>
|
|
236
|
+
<SidebarGroup>
|
|
237
|
+
<SidebarGroupLabel>Platform</SidebarGroupLabel>
|
|
238
|
+
<SidebarMenu>
|
|
239
|
+
{data.navMain.map((item) =>
|
|
240
|
+
item.items ? (
|
|
241
|
+
<Collapsible
|
|
242
|
+
key={item.title}
|
|
243
|
+
className="group/collapsible"
|
|
244
|
+
asChild
|
|
245
|
+
>
|
|
246
|
+
<SidebarMenuItem>
|
|
247
|
+
<CollapsibleTrigger asChild>
|
|
248
|
+
<SidebarMenuButton>
|
|
249
|
+
<Icon
|
|
250
|
+
name={item.icon as IconName}
|
|
251
|
+
color="tertiary"
|
|
252
|
+
size="lg"
|
|
253
|
+
/>
|
|
254
|
+
{item.title}
|
|
255
|
+
<Icon
|
|
256
|
+
name="caret-sm-right"
|
|
257
|
+
className="m-left-auto transform data-[state=open]:rotate-90"
|
|
258
|
+
/>
|
|
259
|
+
</SidebarMenuButton>
|
|
260
|
+
</CollapsibleTrigger>
|
|
261
|
+
<CollapsibleContent>
|
|
262
|
+
<SidebarMenuSub>
|
|
263
|
+
{item.items?.map((subItem) => (
|
|
264
|
+
<SidebarMenuSubItem key={subItem.title}>
|
|
265
|
+
<SidebarMenuSubButton asChild>
|
|
266
|
+
<a href={subItem.url}>
|
|
267
|
+
<span>{subItem.title}</span>
|
|
268
|
+
</a>
|
|
269
|
+
</SidebarMenuSubButton>
|
|
270
|
+
</SidebarMenuSubItem>
|
|
271
|
+
))}
|
|
272
|
+
</SidebarMenuSub>
|
|
273
|
+
</CollapsibleContent>
|
|
274
|
+
</SidebarMenuItem>
|
|
275
|
+
</Collapsible>
|
|
276
|
+
) : (
|
|
277
|
+
<SidebarMenuItem key={item.title}>
|
|
278
|
+
<SidebarMenuButton asChild isActive={item.isActive}>
|
|
279
|
+
<a href={item.url}>
|
|
280
|
+
<Icon
|
|
281
|
+
name={item.icon as IconName}
|
|
282
|
+
color="tertiary"
|
|
283
|
+
size="lg"
|
|
284
|
+
/>
|
|
285
|
+
<span>{item.title}</span>
|
|
286
|
+
</a>
|
|
287
|
+
</SidebarMenuButton>
|
|
288
|
+
{item.count && (
|
|
289
|
+
<SidebarMenuBadge>{item.count}</SidebarMenuBadge>
|
|
290
|
+
)}
|
|
291
|
+
</SidebarMenuItem>
|
|
292
|
+
)
|
|
293
|
+
)}
|
|
294
|
+
</SidebarMenu>
|
|
295
|
+
</SidebarGroup>
|
|
296
|
+
<SidebarGroup>
|
|
297
|
+
<SidebarGroupLabel>Favorites</SidebarGroupLabel>
|
|
298
|
+
<SidebarMenu>
|
|
299
|
+
{data.favorites.map((item) => (
|
|
300
|
+
<SidebarMenuItem key={item.name}>
|
|
301
|
+
<SidebarMenuButton asChild>
|
|
302
|
+
<a href={item.url}>
|
|
303
|
+
<Icon name={item.icon as IconName} color="tertiary" />
|
|
304
|
+
<span>{item.name}</span>
|
|
305
|
+
</a>
|
|
306
|
+
</SidebarMenuButton>
|
|
307
|
+
<DropdownMenu>
|
|
308
|
+
<DropdownMenuTrigger asChild>
|
|
309
|
+
<SidebarMenuAction>
|
|
310
|
+
<Icon name="dots" />
|
|
311
|
+
<span className="sr-only">More</span>
|
|
312
|
+
</SidebarMenuAction>
|
|
313
|
+
</DropdownMenuTrigger>
|
|
314
|
+
<DropdownMenuContent side="bottom" align="end">
|
|
315
|
+
<DropdownMenuItem>
|
|
316
|
+
<a href="#">View</a>
|
|
317
|
+
</DropdownMenuItem>
|
|
318
|
+
<DropdownMenuItem>
|
|
319
|
+
<a href="#">Share</a>
|
|
320
|
+
</DropdownMenuItem>
|
|
321
|
+
<DropdownMenuSeparator />
|
|
322
|
+
<DropdownMenuItem>
|
|
323
|
+
<a href="#">Remove</a>
|
|
324
|
+
</DropdownMenuItem>
|
|
325
|
+
</DropdownMenuContent>
|
|
326
|
+
</DropdownMenu>
|
|
327
|
+
</SidebarMenuItem>
|
|
328
|
+
))}
|
|
329
|
+
</SidebarMenu>
|
|
330
|
+
</SidebarGroup>
|
|
331
|
+
</SidebarContent>
|
|
332
|
+
<SidebarRail />
|
|
333
|
+
<SidebarFooter>
|
|
334
|
+
<SidebarMenu>
|
|
335
|
+
<SidebarMenuItem>
|
|
336
|
+
<DropdownMenu>
|
|
337
|
+
<DropdownMenuTrigger asChild>
|
|
338
|
+
<SidebarMenuButton>
|
|
339
|
+
<Box flex="auto" direction="column" gap="2xs">
|
|
340
|
+
<span className="font-weight-semibold">
|
|
341
|
+
{data.user.name}
|
|
342
|
+
</span>
|
|
343
|
+
<span className="truncate font-size-xs font-color-secondary">
|
|
344
|
+
{data.user.email}
|
|
345
|
+
</span>
|
|
346
|
+
</Box>
|
|
347
|
+
<Icon name="caret-up-down" />
|
|
348
|
+
</SidebarMenuButton>
|
|
349
|
+
</DropdownMenuTrigger>
|
|
350
|
+
<DropdownMenuContent side="bottom" align="end" sideOffset={4}>
|
|
351
|
+
<DropdownMenuLabel>
|
|
352
|
+
<Box flex="auto" direction="column" gap="2xs">
|
|
353
|
+
<span className="font-weight-semibold">
|
|
354
|
+
{data.user.name}
|
|
355
|
+
</span>
|
|
356
|
+
<span className="truncate font-size-xs font-color-secondary">
|
|
357
|
+
{data.user.email}
|
|
358
|
+
</span>
|
|
359
|
+
</Box>
|
|
360
|
+
</DropdownMenuLabel>
|
|
361
|
+
<DropdownMenuSeparator />
|
|
362
|
+
<DropdownMenuGroup>
|
|
363
|
+
<DropdownMenuItem>
|
|
364
|
+
<Icon name="user" color="tertiary" />
|
|
365
|
+
Profile
|
|
366
|
+
</DropdownMenuItem>
|
|
367
|
+
<DropdownMenuItem>
|
|
368
|
+
<Icon name="alarm" color="tertiary" />
|
|
369
|
+
Notifications{' '}
|
|
370
|
+
</DropdownMenuItem>
|
|
371
|
+
</DropdownMenuGroup>
|
|
372
|
+
<DropdownMenuSeparator />
|
|
373
|
+
<DropdownMenuItem>
|
|
374
|
+
<Icon name="logout" color="tertiary" />
|
|
375
|
+
Log out
|
|
376
|
+
</DropdownMenuItem>
|
|
377
|
+
</DropdownMenuContent>
|
|
378
|
+
</DropdownMenu>
|
|
379
|
+
</SidebarMenuItem>
|
|
380
|
+
</SidebarMenu>
|
|
381
|
+
</SidebarFooter>
|
|
382
|
+
</Sidebar>
|
|
383
|
+
<SidebarInset>
|
|
384
|
+
{isMobile && <SidebarTrigger />}
|
|
385
|
+
<Card height="100" padding="2xl">
|
|
386
|
+
content
|
|
387
|
+
</Card>
|
|
388
|
+
</SidebarInset>
|
|
389
|
+
</SidebarProvider>
|
|
390
|
+
</ResponsiveProvider>
|
|
391
|
+
);
|
|
392
|
+
};
|