Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Admin UI fixes

Damian Legawiec532722179c6b
diff --git a/packages/admin/src/components/app-sidebar.tsx b/packages/admin/src/components/app-sidebar.tsx
index eaceed90f3..8f5cb60730 100644
--- a/packages/admin/src/components/app-sidebar.tsx
+++ b/packages/admin/src/components/app-sidebar.tsx
@@ -1,3 +1,13 @@
+import {
+ BarChart3Icon,
+ HomeIcon,
+ InboxIcon,
+ type LucideIcon,
+ PackageIcon,
+ SettingsIcon,
+ TagIcon,
+ UsersIcon,
+} from 'lucide-react'
import type { ComponentProps } from 'react'
import { NavMain } from '@/components/nav-main'
import { NavUser } from '@/components/nav-user'
@@ -7,7 +17,7 @@ import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader } from '@/compone
export type NavItem = {
title: string
url: string
- icon: string
+ icon: LucideIcon
items?: { title: string; url: string }[]
}
@@ -15,18 +25,18 @@ const navigation: NavItem[] = [
{
title: 'Home',
url: '/',
- icon: 'home',
+ icon: HomeIcon,
},
{
title: 'Orders',
url: '/orders',
- icon: 'inbox',
+ icon: InboxIcon,
items: [{ title: 'Draft Orders', url: '/orders/drafts' }],
},
{
title: 'Products',
url: '/products',
- icon: 'package',
+ icon: PackageIcon,
items: [
{ title: 'Price Lists', url: '/products/price-lists' },
{ title: 'Stock', url: '/products/stock' },
@@ -37,18 +47,18 @@ const navigation: NavItem[] = [
{
title: 'Customers',
url: '/customers',
- icon: 'users',
+ icon: UsersIcon,
},
{
title: 'Promotions',
url: '/promotions',
- icon: 'discount',
+ icon: TagIcon,
items: [{ title: 'Gift Cards', url: '/promotions/gift-cards' }],
},
{
title: 'Reports',
url: '/reports',
- icon: 'chart-bar',
+ icon: BarChart3Icon,
},
]
@@ -56,7 +66,7 @@ const bottomNavigation: NavItem[] = [
{
title: 'Settings',
url: '/settings',
- icon: 'settings',
+ icon: SettingsIcon,
},
]
diff --git a/packages/admin/src/components/nav-main.tsx b/packages/admin/src/components/nav-main.tsx
index 0366a92b78..edabd6485d 100644
--- a/packages/admin/src/components/nav-main.tsx
+++ b/packages/admin/src/components/nav-main.tsx
@@ -1,6 +1,12 @@
import { Link, useRouterState } from '@tanstack/react-router'
+import { useState } from 'react'
import type { NavItem } from '@/components/app-sidebar'
-import { TablerIcon } from '@/components/tabler-icon'
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu'
import {
SidebarGroup,
SidebarMenu,
@@ -9,71 +15,127 @@ import {
SidebarMenuSub,
SidebarMenuSubButton,
SidebarMenuSubItem,
+ useSidebar,
} from '@/components/ui/sidebar'
-function NavIcon({ name, isActive }: { name: string; isActive?: boolean }) {
+function NavIcon({ icon: Icon, isActive }: { icon: NavItem['icon']; isActive?: boolean }) {
return (
<span
className={
- 'inline-flex shrink-0 items-center justify-center rounded-lg p-[0.2rem] mr-2 transition-colors duration-100 ' +
+ 'inline-flex shrink-0 items-center justify-center rounded-lg p-[0.2rem] transition-colors duration-100 ' +
(isActive
? 'bg-zinc-950 text-white'
: 'text-gray-400 group-hover/menu-button:text-zinc-950')
}
>
- <TablerIcon name={name} className="size-[1.125rem]" />
+ <Icon className="size-[1.125rem]" strokeWidth={2.25} />
</span>
)
}
+function CollapsedDropdown({ item, children }: { item: NavItem; children: React.ReactNode }) {
+ const [open, setOpen] = useState(false)
+
+ return (
+ <DropdownMenu open={open} onOpenChange={setOpen}>
+ <DropdownMenuTrigger asChild onMouseEnter={() => setOpen(true)}>
+ {/* biome-ignore lint/a11y/noStaticElementInteractions: hover trigger for collapsed nav */}
+ <div onMouseLeave={() => setOpen(false)}>{children}</div>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent
+ side="right"
+ align="start"
+ sideOffset={4}
+ onMouseLeave={() => setOpen(false)}
+ onMouseEnter={() => setOpen(true)}
+ >
+ {item.items!.map((subItem) => (
+ <DropdownMenuItem key={subItem.title} asChild>
+ <Link to={subItem.url} className="no-underline">
+ {subItem.title}
+ </Link>
+ </DropdownMenuItem>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )
+}
+
+function NavItemContent({
+ item,
+ currentPath,
+ isCollapsed,
+}: {
+ item: NavItem
+ currentPath: string
+ isCollapsed: boolean
+}) {
+ const isExactActive = currentPath === item.url
+ const isActive = isExactActive || (item.url !== '/' && currentPath.startsWith(item.url))
+ const hasActiveChild = item.items?.some(
+ (sub) => currentPath === sub.url || currentPath.startsWith(sub.url),
+ )
+ const showSubmenu = isActive || hasActiveChild
+ const itemIsActive = isActive || !!hasActiveChild
+
+ const button = (
+ <SidebarMenuButton
+ tooltip={!item.items || !isCollapsed ? item.title : undefined}
+ asChild
+ isActive={itemIsActive}
+ >
+ <Link to={item.url}>
+ <NavIcon icon={item.icon} isActive={itemIsActive} />
+ <span>{item.title}</span>
+ </Link>
+ </SidebarMenuButton>
+ )
+
+ return (
+ <SidebarMenuItem>
+ {isCollapsed && item.items ? (
+ <CollapsedDropdown item={item}>{button}</CollapsedDropdown>
+ ) : (
+ button
+ )}
+ {item.items && showSubmenu && (
+ <SidebarMenuSub>
+ {item.items.map((subItem) => {
+ const subActive = currentPath === subItem.url || currentPath.startsWith(subItem.url)
+ return (
+ <SidebarMenuSubItem key={subItem.title}>
+ <SidebarMenuSubButton asChild isActive={subActive}>
+ <Link to={subItem.url}>
+ <span>{subItem.title}</span>
+ </Link>
+ </SidebarMenuSubButton>
+ </SidebarMenuSubItem>
+ )
+ })}
+ </SidebarMenuSub>
+ )}
+ </SidebarMenuItem>
+ )
+}
+
export function NavMain({ items, bottomItems }: { items: NavItem[]; bottomItems?: NavItem[] }) {
const routerState = useRouterState()
const currentPath = routerState.location.pathname
+ const { state } = useSidebar()
+ const isCollapsed = state === 'collapsed'
return (
<>
<SidebarGroup>
<SidebarMenu>
- {items.map((item) => {
- const isExactActive = currentPath === item.url
- const isActive = isExactActive || (item.url !== '/' && currentPath.startsWith(item.url))
- const hasActiveChild = item.items?.some(
- (sub) => currentPath === sub.url || currentPath.startsWith(sub.url),
- )
- const showSubmenu = isActive || hasActiveChild
-
- return (
- <SidebarMenuItem key={item.title}>
- <SidebarMenuButton
- tooltip={item.title}
- asChild
- isActive={isActive && !hasActiveChild}
- >
- <Link to={item.url}>
- <NavIcon name={item.icon} isActive={isActive && !hasActiveChild} />
- <span>{item.title}</span>
- </Link>
- </SidebarMenuButton>
- {item.items && showSubmenu && (
- <SidebarMenuSub>
- {item.items.map((subItem) => {
- const subActive =
- currentPath === subItem.url || currentPath.startsWith(subItem.url)
- return (
- <SidebarMenuSubItem key={subItem.title}>
- <SidebarMenuSubButton asChild isActive={subActive}>
- <Link to={subItem.url}>
- <span>{subItem.title}</span>
- </Link>
- </SidebarMenuSubButton>
- </SidebarMenuSubItem>
- )
- })}
- </SidebarMenuSub>
- )}
- </SidebarMenuItem>
- )
- })}
+ {items.map((item) => (
+ <NavItemContent
+ key={item.title}
+ item={item}
+ currentPath={currentPath}
+ isCollapsed={isCollapsed}
+ />
+ ))}
</SidebarMenu>
</SidebarGroup>
@@ -88,7 +150,7 @@ export function NavMain({ items, bottomItems }: { items: NavItem[]; bottomItems?
<SidebarMenuItem key={item.title}>
<SidebarMenuButton tooltip={item.title} asChild isActive={isActive}>
<Link to={item.url}>
- <NavIcon name={item.icon} isActive={isActive} />
+ <NavIcon icon={item.icon} isActive={isActive} />
<span>{item.title}</span>
</Link>
</SidebarMenuButton>
diff --git a/packages/admin/src/components/nav-user.tsx b/packages/admin/src/components/nav-user.tsx
index 7f88fcc4d0..844e41032d 100644
--- a/packages/admin/src/components/nav-user.tsx
+++ b/packages/admin/src/components/nav-user.tsx
@@ -1,4 +1,4 @@
-import { TablerIcon } from '@/components/tabler-icon'
+import { BookOpenIcon, LogOutIcon, MailIcon, MessageCircleIcon, UserIcon } from 'lucide-react'
import { Avatar, AvatarFallback } from '@/components/ui/avatar'
import {
DropdownMenu,
@@ -11,7 +11,8 @@ import { SidebarMenu, SidebarMenuItem, useSidebar } from '@/components/ui/sideba
import { useAuth } from '@/hooks/use-auth'
export function NavUser() {
- const { isMobile } = useSidebar()
+ const { isMobile, state } = useSidebar()
+ const isCollapsed = state === 'collapsed'
const { user, logout } = useAuth()
if (!user) return null
@@ -32,14 +33,19 @@ export function NavUser() {
<DropdownMenuTrigger asChild>
<button
type="button"
- className="flex w-full items-center gap-2 rounded-lg p-1 text-left hover:bg-gray-200/50 transition-colors duration-100 outline-none"
+ className={
+ 'flex w-full items-center rounded-lg text-left transition-colors duration-100 outline-none hover:bg-gray-200/50 ' +
+ (isCollapsed ? 'justify-center p-0' : 'gap-2 p-1')
+ }
>
- <Avatar className="size-8">
+ <Avatar className="size-8 shrink-0">
<AvatarFallback className="text-xs bg-zinc-950 text-white">
{initials}
</AvatarFallback>
</Avatar>
- <span className="flex-1 min-w-0 truncate text-sm text-zinc-950">{displayName}</span>
+ {!isCollapsed && (
+ <span className="flex-1 min-w-0 truncate text-sm text-zinc-950">{displayName}</span>
+ )}
</button>
</DropdownMenuTrigger>
<DropdownMenuContent
@@ -64,25 +70,25 @@ export function NavUser() {
</div>
<DropdownMenuSeparator />
<DropdownMenuItem>
- <TablerIcon name="user-scan" />
+ <UserIcon className="size-4" />
Edit Profile
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem>
- <TablerIcon name="book" />
+ <BookOpenIcon className="size-4" />
Documentation
</DropdownMenuItem>
<DropdownMenuItem>
- <TablerIcon name="message-circle" />
+ <MessageCircleIcon className="size-4" />
Community
</DropdownMenuItem>
<DropdownMenuItem>
- <TablerIcon name="mail" />
+ <MailIcon className="size-4" />
Contact Support
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem onClick={logout} className="text-destructive focus:text-destructive">
- <TablerIcon name="log-out" />
+ <LogOutIcon className="size-4" />
Log out
</DropdownMenuItem>
</DropdownMenuContent>
diff --git a/packages/admin/src/components/resource-table.tsx b/packages/admin/src/components/resource-table.tsx
index 9b662018e0..587f0ebee8 100644
--- a/packages/admin/src/components/resource-table.tsx
+++ b/packages/admin/src/components/resource-table.tsx
@@ -1,9 +1,9 @@
-import { useQuery } from '@tanstack/react-query'
-import { useNavigate } from '@tanstack/react-router'
-import { type ReactNode, useDeferredValue, useState } from 'react'
-import { z } from 'zod/v4'
-import { TableToolbar } from '@/components/table-toolbar'
-import { Card, CardContent } from '@/components/ui/card'
+import { useQuery } from "@tanstack/react-query";
+import { useNavigate } from "@tanstack/react-router";
+import { type ReactNode, useDeferredValue, useState } from "react";
+import { z } from "zod/v4";
+import { TableToolbar } from "@/components/table-toolbar";
+import { Card, CardContent } from "@/components/ui/card";
import {
Table,
TableBody,
@@ -12,16 +12,16 @@ import {
TableHead,
TableHeader,
TableRow,
-} from '@/components/ui/data-table'
-import { Pagination, type PaginationMeta } from '@/components/ui/pagination'
-import { useAuth } from '@/hooks/use-auth'
+} from "@/components/ui/data-table";
+import { Pagination, type PaginationMeta } from "@/components/ui/pagination";
+import { useAuth } from "@/hooks/use-auth";
import {
type FilterRule,
getDefaultColumnKeys,
getDisplayableColumns,
getTable,
type SortOption,
-} from '@/lib/table-registry'
+} from "@/lib/table-registry";
// ============================================================================
// Search schema — shared by all resource table routes
@@ -32,30 +32,30 @@ const filterSchema = z.object({
field: z.string(),
operator: z.string(),
value: z.string(),
-})
+});
export const resourceSearchSchema = z.object({
page: z.coerce.number().optional().default(1),
sort: z.string().optional(),
- dir: z.enum(['asc', 'desc']).optional(),
+ dir: z.enum(["asc", "desc"]).optional(),
search: z.string().optional(),
filters: z.preprocess((val) => {
- if (typeof val === 'string') {
+ if (typeof val === "string") {
try {
- return JSON.parse(val)
+ return JSON.parse(val);
} catch {
- return []
+ return [];
}
}
- return val ?? []
+ return val ?? [];
}, z.array(filterSchema).optional().default([])),
columns: z.preprocess((val) => {
- if (typeof val === 'string') return val.split(',')
- return val ?? undefined
+ if (typeof val === "string") return val.split(",");
+ return val ?? undefined;
}, z.array(z.string()).optional()),
-})
+});
-export type ResourceSearch = z.infer<typeof resourceSearchSchema>
+export type ResourceSearch = z.infer<typeof resourceSearchSchema>;
// ============================================================================
// Props
@@ -63,19 +63,21 @@ export type ResourceSearch = z.infer<typeof resourceSearchSchema>
interface ResourceTableProps<T> {
/** Registry key (e.g., 'products') */
- tableKey: string
+ tableKey: string;
/** TanStack Query key prefix (e.g., 'products') */
- queryKey: string
+ queryKey: string;
/** Function that calls the SDK to fetch data */
- queryFn: (params: Record<string, unknown>) => Promise<{ data: T[]; meta: PaginationMeta }>
+ queryFn: (
+ params: Record<string, unknown>,
+ ) => Promise<{ data: T[]; meta: PaginationMeta }>;
/** Current search params from the route */
- searchParams: ResourceSearch
+ searchParams: ResourceSearch;
/** Title displayed in the toolbar header. Overrides the table definition's title. */
- title?: string
+ title?: string;
/** Default params always sent with every request (e.g., { complete: 1 } for orders) */
- defaultParams?: Record<string, unknown>
+ defaultParams?: Record<string, unknown>;
/** Actions to render in the toolbar (e.g., "Add Product" button) */
- actions?: ReactNode
+ actions?: ReactNode;
}
// ============================================================================
@@ -91,93 +93,111 @@ export function ResourceTable<T extends Record<string, any>>({
defaultParams,
actions,
}: ResourceTableProps<T>) {
- const table = getTable<T>(tableKey)
- const { token } = useAuth()
- const navigate = useNavigate()
+ const table = getTable<T>(tableKey);
+ const { token } = useAuth();
+ const navigate = useNavigate();
- const { page, sort: urlSort, dir: urlDir, search, filters, columns: urlColumns } = searchParams
+ const {
+ page,
+ sort: urlSort,
+ dir: urlDir,
+ search,
+ filters,
+ columns: urlColumns,
+ } = searchParams;
const defaultSort = table.defaultSort ?? {
- field: 'updated_at',
- direction: 'desc' as const,
- }
- const sort = urlSort ?? defaultSort.field
- const dir = urlDir ?? defaultSort.direction
+ field: "updated_at",
+ direction: "desc" as const,
+ };
+ const sort = urlSort ?? defaultSort.field;
+ const dir = urlDir ?? defaultSort.direction;
- const [searchInput, setSearchInput] = useState(search ?? '')
- const deferredSearch = useDeferredValue(searchInput)
+ const [searchInput, setSearchInput] = useState(search ?? "");
+ const deferredSearch = useDeferredValue(searchInput);
- const displayableColumns = getDisplayableColumns(table)
- const defaultColumnKeys = getDefaultColumnKeys(table)
- const visibleColumnKeys = urlColumns ?? defaultColumnKeys
+ const displayableColumns = getDisplayableColumns(table);
+ const defaultColumnKeys = getDefaultColumnKeys(table);
+ const visibleColumnKeys = urlColumns ?? defaultColumnKeys;
- const visibleColumns = displayableColumns.filter((c) => visibleColumnKeys.includes(c.key))
+ const visibleColumns = displayableColumns.filter((c) =>
+ visibleColumnKeys.includes(c.key),
+ );
// Build API params
- const sortString = dir === 'desc' ? `-${sort}` : sort
+ const sortString = dir === "desc" ? `-${sort}` : sort;
const { data, isLoading } = useQuery({
- queryKey: [queryKey, { page, sort: sortString, search: deferredSearch, filters }],
+ queryKey: [
+ queryKey,
+ { page, sort: sortString, search: deferredSearch, filters },
+ ],
queryFn: () => {
- const params: Record<string, unknown> = { page, sort: sortString, ...defaultParams }
+ const params: Record<string, unknown> = {
+ page,
+ sort: sortString,
+ ...defaultParams,
+ };
if (deferredSearch) {
- const searchParam = table.searchParam ?? 'name_cont'
- params[searchParam] = deferredSearch
+ const searchParam = table.searchParam ?? "name_cont";
+ params[searchParam] = deferredSearch;
}
// Convert FilterRule[] to Ransack params
for (const filter of filters as FilterRule[]) {
- const col = table.columns.find((c) => c.key === filter.field)
- const ransackKey = col?.ransackAttribute ?? filter.field
- params[`${ransackKey}_${filter.operator}`] = filter.value
+ const col = table.columns.find((c) => c.key === filter.field);
+ const ransackKey = col?.ransackAttribute ?? filter.field;
+ params[`${ransackKey}_${filter.operator}`] = filter.value;
}
- return queryFn(params)
+ return queryFn(params);
},
enabled: !!token,
- })
+ });
- const rows = data?.data ?? []
- const meta = data?.meta
+ const rows = data?.data ?? [];
+ const meta = data?.meta;
// Navigation helpers
function updateSearch(updates: Record<string, unknown>) {
navigate({
- search: (prev: Record<string, unknown>) => ({ ...prev, ...updates }),
- })
+ search: (prev: Record<string, unknown>) =>
+ ({ ...prev, ...updates }) as never,
+ });
}
function handleSearchChange(value: string) {
- setSearchInput(value)
- updateSearch({ search: value || undefined, page: 1 })
+ setSearchInput(value);
+ updateSearch({ search: value || undefined, page: 1 });
}
function handleSortChange(s: SortOption) {
- updateSearch({ sort: s.field, dir: s.direction, page: 1 })
+ updateSearch({ sort: s.field, dir: s.direction, page: 1 });
}
function handleFiltersChange(f: FilterRule[]) {
updateSearch({
filters: f.length > 0 ? JSON.stringify(f) : undefined,
page: 1,
- })
+ });
}
function handleColumnsChange(cols: string[]) {
const isDefault =
- cols.length === defaultColumnKeys.length && cols.every((c) => defaultColumnKeys.includes(c))
- updateSearch({ columns: isDefault ? undefined : cols.join(',') })
+ cols.length === defaultColumnKeys.length &&
+ cols.every((c) => defaultColumnKeys.includes(c));
+ updateSearch({ columns: isDefault ? undefined : cols.join(",") });
}
// Header columns for price-like right-aligned columns
const headerColumns = visibleColumns.map((col) => {
- const isRightAligned = col.className?.includes('text-right')
+ const isRightAligned = col.className?.includes("text-right");
return {
...col,
- headerClassName: isRightAligned ? 'text-right' : undefined,
- }
- })
+ headerClassName: isRightAligned ? "text-right" : undefined,
+ };
+ });
return (
<Card className="rounded-2xl">
@@ -187,7 +207,7 @@ export function ResourceTable<T extends Record<string, any>>({
onVisibleColumnsChange={handleColumnsChange}
search={searchInput}
onSearchChange={handleSearchChange}
- searchPlaceholder={table.searchPlaceholder ?? 'Search...'}
+ searchPlaceholder={table.searchPlaceholder ?? "Search..."}
sort={{ field: sort, direction: dir }}
onSortChange={handleSortChange}
filters={filters as FilterRule[]}
@@ -209,14 +229,18 @@ export function ResourceTable<T extends Record<string, any>>({
</TableHeader>
<TableBody>
{isLoading ? (
- <TableEmpty colSpan={visibleColumns.length}>Loading...</TableEmpty>
+ <TableEmpty colSpan={visibleColumns.length}>
+ Loading...
+ </TableEmpty>
) : rows.length === 0 ? (
<TableEmpty colSpan={visibleColumns.length}>
<div className="flex flex-col items-center gap-2">
{table.emptyIcon}
- <p>{table.emptyMessage ?? 'No results found'}</p>
+ <p>{table.emptyMessage ?? "No results found"}</p>
{(deferredSearch || (filters as FilterRule[]).length > 0) && (
- <p className="text-xs">Try adjusting your search or filters</p>
+ <p className="text-xs">
+ Try adjusting your search or filters
+ </p>
)}
</div>
</TableEmpty>
@@ -225,7 +249,9 @@ export function ResourceTable<T extends Record<string, any>>({
<TableRow key={(row as any).id ?? i}>
{visibleColumns.map((col) => (
<TableCell key={col.key} className={col.className}>
- {col.render ? col.render(row) : String((row as any)[col.key] ?? '—')}
+ {col.render
+ ? col.render(row)
+ : String((row as any)[col.key] ?? "—")}
</TableCell>
))}
</TableRow>
@@ -233,8 +259,13 @@ export function ResourceTable<T extends Record<string, any>>({
)}
</TableBody>
</Table>
- {meta && <Pagination meta={meta} onPageChange={(p) => updateSearch({ page: p })} />}
+ {meta && (
+ <Pagination
+ meta={meta}
+ onPageChange={(p) => updateSearch({ page: p })}
+ />
+ )}
</CardContent>
</Card>
- )
+ );
}
diff --git a/packages/admin/src/components/store-switcher.tsx b/packages/admin/src/components/store-switcher.tsx
index 5312208eb7..a11a173ff7 100644
--- a/packages/admin/src/components/store-switcher.tsx
+++ b/packages/admin/src/components/store-switcher.tsx
@@ -1,5 +1,4 @@
-import { ChevronsUpDownIcon, ExternalLinkIcon } from 'lucide-react'
-import { TablerIcon } from '@/components/tabler-icon'
+import { ChevronsUpDownIcon, ExternalLinkIcon, PaletteIcon, StoreIcon } from 'lucide-react'
import {
DropdownMenu,
DropdownMenuContent,
@@ -7,36 +6,39 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'
-import {
- SidebarMenu,
- SidebarMenuButton,
- SidebarMenuItem,
- useSidebar,
-} from '@/components/ui/sidebar'
+import { SidebarMenu, SidebarMenuItem, useSidebar } from '@/components/ui/sidebar'
export function StoreSwitcher() {
- const { isMobile } = useSidebar()
+ const { isMobile, state } = useSidebar()
+ const isCollapsed = state === 'collapsed'
return (
<SidebarMenu>
<SidebarMenuItem>
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <SidebarMenuButton
- size="lg"
- className="h-[58px] gap-2 rounded-xl p-1 hover:bg-gray-200/50 data-[state=open]:bg-gray-200/50"
+ <button
+ type="button"
+ className={
+ 'flex w-full items-center rounded-xl outline-hidden transition-colors duration-100 hover:bg-gray-200/50 data-[state=open]:bg-gray-200/50 ' +
+ (isCollapsed ? 'size-10 justify-center p-0' : 'h-[58px] gap-2 p-1')
+ }
>
<div className="flex size-8 shrink-0 items-center justify-center rounded-lg bg-zinc-950 text-white">
- <TablerIcon name="building-store" className="size-4" />
- </div>
- <div className="grid flex-1 text-left text-sm leading-tight">
- <span className="truncate font-medium text-zinc-950">Spree Store</span>
+ <StoreIcon className="size-4" />
</div>
- <ChevronsUpDownIcon className="ml-auto size-4 text-gray-400" />
- </SidebarMenuButton>
+ {!isCollapsed && (
+ <>
+ <div className="grid flex-1 text-left text-sm leading-tight">
+ <span className="truncate font-medium text-zinc-950">Spree Store</span>
+ </div>
+ <ChevronsUpDownIcon className="ml-auto size-4 text-gray-400" />
+ </>
+ )}
+ </button>
</DropdownMenuTrigger>
<DropdownMenuContent
- className="w-(--radix-dropdown-menu-trigger-width) min-w-48"
+ className="min-w-48"
side={isMobile ? 'bottom' : 'right'}
align="start"
sideOffset={8}
@@ -47,7 +49,7 @@ export function StoreSwitcher() {
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem>
- <TablerIcon name="palette" className="size-4" />
+ <PaletteIcon className="size-4" />
Edit Theme
</DropdownMenuItem>
</DropdownMenuContent>
diff --git a/packages/admin/src/components/table-toolbar.tsx b/packages/admin/src/components/table-toolbar.tsx
index 8161bf229c..2255453fd3 100644
--- a/packages/admin/src/components/table-toolbar.tsx
+++ b/packages/admin/src/components/table-toolbar.tsx
@@ -6,11 +6,11 @@ import {
SearchIcon,
Trash2Icon,
XIcon,
-} from 'lucide-react'
-import { useCallback, useEffect, useRef, useState } from 'react'
-import { Badge } from '@/components/ui/badge'
-import { Button } from '@/components/ui/button'
-import { CardTitle } from '@/components/ui/card'
+} from "lucide-react";
+import { useCallback, useEffect, useRef, useState } from "react";
+import { Badge } from "@/components/ui/badge";
+import { Button } from "@/components/ui/button";
+import { CardTitle } from "@/components/ui/card";
import {
DropdownMenu,
DropdownMenuCheckboxItem,
@@ -20,15 +20,15 @@ import {
DropdownMenuRadioItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
-} from '@/components/ui/dropdown-menu'
-import { Input } from '@/components/ui/input'
+} from "@/components/ui/dropdown-menu";
+import { Input } from "@/components/ui/input";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
-} from '@/components/ui/select'
+} from "@/components/ui/select";
import {
Sheet,
SheetClose,
@@ -37,26 +37,27 @@ import {
SheetFooter,
SheetHeader,
SheetTitle,
-} from '@/components/ui/sheet'
-import type { ColumnDef, FilterRule, SortOption } from '@/lib/table-registry'
+} from "@/components/ui/sheet";
+import { Tooltip, TooltipTrigger, TooltipContent } from "./ui/tooltip";
+import type { ColumnDef, FilterRule, SortOption } from "@/lib/table-registry";
interface TableToolbarProps {
/** Displayable columns (for column selector and table headers) */
- columns: ColumnDef[]
- visibleColumns: string[]
- onVisibleColumnsChange: (columns: string[]) => void
- search: string
- onSearchChange: (value: string) => void
- searchPlaceholder?: string
- sort: SortOption
- onSortChange: (sort: SortOption) => void
- filters: FilterRule[]
- onFiltersChange: (filters: FilterRule[]) => void
+ columns: ColumnDef[];
+ visibleColumns: string[];
+ onVisibleColumnsChange: (columns: string[]) => void;
+ search: string;
+ onSearchChange: (value: string) => void;
+ searchPlaceholder?: string;
+ sort: SortOption;
+ onSortChange: (sort: SortOption) => void;
+ filters: FilterRule[];
+ onFiltersChange: (filters: FilterRule[]) => void;
/** All columns including filter-only ones (for the filter drawer). Falls back to `columns` if not provided. */
- allColumns?: ColumnDef[]
+ allColumns?: ColumnDef[];
/** Title displayed in the toolbar header */
- title?: string
- actions?: React.ReactNode
+ title?: string;
+ actions?: React.ReactNode;
}
// ============================================================================
@@ -65,42 +66,42 @@ interface TableToolbarProps {
const operatorsByType: Record<string, { value: string; label: string }[]> = {
string: [
- { value: 'cont', label: 'contains' },
- { value: 'eq', label: 'equals' },
- { value: 'not_eq', label: 'does not equal' },
- { value: 'start', label: 'starts with' },
- { value: 'end', label: 'ends with' },
- { value: 'present', label: 'is set' },
- { value: 'blank', label: 'is not set' },
+ { value: "cont", label: "contains" },
+ { value: "eq", label: "equals" },
+ { value: "not_eq", label: "does not equal" },
+ { value: "start", label: "starts with" },
+ { value: "end", label: "ends with" },
+ { value: "present", label: "is set" },
+ { value: "blank", label: "is not set" },
],
status: [
- { value: 'eq', label: 'is' },
- { value: 'not_eq', label: 'is not' },
- { value: 'in', label: 'is any of' },
- { value: 'not_in', label: 'is none of' },
+ { value: "eq", label: "is" },
+ { value: "not_eq", label: "is not" },
+ { value: "in", label: "is any of" },
+ { value: "not_in", label: "is none of" },
],
- boolean: [{ value: 'eq', label: 'is' }],
+ boolean: [{ value: "eq", label: "is" }],
number: [
- { value: 'eq', label: 'equals' },
- { value: 'gt', label: 'greater than' },
- { value: 'gteq', label: 'greater than or equal' },
- { value: 'lt', label: 'less than' },
- { value: 'lteq', label: 'less than or equal' },
+ { value: "eq", label: "equals" },
+ { value: "gt", label: "greater than" },
+ { value: "gteq", label: "greater than or equal" },
+ { value: "lt", label: "less than" },
+ { value: "lteq", label: "less than or equal" },
],
date: [
- { value: 'eq', label: 'is' },
- { value: 'gt', label: 'after' },
- { value: 'lt', label: 'before' },
- { value: 'gteq', label: 'on or after' },
- { value: 'lteq', label: 'on or before' },
+ { value: "eq", label: "is" },
+ { value: "gt", label: "after" },
+ { value: "lt", label: "before" },
+ { value: "gteq", label: "on or after" },
+ { value: "lteq", label: "on or before" },
],
-}
+};
function getOperators(type: string) {
- return operatorsByType[type] || operatorsByType.string
+ return operatorsByType[type] || operatorsByType.string;
}
-const noValueOperators = ['present', 'blank']
+const noValueOperators = ["present", "blank"];
// ============================================================================
// TableToolbar
@@ -112,7 +113,7 @@ export function TableToolbar({
onVisibleColumnsChange,
search,
onSearchChange,
- searchPlaceholder = 'Search...',
+ searchPlaceholder = "Search...",
sort,
onSortChange,
filters,
@@ -121,13 +122,13 @@ export function TableToolbar({
title,
actions,
}: TableToolbarProps) {
- const [filterOpen, setFilterOpen] = useState(false)
- const searchRef = useRef<HTMLInputElement>(null)
+ const [filterOpen, setFilterOpen] = useState(false);
+ const searchRef = useRef<HTMLInputElement>(null);
- const allCols = allColumns ?? columns
- const sortableColumns = allCols.filter((c) => c.sortable)
- const filterableColumns = allCols.filter((c) => c.filterable)
- const activeFilterCount = filters.length
+ const allCols = allColumns ?? columns;
+ const sortableColumns = allCols.filter((c) => c.sortable);
+ const filterableColumns = allCols.filter((c) => c.filterable);
+ const activeFilterCount = filters.length;
return (
<>
@@ -149,8 +150,8 @@ export function TableToolbar({
type="button"
className="p-0.5 text-gray-400 hover:text-gray-600 shrink-0"
onClick={() => {
- onSearchChange('')
- searchRef.current?.focus()
+ onSearchChange("");
+ searchRef.current?.focus();
}}
>
<XIcon className="size-3.5" />
@@ -162,23 +163,33 @@ export function TableToolbar({
<div className="flex gap-2 items-center">
{/* Filter button */}
{filterableColumns.length > 0 && (
- <Button
- variant="outline"
- size="sm"
- className="h-[2.125rem]"
- onClick={() => setFilterOpen(true)}
- >
- <FilterIcon className="size-4" />
- Filters
- {activeFilterCount > 0 && (
- <Badge className="ml-1 px-1.5 py-0 text-xs">{activeFilterCount}</Badge>
- )}
- </Button>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-[2.125rem]"
+ onClick={() => setFilterOpen(true)}
+ >
+ <FilterIcon className="size-4" />
+ {activeFilterCount > 0 && (
+ <Badge className="ml-1 px-1.5 py-0 text-xs">
+ {activeFilterCount}
+ </Badge>
+ )}
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>Filters</TooltipContent>
+ </Tooltip>
)}
{/* Sort dropdown */}
{sortableColumns.length > 0 && (
- <SortDropdown columns={sortableColumns} sort={sort} onSortChange={onSortChange} />
+ <SortDropdown
+ columns={sortableColumns}
+ sort={sort}
+ onSortChange={onSortChange}
+ />
)}
{/* Column selector */}
@@ -196,12 +207,16 @@ export function TableToolbar({
{filters.length > 0 && (
<div className="flex gap-2 flex-wrap px-3 py-2 border-b border-gray-200">
{filters.map((filter) => {
- const col = allCols.find((c) => c.key === filter.field)
- const ops = getOperators(col?.filterType ?? 'string')
- const opLabel = ops.find((o) => o.value === filter.operator)?.label ?? filter.operator
+ const col = allCols.find((c) => c.key === filter.field);
+ const ops = getOperators(col?.filterType ?? "string");
+ const opLabel =
+ ops.find((o) => o.value === filter.operator)?.label ??
+ filter.operator;
return (
<Badge key={filter.id} className="gap-1.5 pr-1">
- <span className="font-medium">{col?.label ?? filter.field}</span>
+ <span className="font-medium">
+ {col?.label ?? filter.field}
+ </span>
<span className="text-muted-foreground">{opLabel}</span>
{!noValueOperators.includes(filter.operator) && (
<span className="font-medium">{filter.value}</span>
@@ -209,12 +224,14 @@ export function TableToolbar({
<button
type="button"
className="ml-0.5 p-0.5 rounded-sm hover:bg-gray-200"
- onClick={() => onFiltersChange(filters.filter((f) => f.id !== filter.id))}
+ onClick={() =>
+ onFiltersChange(filters.filter((f) => f.id !== filter.id))
+ }
>
<XIcon className="size-3" />
</button>
</Badge>
- )
+ );
})}
<button
type="button"
@@ -235,7 +252,7 @@ export function TableToolbar({
onApply={onFiltersChange}
/>
</>
- )
+ );
}
// ============================================================================
@@ -247,26 +264,32 @@ function SortDropdown({
sort,
onSortChange,
}: {
- columns: ColumnDef[]
- sort: SortOption
- onSortChange: (sort: SortOption) => void
+ columns: ColumnDef[];
+ sort: SortOption;
+ onSortChange: (sort: SortOption) => void;
}) {
- const currentCol = columns.find((c) => c.key === sort.field)
+ const currentCol = columns.find((c) => c.key === sort.field);
return (
<DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="outline" size="sm" className="h-[2.125rem]">
- <ArrowUpDownIcon className="size-4" />
- {currentCol?.label ?? 'Sort'}
- </Button>
- </DropdownMenuTrigger>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <DropdownMenuTrigger asChild>
+ <Button variant="outline" size="sm" className="h-[2.125rem]">
+ <ArrowUpDownIcon className="size-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ </TooltipTrigger>
+ <TooltipContent>{currentCol?.label ?? "Sort"}</TooltipContent>
+ </Tooltip>
<DropdownMenuContent align="end" className="min-w-48">
<DropdownMenuLabel>Sort by</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuRadioGroup
value={sort.field}
- onValueChange={(field) => onSortChange({ field, direction: sort.direction })}
+ onValueChange={(field) =>
+ onSortChange({ field, direction: sort.direction })
+ }
>
{columns.map((col) => (
<DropdownMenuRadioItem key={col.key} value={col.key}>
@@ -280,7 +303,10 @@ function SortDropdown({
<DropdownMenuRadioGroup
value={sort.direction}
onValueChange={(dir) =>
- onSortChange({ field: sort.field, direction: dir as 'asc' | 'desc' })
+ onSortChange({
+ field: sort.field,
+ direction: dir as "asc" | "desc",
+ })
}
>
<DropdownMenuRadioItem value="asc">Ascending</DropdownMenuRadioItem>
@@ -288,7 +314,7 @@ function SortDropdown({
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
- )
+ );
}
// ============================================================================
@@ -300,20 +326,24 @@ function ColumnSelector({
visibleColumns,
onVisibleColumnsChange,
}: {
- columns: ColumnDef[]
- visibleColumns: string[]
- onVisibleColumnsChange: (columns: string[]) => void
+ columns: ColumnDef[];
+ visibleColumns: string[];
+ onVisibleColumnsChange: (columns: string[]) => void;
}) {
- const defaults = columns.filter((c) => c.default).map((c) => c.key)
+ const defaults = columns.filter((c) => c.default).map((c) => c.key);
return (
<DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="outline" size="sm" className="h-[2.125rem]">
- <Columns3Icon className="size-4" />
- Columns
- </Button>
- </DropdownMenuTrigger>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <DropdownMenuTrigger asChild>
+ <Button variant="outline" size="sm" className="h-[2.125rem]">
+ <Columns3Icon className="size-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ </TooltipTrigger>
+ <TooltipContent>Columns</TooltipContent>
+ </Tooltip>
<DropdownMenuContent align="end" className="min-w-48">
<DropdownMenuLabel>Visible columns</DropdownMenuLabel>
<DropdownMenuSeparator />
@@ -326,7 +356,7 @@ function ColumnSelector({
checked
? [...visibleColumns, col.key]
: visibleColumns.filter((k) => k !== col.key),
- )
+ );
}}
onSelect={(e) => e.preventDefault()}
>
@@ -346,7 +376,7 @@ function ColumnSelector({
</div>
</DropdownMenuContent>
</DropdownMenu>
- )
+ );
}
// ============================================================================
@@ -360,48 +390,53 @@ function FilterDrawer({
filters: initialFilters,
onApply,
}: {
- open: boolean
- onOpenChange: (open: boolean) => void
- columns: ColumnDef[]
- filters: FilterRule[]
- onApply: (filters: FilterRule[]) => void
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ columns: ColumnDef[];
+ filters: FilterRule[];
+ onApply: (filters: FilterRule[]) => void;
}) {
- const [draft, setDraft] = useState<FilterRule[]>(initialFilters)
+ const [draft, setDraft] = useState<FilterRule[]>(initialFilters);
// Sync draft when opened
useEffect(() => {
- if (open) setDraft(initialFilters)
- }, [open, initialFilters])
+ if (open) setDraft(initialFilters);
+ }, [open, initialFilters]);
const addFilter = useCallback(() => {
- const first = columns[0]
- if (!first) return
+ const first = columns[0];
+ if (!first) return;
setDraft((prev) => [
...prev,
{
id: crypto.randomUUID(),
field: first.key,
- operator: getOperators(first.filterType ?? 'string')[0].value,
- value: '',
+ operator: getOperators(first.filterType ?? "string")[0].value,
+ value: "",
},
- ])
- }, [columns])
-
- const updateFilter = useCallback((id: string, update: Partial<FilterRule>) => {
- setDraft((prev) => prev.map((f) => (f.id === id ? { ...f, ...update } : f)))
- }, [])
+ ]);
+ }, [columns]);
+
+ const updateFilter = useCallback(
+ (id: string, update: Partial<FilterRule>) => {
+ setDraft((prev) =>
+ prev.map((f) => (f.id === id ? { ...f, ...update } : f)),
+ );
+ },
+ [],
+ );
const removeFilter = useCallback((id: string) => {
- setDraft((prev) => prev.filter((f) => f.id !== id))
- }, [])
+ setDraft((prev) => prev.filter((f) => f.id !== id));
+ }, []);
function handleApply() {
// Remove filters with no value (unless operator doesn't need one)
const valid = draft.filter(
- (f) => noValueOperators.includes(f.operator) || f.value.trim() !== '',
- )
- onApply(valid)
- onOpenChange(false)
+ (f) => noValueOperators.includes(f.operator) || f.value.trim() !== "",
+ );
+ onApply(valid);
+ onOpenChange(false);
}
return (
@@ -409,7 +444,9 @@ function FilterDrawer({
<SheetContent side="right" showCloseButton={false}>
<SheetHeader>
<SheetTitle>Filters</SheetTitle>
- <SheetDescription className="sr-only">Build filters for the table</SheetDescription>
+ <SheetDescription className="sr-only">
+ Build filters for the table
+ </SheetDescription>
<SheetClose asChild>
<Button variant="ghost" size="icon-sm">
<XIcon />
@@ -419,23 +456,26 @@ function FilterDrawer({
<div className="flex-1 overflow-y-auto p-4 space-y-3">
{draft.map((filter) => {
- const col = columns.find((c) => c.key === filter.field)
- const type = col?.filterType ?? 'string'
- const ops = getOperators(type)
+ const col = columns.find((c) => c.key === filter.field);
+ const type = col?.filterType ?? "string";
+ const ops = getOperators(type);
return (
- <div key={filter.id} className="flex items-center gap-2 p-3 bg-gray-50 rounded-lg">
+ <div
+ key={filter.id}
+ className="flex items-center gap-2 p-3 bg-gray-50 rounded-lg"
+ >
{/* Field select */}
<Select
value={filter.field}
onValueChange={(val) => {
- const newCol = columns.find((c) => c.key === val)
- const newOps = getOperators(newCol?.filterType ?? 'string')
+ const newCol = columns.find((c) => c.key === val);
+ const newOps = getOperators(newCol?.filterType ?? "string");
updateFilter(filter.id, {
field: val,
operator: newOps[0].value,
- value: '',
- })
+ value: "",
+ });
}}
>
<SelectTrigger className="flex-1">
@@ -453,7 +493,9 @@ function FilterDrawer({
{/* Operator select */}
<Select
value={filter.operator}
- onValueChange={(val) => updateFilter(filter.id, { operator: val })}
+ onValueChange={(val) =>
+ updateFilter(filter.id, { operator: val })
+ }
>
<SelectTrigger className="w-[140px] shrink-0">
<SelectValue />
@@ -469,10 +511,12 @@ function FilterDrawer({
{/* Value input */}
{!noValueOperators.includes(filter.operator) &&
- (col?.filterType === 'status' && col.filterOptions ? (
+ (col?.filterType === "status" && col.filterOptions ? (
<Select
value={filter.value || undefined}
- onValueChange={(val) => updateFilter(filter.id, { value: val })}
+ onValueChange={(val) =>
+ updateFilter(filter.id, { value: val })
+ }
>
<SelectTrigger className="flex-1">
<SelectValue placeholder="Select..." />
@@ -485,10 +529,12 @@ function FilterDrawer({
))}
</SelectContent>
</Select>
- ) : col?.filterType === 'boolean' ? (
+ ) : col?.filterType === "boolean" ? (
<Select
value={filter.value || undefined}
- onValueChange={(val) => updateFilter(filter.id, { value: val })}
+ onValueChange={(val) =>
+ updateFilter(filter.id, { value: val })
+ }
>
<SelectTrigger className="flex-1">
<SelectValue placeholder="Select..." />
@@ -501,16 +547,18 @@ function FilterDrawer({
) : (
<Input
type={
- col?.filterType === 'number'
- ? 'number'
- : col?.filterType === 'date'
- ? 'date'
- : 'text'
+ col?.filterType === "number"
+ ? "number"
+ : col?.filterType === "date"
+ ? "date"
+ : "text"
}
className="flex-1 py-1.5 px-2"
placeholder="Enter value..."
value={filter.value}
- onChange={(e) => updateFilter(filter.id, { value: e.target.value })}
+ onChange={(e) =>
+ updateFilter(filter.id, { value: e.target.value })
+ }
/>
))}
@@ -523,7 +571,7 @@ function FilterDrawer({
<Trash2Icon className="size-4" />
</button>
</div>
- )
+ );
})}
{draft.length === 0 && (
@@ -551,5 +599,5 @@ function FilterDrawer({
</SheetFooter>
</SheetContent>
</Sheet>
- )
+ );
}
diff --git a/packages/admin/src/components/tabler-icon.tsx b/packages/admin/src/components/tabler-icon.tsx
deleted file mode 100644
index 7fbfac82c6..0000000000
--- a/packages/admin/src/components/tabler-icon.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import {
- BarChart3Icon,
- BookOpenIcon,
- HomeIcon,
- InboxIcon,
- LogOutIcon,
- type LucideIcon,
- MailIcon,
- MessageCircleIcon,
- PackageIcon,
- PaletteIcon,
- PlugIcon,
- ReceiptIcon,
- SettingsIcon,
- StoreIcon,
- TagIcon,
- UserIcon,
- UsersIcon,
-} from 'lucide-react'
-import { cn } from '@/lib/utils'
-
-const iconMap: Record<string, LucideIcon> = {
- home: HomeIcon,
- inbox: InboxIcon,
- package: PackageIcon,
- users: UsersIcon,
- discount: TagIcon,
- 'chart-bar': BarChart3Icon,
- settings: SettingsIcon,
- 'receipt-refund': ReceiptIcon,
- 'plug-connected': PlugIcon,
- 'building-store': StoreIcon,
- palette: PaletteIcon,
- 'user-scan': UserIcon,
- 'log-out': LogOutIcon,
- book: BookOpenIcon,
- 'message-circle': MessageCircleIcon,
- mail: MailIcon,
-}
-
-interface TablerIconProps {
- name: string
- className?: string
-}
-
-export function TablerIcon({ name, className }: TablerIconProps) {
- const Icon = iconMap[name] ?? StoreIcon
-
- return <Icon className={cn('size-4', className)} />
-}
diff --git a/packages/admin/src/components/ui/sidebar.tsx b/packages/admin/src/components/ui/sidebar.tsx
index 224e5cfb4d..352903d1e0 100644
--- a/packages/admin/src/components/ui/sidebar.tsx
+++ b/packages/admin/src/components/ui/sidebar.tsx
@@ -21,7 +21,7 @@ const SIDEBAR_COOKIE_NAME = 'sidebar_state'
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
const SIDEBAR_WIDTH = '220px'
const SIDEBAR_WIDTH_MOBILE = '220px'
-const SIDEBAR_WIDTH_ICON = '3rem'
+const SIDEBAR_WIDTH_ICON = '59px'
const SIDEBAR_KEYBOARD_SHORTCUT = 'b'
type SidebarContextProps = {
@@ -223,7 +223,7 @@ function Sidebar({
// Adjust the padding for floating and inset variants.
variant === 'floating' || variant === 'inset'
? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]'
- : 'group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l',
+ : 'group-data-[collapsible=icon]:w-(--sidebar-width-icon)',
className,
)}
{...props}
@@ -316,7 +316,10 @@ function SidebarHeader({ className, ...props }: React.ComponentProps<'div'>) {
<div
data-slot="sidebar-header"
data-sidebar="header"
- className={cn('flex flex-col gap-0 px-2', className)}
+ className={cn(
+ 'flex flex-col gap-0 px-2 group-data-[collapsible=icon]:px-0 group-data-[collapsible=icon]:items-center',
+ className,
+ )}
{...props}
/>
)
@@ -327,7 +330,10 @@ function SidebarFooter({ className, ...props }: React.ComponentProps<'div'>) {
<div
data-slot="sidebar-footer"
data-sidebar="footer"
- className={cn('flex flex-col gap-0 p-2 mt-auto border-t border-sidebar-border', className)}
+ className={cn(
+ 'flex flex-col gap-0 p-2 mt-auto border-t border-sidebar-border group-data-[collapsible=icon]:px-0 group-data-[collapsible=icon]:items-center',
+ className,
+ )}
{...props}
/>
)
@@ -350,7 +356,7 @@ function SidebarContent({ className, ...props }: React.ComponentProps<'div'>) {
data-slot="sidebar-content"
data-sidebar="content"
className={cn(
- 'no-scrollbar flex min-h-0 flex-1 flex-col gap-0 pt-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden',
+ 'no-scrollbar flex min-h-0 flex-1 flex-col gap-0 pt-2 overflow-auto group-data-[collapsible=icon]:overflow-visible',
className,
)}
{...props}
@@ -363,7 +369,10 @@ function SidebarGroup({ className, ...props }: React.ComponentProps<'div'>) {
<div
data-slot="sidebar-group"
data-sidebar="group"
- className={cn('relative flex w-full min-w-0 flex-col px-3 py-0', className)}
+ className={cn(
+ 'relative flex w-full min-w-0 flex-col px-3 py-0 group-data-[collapsible=icon]:px-0 group-data-[collapsible=icon]:items-center',
+ className,
+ )}
{...props}
/>
)
@@ -443,7 +452,7 @@ function SidebarMenuItem({ className, ...props }: React.ComponentProps<'li'>) {
}
const sidebarMenuButtonVariants = cva(
- 'peer/menu-button group/menu-button flex w-full items-center overflow-hidden rounded-xl p-1 text-left text-sm text-gray-800 ring-sidebar-ring outline-hidden transition-colors duration-100 ease-in-out group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-gray-200/50 hover:text-zinc-950 focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-gray-200/50 data-open:hover:text-zinc-950 data-active:bg-white data-active:text-zinc-950 data-active:font-semibold data-active:shadow-[rgba(0,0,0,0)_0px_0px_0px_0px,rgba(0,0,0,0)_0px_0px_0px_0px,rgba(0,0,0,0.04)_0px_0px_0px_1px,rgba(0,0,0,0.04)_0px_1px_2px_-1px,rgba(0,0,0,0.02)_0px_2px_4px_0px] [&>span:last-child]:truncate',
+ 'peer/menu-button group/menu-button flex w-full items-center overflow-hidden rounded-xl p-1 text-left text-base text-gray-800 ring-sidebar-ring outline-hidden transition-colors duration-100 ease-in-out group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-10! group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:overflow-visible group-data-[collapsible=icon]:p-0! group-data-[collapsible=icon]:[&>span:last-child]:hidden hover:bg-gray-200/50 hover:text-zinc-950 focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-gray-200/50 data-open:hover:text-zinc-950 data-active:bg-white data-active:text-zinc-950 data-active:font-semibold data-active:shadow-nav [&>span:last-child]:truncate',
{
variants: {
variant: {
@@ -452,9 +461,9 @@ const sidebarMenuButtonVariants = cva(
'bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]',
},
size: {
- default: 'h-8 text-sm',
+ default: 'h-8 text-base',
sm: 'h-7 text-xs',
- lg: 'h-12 text-sm group-data-[collapsible=icon]:p-0!',
+ lg: 'h-12 text-base group-data-[collapsible=icon]:p-0!',
},
},
defaultVariants: {
@@ -632,7 +641,7 @@ function SidebarMenuSubButton({
data-size={size}
data-active={isActive}
className={cn(
- 'relative flex h-7 min-w-0 items-center gap-2 overflow-hidden rounded-xl p-1 text-gray-800 ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-gray-50 hover:text-zinc-950 focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:font-semibold data-active:text-zinc-950 data-active:bg-transparent data-active:shadow-none data-active:before:absolute data-active:before:-left-4 data-active:before:top-[10%] data-active:before:h-[80%] data-active:before:w-[3px] data-active:before:rounded-sm data-active:before:bg-zinc-950 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0',
+ 'relative flex h-7 min-w-0 items-center gap-2 overflow-hidden rounded-xl p-1 text-gray-800 ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-gray-50 hover:text-zinc-950 focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-base data-[size=sm]:text-xs data-active:font-semibold data-active:text-zinc-950 data-active:bg-transparent data-active:shadow-none data-active:before:absolute data-active:before:-left-4 data-active:before:top-[10%] data-active:before:h-[80%] data-active:before:w-[3px] data-active:before:rounded-sm data-active:before:bg-zinc-950 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0',
className,
)}
{...props}
diff --git a/packages/admin/src/index.css b/packages/admin/src/index.css
index 7bf9054bad..e624cff941 100644
--- a/packages/admin/src/index.css
+++ b/packages/admin/src/index.css
@@ -99,6 +99,7 @@
/* Shadows — subtle like Rails admin */
--shadow-xs: rgba(43, 34, 51, 0.05) 0px 1px 1px;
--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
+ --shadow-nav: rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0.04) 0px 0px 0px 1px, rgba(0, 0, 0, 0.04) 0px 1px 2px -1px, rgba(0, 0, 0, 0.02) 0px 2px 4px 0px;
/* Sidebar + header tokens */
--spacing-sidebar-width: 220px;