|
| 1 | +import {CaretDown, GearSix, Plus} from '@phosphor-icons/react'; |
| 2 | +import type {Space} from '@sd/ts-client'; |
| 3 | +import {DropdownMenu, SelectPill} from '@spaceui/primitives'; |
1 | 4 | import clsx from 'clsx'; |
2 | | -import { CaretDown, Plus, GearSix } from '@phosphor-icons/react'; |
3 | | -import { DropdownMenu } from '@spaceui/primitives'; |
4 | | -import type { Space } from '@sd/ts-client'; |
5 | | -import { useCreateSpaceDialog } from './CreateSpaceModal'; |
| 5 | +import {useCreateSpaceDialog} from './CreateSpaceModal'; |
6 | 6 |
|
7 | 7 | interface SpaceSwitcherProps { |
8 | 8 | spaces: Space[] | undefined; |
9 | 9 | currentSpace: Space | undefined; |
10 | 10 | onSwitch: (spaceId: string) => void; |
11 | 11 | } |
12 | 12 |
|
13 | | -export function SpaceSwitcher({ spaces, currentSpace, onSwitch }: SpaceSwitcherProps) { |
| 13 | +export function SpaceSwitcher({ |
| 14 | + spaces, |
| 15 | + currentSpace, |
| 16 | + onSwitch |
| 17 | +}: SpaceSwitcherProps) { |
14 | 18 | const createSpaceDialog = useCreateSpaceDialog; |
15 | 19 |
|
16 | 20 | return ( |
17 | 21 | <DropdownMenu.Root> |
18 | 22 | <DropdownMenu.Trigger asChild> |
19 | | - <button |
20 | | - className={clsx( |
21 | | - "w-full flex items-center gap-1.5 rounded-lg px-2 py-1.5 text-sm font-medium", |
22 | | - "bg-sidebar-box border border-sidebar-line", |
23 | | - "text-sidebar-ink hover:bg-sidebar-button", |
24 | | - "focus:outline-none focus:ring-1 focus:ring-accent", |
25 | | - "transition-colors", |
26 | | - !currentSpace && "text-sidebar-inkFaint" |
27 | | - )} |
28 | | - > |
| 23 | + <SelectPill variant="sidebar" size="lg"> |
29 | 24 | <div |
30 | | - className="size-2 rounded-full shrink-0" |
31 | | - style={{ backgroundColor: currentSpace?.color || '#666' }} |
| 25 | + className="size-2 rounded-full" |
| 26 | + style={{backgroundColor: currentSpace?.color || '#666'}} |
32 | 27 | /> |
33 | | - <span className="truncate flex-1 text-left"> |
| 28 | + <span className="flex-1 truncate text-left"> |
34 | 29 | {currentSpace?.name || 'Select Space'} |
35 | 30 | </span> |
36 | | - <CaretDown className="size-3 opacity-50" /> |
37 | | - </button> |
| 31 | + </SelectPill> |
38 | 32 | </DropdownMenu.Trigger> |
39 | | - <DropdownMenu.Content className="p-1 min-w-[var(--radix-dropdown-menu-trigger-width)]"> |
| 33 | + <DropdownMenu.Content className="min-w-[var(--radix-dropdown-menu-trigger-width)] p-1"> |
40 | 34 | {spaces && spaces.length > 1 |
41 | 35 | ? spaces.map((space) => ( |
42 | 36 | <DropdownMenu.Item |
43 | 37 | key={space.id} |
44 | 38 | onClick={() => onSwitch(space.id)} |
45 | 39 | className={clsx( |
46 | | - "px-2 py-1 text-sm rounded-md", |
| 40 | + 'rounded-md px-2 py-1 text-sm', |
47 | 41 | space.id === currentSpace?.id |
48 | | - ? "bg-accent text-white" |
49 | | - : "text-sidebar-ink hover:bg-sidebar-selected" |
| 42 | + ? 'bg-accent text-white' |
| 43 | + : 'text-sidebar-ink hover:bg-sidebar-selected' |
50 | 44 | )} |
51 | 45 | > |
52 | 46 | <div className="flex items-center gap-2"> |
53 | 47 | <div |
54 | 48 | className="size-2 rounded-full" |
55 | | - style={{ backgroundColor: space.color }} |
| 49 | + style={{backgroundColor: space.color}} |
56 | 50 | /> |
57 | 51 | <span>{space.name}</span> |
58 | 52 | </div> |
59 | 53 | </DropdownMenu.Item> |
60 | | - )) |
| 54 | + )) |
61 | 55 | : null} |
62 | 56 | {spaces && spaces.length > 1 && ( |
63 | 57 | <DropdownMenu.Separator className="border-sidebar-line my-1" /> |
64 | 58 | )} |
65 | 59 | <DropdownMenu.Item |
66 | 60 | onClick={() => createSpaceDialog()} |
67 | | - className="px-2 py-1 text-sm rounded-md hover:bg-sidebar-selected text-sidebar-ink font-medium" |
| 61 | + className="hover:bg-sidebar-selected text-sidebar-ink rounded-md px-2 py-1 text-sm font-medium" |
68 | 62 | > |
69 | 63 | <Plus className="mr-2 size-4" weight="bold" /> |
70 | 64 | New Space |
71 | 65 | </DropdownMenu.Item> |
72 | | - <DropdownMenu.Item |
73 | | - className="px-2 py-1 text-sm rounded-md hover:bg-sidebar-selected text-sidebar-ink font-medium" |
74 | | - > |
| 66 | + <DropdownMenu.Item className="hover:bg-sidebar-selected text-sidebar-ink rounded-md px-2 py-1 text-sm font-medium"> |
75 | 67 | <GearSix className="mr-2 size-4" weight="bold" /> |
76 | 68 | Space Settings |
77 | 69 | </DropdownMenu.Item> |
|
0 commit comments