@hyphen/hyphen-components 5.7.2 → 5.7.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyphen/hyphen-components",
3
- "version": "5.7.2",
3
+ "version": "5.7.3",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "@hyphen"
@@ -182,7 +182,12 @@ export const SidebarExample = () => {
182
182
  <SidebarRail />
183
183
  </Sidebar>
184
184
  <SidebarInset>
185
- {isMobile && <SidebarTrigger />}
185
+ {isMobile && (
186
+ <Box direction="row" gap="sm" alignItems="center">
187
+ <SidebarTrigger />
188
+ <CreateMenu />
189
+ </Box>
190
+ )}
186
191
  <Card height="100" padding="2xl">
187
192
  content
188
193
  </Card>
@@ -197,14 +202,10 @@ export const SidebarCollapsed = () => {
197
202
 
198
203
  const [activeTeam, setActiveTeam] = React.useState(data.teams[0]);
199
204
  const isMobile = useIsMobile();
200
- const startOpen = localStorage.getItem(STORAGE_KEY) || 'false';
201
205
 
202
206
  return (
203
207
  <ResponsiveProvider>
204
- <SidebarProvider
205
- storageKey={STORAGE_KEY}
206
- defaultOpen={startOpen === 'true'}
207
- >
208
+ <SidebarProvider storageKey={STORAGE_KEY} defaultOpen={false}>
208
209
  <Sidebar side="left" collapsible="icon">
209
210
  <NavHeader activeTeam={activeTeam} setActiveTeam={setActiveTeam} />
210
211
  <SidebarContent>
@@ -215,7 +216,12 @@ export const SidebarCollapsed = () => {
215
216
  <SidebarRail />
216
217
  </Sidebar>
217
218
  <SidebarInset>
218
- {isMobile && <SidebarTrigger />}
219
+ {isMobile && (
220
+ <Box direction="row" gap="sm" alignItems="center">
221
+ <SidebarTrigger />
222
+ <CreateMenu />
223
+ </Box>
224
+ )}
219
225
  <Card height="100" padding="2xl">
220
226
  content
221
227
  </Card>
@@ -244,75 +250,21 @@ const NavHeader = ({
244
250
  activeTeam: any;
245
251
  setActiveTeam: (team: any) => void;
246
252
  }) => {
247
- const { state } = useSidebar();
253
+ const { state, isMobile } = useSidebar();
254
+
255
+ const isCollapsed = state === 'collapsed';
248
256
 
249
257
  return (
250
258
  <SidebarHeader>
251
259
  <SidebarMenu>
252
260
  <SidebarMenuItem>
253
- <DropdownMenu>
254
- <DropdownMenuTrigger asChild>
255
- <SidebarMenuButton style={{ padding: 'var(--size-spacing-xs)' }}>
256
- <Box flex="auto" direction="row" gap="sm" alignItems="center">
257
- <Box
258
- background="black"
259
- borderColor="subtle"
260
- borderWidth="sm"
261
- width="24px"
262
- height="24px"
263
- minWidth="24px"
264
- minHeight="24px"
265
- alignItems="center"
266
- justifyContent="center"
267
- radius="sm"
268
- color="white"
269
- fontSize="xs"
270
- fontWeight="bold"
271
- >
272
- AC
273
- </Box>
274
- <span
275
- className="font-weight-semibold"
276
- style={{ whiteSpace: 'nowrap' }}
277
- >
278
- {activeTeam.name}
279
- </span>
280
- </Box>
281
- <Icon
282
- name="caret-up-down"
283
- className="group-data-collapsible-icon-hidden"
284
- />
285
- </SidebarMenuButton>
286
- </DropdownMenuTrigger>
287
- <DropdownMenuContent
288
- align="start"
289
- side={state === 'expanded' ? 'bottom' : 'right'}
290
- sideOffset={4}
291
- >
292
- <DropdownMenuLabel className="text-xs text-muted-foreground">
293
- Organizations
294
- </DropdownMenuLabel>
295
- {data.teams.map((team, index) => (
296
- <DropdownMenuItem
297
- key={`team.name-${index}`}
298
- onClick={() => setActiveTeam(team)}
299
- >
300
- {team.name}
301
- <DropdownMenuShortcut>⌘{index + 1}</DropdownMenuShortcut>
302
- </DropdownMenuItem>
303
- ))}
304
- <DropdownMenuSeparator />
305
- <DropdownMenuItem>
306
- <a
307
- href="https://ux.hyphen.ai"
308
- className="display-flex flex-direction-row g-sm align-items-center"
309
- >
310
- <Icon name="add" color="tertiary" />
311
- <span>Create Organization</span>
312
- </a>
313
- </DropdownMenuItem>
314
- </DropdownMenuContent>
315
- </DropdownMenu>
261
+ <Box direction="row" alignItems="center" gap="sm">
262
+ <OrgSwitcher
263
+ activeTeam={activeTeam}
264
+ setActiveTeam={setActiveTeam}
265
+ />
266
+ {!isMobile && !isCollapsed && <CreateMenu />}
267
+ </Box>
316
268
  </SidebarMenuItem>
317
269
  </SidebarMenu>
318
270
  </SidebarHeader>
@@ -423,7 +375,7 @@ const NavFooter = () => {
423
375
  <DropdownMenu>
424
376
  <DropdownMenuTrigger asChild>
425
377
  <SidebarMenuButton tooltip="Your Profile">
426
- <Icon name="user" size="lg" color="tertiary" />
378
+ <Icon name="c-user" size="lg" color="tertiary" />
427
379
  <Box flex="auto" direction="column" gap="2xs">
428
380
  <span className="font-weight-semibold">{data.user.name}</span>
429
381
  <span className="truncate font-size-xs font-color-secondary">
@@ -510,3 +462,165 @@ const NavFavorites = ({ favorites }: { favorites: typeof data.favorites }) => (
510
462
  </SidebarMenu>
511
463
  </SidebarGroup>
512
464
  );
465
+
466
+ function CreateMenu() {
467
+ const menuItems = [
468
+ {
469
+ key: 'project',
470
+ to: `/#`,
471
+ label: 'Project',
472
+ },
473
+ {
474
+ key: 'app',
475
+ to: `/#`,
476
+ label: 'App',
477
+ },
478
+ {
479
+ key: 'deployment',
480
+ to: `/#`,
481
+ label: 'Deployment Policy',
482
+ },
483
+ {
484
+ key: 'feature-flag',
485
+ to: `/#`,
486
+ label: 'Feature Flag',
487
+ },
488
+ {
489
+ key: 'segment',
490
+ to: `/#`,
491
+ label: 'Segment',
492
+ },
493
+ {
494
+ key: 'short-link',
495
+ to: `/#`,
496
+ label: 'Short Link',
497
+ },
498
+ {
499
+ key: 'team',
500
+ to: `/#`,
501
+ label: 'Team',
502
+ },
503
+ {
504
+ key: 'invite-member',
505
+ to: `/#`,
506
+ label: 'Invite Member',
507
+ },
508
+ ] as Array<{ key: string; to: string; label: string }>;
509
+
510
+ return (
511
+ <DropdownMenu>
512
+ <DropdownMenuTrigger asChild>
513
+ <Box
514
+ as="button"
515
+ type="button"
516
+ color="base"
517
+ alignItems="center"
518
+ justifyContent="center"
519
+ padding="sm"
520
+ radius="sm"
521
+ hover={{
522
+ background: 'button-tertiary-hover',
523
+ color: 'button-tertiary-hover',
524
+ }}
525
+ borderWidth="0"
526
+ background="primary"
527
+ cursor="pointer"
528
+ shadow="xs"
529
+ >
530
+ <Icon name="add" />
531
+ </Box>
532
+ </DropdownMenuTrigger>
533
+ <DropdownMenuContent align="start" side="bottom" sideOffset={4}>
534
+ {menuItems.map(({ key, to, label }) => (
535
+ <DropdownMenuItem asChild key={key}>
536
+ <a href={to} className="navlink">
537
+ <span>{label}</span>
538
+ </a>
539
+ </DropdownMenuItem>
540
+ ))}
541
+ </DropdownMenuContent>
542
+ </DropdownMenu>
543
+ );
544
+ }
545
+
546
+ const OrgSwitcher = ({
547
+ activeTeam,
548
+ setActiveTeam,
549
+ }: {
550
+ activeTeam: any;
551
+ setActiveTeam: (team: any) => void;
552
+ }) => {
553
+ const { state } = useSidebar();
554
+
555
+ const isCollapsed = state === 'collapsed';
556
+
557
+ return (
558
+ <DropdownMenu>
559
+ <DropdownMenuTrigger asChild>
560
+ <SidebarMenuButton style={{ padding: 'var(--size-spacing-xs)' }}>
561
+ <Box flex="auto" direction="row" gap="sm" alignItems="center">
562
+ <Box
563
+ background="black"
564
+ borderColor="subtle"
565
+ borderWidth="sm"
566
+ width="24px"
567
+ height="24px"
568
+ minWidth="24px"
569
+ minHeight="24px"
570
+ alignItems="center"
571
+ justifyContent="center"
572
+ radius="sm"
573
+ color="white"
574
+ fontSize="xs"
575
+ fontWeight="bold"
576
+ >
577
+ AC
578
+ </Box>
579
+ {!isCollapsed && (
580
+ <span
581
+ className="font-weight-semibold"
582
+ style={{ whiteSpace: 'nowrap' }}
583
+ >
584
+ {activeTeam.name}
585
+ </span>
586
+ )}
587
+ </Box>
588
+ {!isCollapsed && (
589
+ <Icon
590
+ name="caret-up-down"
591
+ className="group-data-collapsible-icon-hidden"
592
+ />
593
+ )}
594
+ </SidebarMenuButton>
595
+ </DropdownMenuTrigger>
596
+ <DropdownMenuContent
597
+ align="start"
598
+ side={state === 'expanded' ? 'bottom' : 'right'}
599
+ sideOffset={4}
600
+ >
601
+ <DropdownMenuLabel className="text-xs text-muted-foreground">
602
+ Organizations
603
+ </DropdownMenuLabel>
604
+ {data.teams.map((team, index) => (
605
+ <DropdownMenuItem
606
+ key={`team.name-${index}`}
607
+ onClick={() => setActiveTeam(team)}
608
+ >
609
+ {team.name}
610
+ <DropdownMenuShortcut>⌘{index + 1}</DropdownMenuShortcut>
611
+ </DropdownMenuItem>
612
+ ))}
613
+ <DropdownMenuSeparator />
614
+ <DropdownMenuItem>
615
+ <a
616
+ href="https://ux.hyphen.ai"
617
+ className="display-flex flex-direction-row g-sm align-items-center"
618
+ >
619
+ <Icon name="add" color="tertiary" />
620
+ <span>Create Organization</span>
621
+ </a>
622
+ </DropdownMenuItem>
623
+ </DropdownMenuContent>
624
+ </DropdownMenu>
625
+ );
626
+ };
@@ -331,7 +331,7 @@ const SidebarHeader = React.forwardRef<
331
331
  ref={ref}
332
332
  data-sidebar="header"
333
333
  className={classNames(
334
- 'display-flex g-sm p-v-md p-h-md p-right-0-desktop overflow-hidden',
334
+ 'display-flex g-sm p-v-md p-h-md p-right-0-desktop',
335
335
  className
336
336
  )}
337
337
  {...props}