Skip to content

Commit 0c19c64

Browse files
committed
ui
1 parent 22020cf commit 0c19c64

3 files changed

Lines changed: 787 additions & 661 deletions

File tree

packages/interface/src/components/SpacesSidebar/SpaceSwitcher.tsx

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,69 @@
1+
import {CaretDown, GearSix, Plus} from '@phosphor-icons/react';
2+
import type {Space} from '@sd/ts-client';
3+
import {DropdownMenu, SelectPill} from '@spaceui/primitives';
14
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';
66

77
interface SpaceSwitcherProps {
88
spaces: Space[] | undefined;
99
currentSpace: Space | undefined;
1010
onSwitch: (spaceId: string) => void;
1111
}
1212

13-
export function SpaceSwitcher({ spaces, currentSpace, onSwitch }: SpaceSwitcherProps) {
13+
export function SpaceSwitcher({
14+
spaces,
15+
currentSpace,
16+
onSwitch
17+
}: SpaceSwitcherProps) {
1418
const createSpaceDialog = useCreateSpaceDialog;
1519

1620
return (
1721
<DropdownMenu.Root>
1822
<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">
2924
<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'}}
3227
/>
33-
<span className="truncate flex-1 text-left">
28+
<span className="flex-1 truncate text-left">
3429
{currentSpace?.name || 'Select Space'}
3530
</span>
36-
<CaretDown className="size-3 opacity-50" />
37-
</button>
31+
</SelectPill>
3832
</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">
4034
{spaces && spaces.length > 1
4135
? spaces.map((space) => (
4236
<DropdownMenu.Item
4337
key={space.id}
4438
onClick={() => onSwitch(space.id)}
4539
className={clsx(
46-
"px-2 py-1 text-sm rounded-md",
40+
'rounded-md px-2 py-1 text-sm',
4741
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'
5044
)}
5145
>
5246
<div className="flex items-center gap-2">
5347
<div
5448
className="size-2 rounded-full"
55-
style={{ backgroundColor: space.color }}
49+
style={{backgroundColor: space.color}}
5650
/>
5751
<span>{space.name}</span>
5852
</div>
5953
</DropdownMenu.Item>
60-
))
54+
))
6155
: null}
6256
{spaces && spaces.length > 1 && (
6357
<DropdownMenu.Separator className="border-sidebar-line my-1" />
6458
)}
6559
<DropdownMenu.Item
6660
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"
6862
>
6963
<Plus className="mr-2 size-4" weight="bold" />
7064
New Space
7165
</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">
7567
<GearSix className="mr-2 size-4" weight="bold" />
7668
Space Settings
7769
</DropdownMenu.Item>

0 commit comments

Comments
 (0)