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.

Some minor design improvements (#14529)

Damian Legawiecc54c5c85e6a6
diff --git a/packages/dashboard-core/src/components/table-toolbar.tsx b/packages/dashboard-core/src/components/table-toolbar.tsx
index f3c8839dc3..eacab2a2c3 100644
--- a/packages/dashboard-core/src/components/table-toolbar.tsx
+++ b/packages/dashboard-core/src/components/table-toolbar.tsx
@@ -35,7 +35,7 @@ import {
ListFilter,
XIcon,
} from 'lucide-react'
-import { useCallback, useMemo, useState } from 'react'
+import { useCallback, useDeferredValue, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { getApiClient } from '../api-client'
import { useAuth } from '../hooks/use-auth'
@@ -271,123 +271,128 @@ export function TableToolbar({
search ||
(!hideSort && sortableColumns.length > 0) ||
columns.some((c) => c.default !== undefined)) && (
- <div className="flex flex-wrap items-center gap-2 border-b border-border-subtle px-3 py-2">
- {/* Search leads: it is the widest net, and the filters beside it
+ <div className="flex items-start gap-2 border-b border-border-subtle px-3 py-2">
+ {/* Only the filters wrap. They grow with what the operator has set,
+ where sort and columns are a fixed pair — letting the whole row
+ wrap dropped those two onto a line of their own the moment the
+ filters filled the width. */}
+ <div className="flex min-w-0 flex-1 flex-wrap items-center gap-2">
+ {/* Search leads: it is the widest net, and the filters beside it
narrow what it finds. Hidden on a phone, where the TopBar already
carries a search field — two search boxes stacked in one column is
the more confusing cost. A term set on desktop still shows as a
chip there, so it never filters a list invisibly. */}
- <SearchInput
- value={search}
- onValueChange={onSearchChange}
- placeholder={
- searchPlaceholder ?? t('admin.components.table_toolbar.search_placeholder')
- }
- clearLabel={t('admin.common.clear')}
- className="hidden h-[2.125rem] w-[240px] bg-card text-sm lg:flex"
- />
+ <SearchInput
+ value={search}
+ onValueChange={onSearchChange}
+ placeholder={
+ searchPlaceholder ?? t('admin.components.table_toolbar.search_placeholder')
+ }
+ clearLabel={t('admin.common.clear')}
+ className="hidden h-[2.125rem] w-[240px] bg-card text-sm lg:flex"
+ />
- {/* Reads as a verb rather than an icon: it is the way *in* to
+ {/* Reads as a verb rather than an icon: it is the way *in* to
everything the quick controls beside it don't cover, so it has to
look like an action and not a toggle. */}
- {/* Hidden when every filterable field already has a quick control:
+ {/* Hidden when every filterable field already has a quick control:
the button would open onto an empty list. */}
- {panelColumns.length > 0 && (
- <Popover open={filterOpen} onOpenChange={setFilterOpen}>
- <PopoverTrigger asChild>
- <Button variant="outline" size="sm" className="h-11 gap-1.5 lg:h-[2.125rem]">
- <ListFilter className="size-3.5" />
- {t('admin.components.table_toolbar.add_filter')}
- </Button>
- </PopoverTrigger>
- {/* `min(480px, …)` rather than a flat 480px: the panel is wider
+ {panelColumns.length > 0 && (
+ <Popover open={filterOpen} onOpenChange={setFilterOpen}>
+ <PopoverTrigger asChild>
+ <Button variant="outline" size="sm" className="h-11 gap-1.5 lg:h-[2.125rem]">
+ <ListFilter className="size-3.5" />
+ {t('admin.components.table_toolbar.add_filter')}
+ </Button>
+ </PopoverTrigger>
+ {/* `min(480px, …)` rather than a flat 480px: the panel is wider
than a phone, so a fixed width runs its right edge and the
Apply button off the screen. */}
- <PopoverContent align="start" className="w-[min(480px,calc(100vw-1rem))] p-0">
- <FilterPanel
- columns={panelColumns}
- allColumns={filterableColumns}
+ <PopoverContent align="start" className="w-[min(480px,calc(100vw-1rem))] p-0">
+ <FilterPanel
+ columns={panelColumns}
+ allColumns={filterableColumns}
+ filters={filters}
+ onApply={(f) => {
+ onFiltersChange(f)
+ setFilterOpen(false)
+ }}
+ onChange={onFiltersChange}
+ onClose={() => setFilterOpen(false)}
+ />
+ </PopoverContent>
+ </Popover>
+ )}
+
+ {quickFilterColumns.map((col) =>
+ col.filterType === 'date' ? (
+ <QuickDateFilter
+ key={col.key}
+ column={col}
filters={filters}
- onApply={(f) => {
- onFiltersChange(f)
- setFilterOpen(false)
- }}
- onChange={onFiltersChange}
- onClose={() => setFilterOpen(false)}
+ onFiltersChange={onFiltersChange}
/>
- </PopoverContent>
- </Popover>
- )}
-
- {quickFilterColumns.map((col) =>
- col.filterType === 'date' ? (
- <QuickDateFilter
- key={col.key}
- column={col}
- filters={filters}
- onFiltersChange={onFiltersChange}
- />
- ) : (
- <QuickEnumFilter
- key={col.key}
- column={col}
- filters={filters}
- onFiltersChange={onFiltersChange}
- />
- ),
- )}
+ ) : (
+ <QuickEnumFilter
+ key={col.key}
+ column={col}
+ filters={filters}
+ onFiltersChange={onFiltersChange}
+ />
+ ),
+ )}
- {/* The search term as a chip, mobile only — the field it came from is
+ {/* The search term as a chip, mobile only — the field it came from is
hidden there, so this is the only way to see or clear it. */}
- {search && (
- <span className="inline-flex h-11 shrink-0 items-center gap-1.5 rounded-lg border border-border bg-muted py-1 pr-1 pl-2.5 text-sm lg:hidden">
- <span className="text-muted-foreground">
- {t('admin.components.table_toolbar.search_placeholder')}
+ {search && (
+ <span className="inline-flex h-11 shrink-0 items-center gap-1.5 rounded-lg border border-border bg-muted py-1 pr-1 pl-2.5 text-sm lg:hidden">
+ <span className="text-muted-foreground">
+ {t('admin.components.table_toolbar.search_placeholder')}
+ </span>
+ <span className="truncate">{search}</span>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon-sm"
+ aria-label={t('admin.common.clear')}
+ onClick={() => onSearchChange('')}
+ >
+ <XIcon className="size-3.5" />
+ </Button>
</span>
- <span className="truncate">{search}</span>
+ )}
+ {chipFilters.map((entry) => (
+ <FilterChip
+ key={entry.key}
+ rules={entry.rules}
+ col={allCols.find((c) => c.key === entry.rules[0].field)}
+ onRemove={() => {
+ const removing = new Set(entry.rules.map((r) => r.id))
+ onFiltersChange(filters.filter((f) => !removing.has(f.id)))
+ }}
+ />
+ ))}
+ {filters.length > 0 && (
+ // Stays borderless while everything beside it is outlined: the
+ // rest of the row sets constraints, this one undoes them, and
+ // giving it the same weight would make "clear" look like a fifth
+ // filter. It matches on height so the row still sits on one line.
<Button
type="button"
variant="ghost"
- size="icon-sm"
- aria-label={t('admin.common.clear')}
- onClick={() => onSearchChange('')}
+ size="sm"
+ className="h-11 text-muted-foreground hover:text-foreground lg:h-[2.125rem]"
+ onClick={() => onFiltersChange([])}
>
- <XIcon className="size-3.5" />
+ {t('admin.components.table_toolbar.clear_all')}
</Button>
- </span>
- )}
- {chipFilters.map((entry) => (
- <FilterChip
- key={entry.key}
- rules={entry.rules}
- col={allCols.find((c) => c.key === entry.rules[0].field)}
- onRemove={() => {
- const removing = new Set(entry.rules.map((r) => r.id))
- onFiltersChange(filters.filter((f) => !removing.has(f.id)))
- }}
- />
- ))}
- {filters.length > 0 && (
- // Stays borderless while everything beside it is outlined: the
- // rest of the row sets constraints, this one undoes them, and
- // giving it the same weight would make "clear" look like a fifth
- // filter. It matches on height so the row still sits on one line.
- <Button
- type="button"
- variant="ghost"
- size="sm"
- className="h-11 text-muted-foreground hover:text-foreground lg:h-[2.125rem]"
- onClick={() => onFiltersChange([])}
- >
- {t('admin.components.table_toolbar.clear_all')}
- </Button>
- )}
+ )}
+ </div>
{/* Sort and columns close the row from the right. They shape the
view rather than narrowing it, so they sit apart from the filters
- — but on the same line, since both are things you reach for while
- reading a list rather than while naming one. */}
- <div className="ml-auto flex shrink-0 items-center gap-2">
+ — and stay on the first line however many filters are set. */}
+ <div className="flex shrink-0 items-center gap-2">
{/* Hidden when the table is drag-reorderable, since free sorting
would defeat the drag. */}
{!hideSort && sortableColumns.length > 0 && (
@@ -981,16 +986,45 @@ function InlineValueList({
queryKey: ['panel-tags', tenantId, column.taggableType],
queryFn: () => tagsClient?.list({ taggable_type: column.taggableType as TaggableType }),
enabled: isTags && isAuthenticated && Boolean(tagsClient),
- staleTime: 60_000,
+ // One list, filtered client-side, and it rarely changes — worth holding
+ // for the session so reopening the panel never refetches.
+ staleTime: 5 * 60_000,
+ gcTime: 30 * 60_000,
})
+ // Deferred so typing stays responsive: the input updates immediately while
+ // the list re-renders at React's convenience, matching the resource picker
+ // sheet. It lowers request volume under load rather than guaranteeing it —
+ // React may still let every keystroke through on a fast machine. What keeps
+ // that cheap is the cache: repeated prefixes are served from it, and only a
+ // genuinely new query reaches the network.
+ const deferredQuery = useDeferredValue(query)
+
const resources = useQuery({
// Tenant-scoped so a store or seller switch cannot reuse the previous
// tenant's results.
- queryKey: ['panel-resource-filter', column.filterResource?.queryKey, tenantId, query],
- queryFn: () => column.filterResource?.search(query),
+ queryKey: ['panel-resource-filter', column.filterResource?.queryKey, tenantId, deferredQuery],
+ queryFn: () => column.filterResource?.search(deferredQuery),
enabled: !isTags && !isCurrency && Boolean(column.filterResource),
- staleTime: 30_000,
+ // These lists are reference data an operator reopens repeatedly while
+ // narrowing one list, and the result is small now that only the displayed
+ // fields are requested. Holding it for the session keeps reopening the
+ // panel instant; `gcTime` outlives the unmount between opens.
+ staleTime: 5 * 60_000,
+ gcTime: 30 * 60_000,
+ // Keeps the previous matches on screen while the next query resolves, so
+ // the list does not blank on every keystroke.
+ //
+ // Only within one field of one tenant: the second argument is the query
+ // those results came from, so a change of store, seller or filter column
+ // drops them instead of briefly offering another tenant's records as
+ // though they were this one's.
+ placeholderData: (previous, previousQuery) => {
+ const [, previousResource, previousTenant] = (previousQuery?.queryKey ?? []) as unknown[]
+ const sameScope =
+ previousResource === column.filterResource?.queryKey && previousTenant === tenantId
+ return sameScope ? previous : undefined
+ },
})
const options = useMemo(() => {
diff --git a/packages/dashboard-ui/src/index.ts b/packages/dashboard-ui/src/index.ts
index 28d8e39a34..f530ed3951 100644
--- a/packages/dashboard-ui/src/index.ts
+++ b/packages/dashboard-ui/src/index.ts
@@ -69,6 +69,7 @@ export * from './spree/theme-toggle'
// ---------------------------------------------------------------------------
// UI primitives (shadcn) — see ./ui/*
// ---------------------------------------------------------------------------
+export * from './ui/accordion'
export * from './ui/alert'
export * from './ui/attachment'
export * from './ui/avatar'
diff --git a/packages/dashboard-ui/src/styles.css b/packages/dashboard-ui/src/styles.css
index f62e428784..42298e8500 100644
--- a/packages/dashboard-ui/src/styles.css
+++ b/packages/dashboard-ui/src/styles.css
@@ -31,9 +31,16 @@
/* Brand palette.
*
- * Surfaces, borders and text are Tailwind's `neutral` ramp — true greyscale,
- * zero chroma — so the single blue accent is the only colour in the palette
- * and reads unmistakably as interaction.
+ * Surfaces, borders and text are Tailwind's `stone` ramp — the same lightness
+ * ladder as `neutral`, carrying a trace of warm chroma (0.001–0.013) rather
+ * than none. Far too little to read as a colour: it stops large white and grey
+ * areas looking blue-cold, and leaves the blue accent still the only thing in
+ * the palette that reads as interaction.
+ *
+ * Values are stone's chroma and hue interpolated onto the lightnesses this
+ * palette already chose, rather than snapped to the nearest ramp step: the
+ * lightness decisions below are load-bearing for contrast, and none of them
+ * move.
*
* Primary CTAs stay near-black rather than adopting the site's blue button:
* in a dense admin UI the blue has to stay meaningful as a selection and
@@ -43,42 +50,42 @@
--brand-blue: oklch(0.5967 0.2212 258); /* #0077ff — site accent */
--brand-blue-strong: oklch(0.5106 0.1868 257.7); /* #0060ce — site link hover */
- --background: oklch(98.5% 0 none); /* neutral-50 */
- --foreground: oklch(0.145 0 0); /* neutral-950 */
+ --background: oklch(98.5% 0.001 106.423); /* stone-50 */
+ --foreground: oklch(0.145 0.0039 49.25); /* stone-950 */
--card: oklch(1 0 0); /* white cards, one step above the page */
- --card-foreground: oklch(0.145 0 0);
+ --card-foreground: oklch(0.145 0.0039 49.25);
--popover: oklch(1 0 0);
- --popover-foreground: oklch(0.145 0 0);
- --primary: oklch(0.145 0 0); /* neutral-950 — near-black primary CTAs */
+ --popover-foreground: oklch(0.145 0.0039 49.25);
+ --primary: oklch(0.145 0.0039 49.25); /* stone-950 — near-black primary CTAs */
--primary-foreground: oklch(1 0 0);
/* Filled surfaces (table headers, badges, secondary buttons) read as a
whisper against the white card rather than a distinct band. */
- --secondary: oklch(0.97 0 0); /* neutral-100 */
- --secondary-foreground: oklch(0.145 0 0);
- --muted: oklch(0.985 0 0); /* neutral-50 */
- /* Between neutral-500 and -600. Clears 4.5:1 against every surface this text
+ --secondary: oklch(0.97 0.001 106.424); /* stone-100 */
+ --secondary-foreground: oklch(0.145 0.0039 49.25);
+ --muted: oklch(0.985 0.001 106.423); /* stone-50 */
+ /* Between stone-500 and -600. Clears 4.5:1 against every surface this text
actually lands on — including --accent, the darkest of them — where the
- neutral-500 step measured 4.15:1. Dark mode keeps its own value: it already
+ stone-500 step measured 4.15:1. Dark mode keeps its own value: it already
passes on all four grounds. */
- --muted-foreground: oklch(0.535 0 0);
+ --muted-foreground: oklch(0.535 0.0127 58.071);
/* Hover/highlight for menu items and table rows. A lighter step than
- neutral-200: these sit on white surfaces, where that value reads as a
+ stone-200: these sit on white surfaces, where that value reads as a
pressed state rather than a hover. The sidebar shares this value via
--sidebar-accent so a highlighted row looks the same wherever it is. */
- --accent: oklch(0.95 0 0);
- --accent-foreground: oklch(0.145 0 0);
+ --accent: oklch(0.95 0.0019 106.424);
+ --accent-foreground: oklch(0.145 0.0039 49.25);
--destructive: oklch(0.58 0.22 27); /* red-600 */
--destructive-foreground: oklch(1 0 0); /* #ffffff */
- /* neutral-200 — rules stay legible but recede, so a dense table reads as
+ /* stone-200 — rules stay legible but recede, so a dense table reads as
rows of content rather than a grid. */
- --border: oklch(0.922 0 0);
+ --border: oklch(0.922 0.003 48.717);
/* Half-strength rule for dividers *inside* a container — card header/footer
splits, dialog and sheet separators, table chrome. Distinct from --border,
which draws a container's own edge. Resolved to a real colour rather than
an opacity utility so it also works inside arbitrary values such as the
sticky table header's inset shadow, where `/50` has no effect. */
--border-subtle: color-mix(in srgb, var(--border) 50%, transparent);
- --input: oklch(0.922 0 0);
+ --input: oklch(0.922 0.003 48.717);
--ring: var(--brand-blue);
--chart-1: oklch(0.7663 0.1067 254.4);
--chart-2: oklch(0.5967 0.2212 258); /* brand blue */
@@ -88,13 +95,13 @@
--radius: 0.75rem;
/* Sidebar — one step off the page, so it reads as its own surface. */
- --sidebar: oklch(97% 0 none); /* neutral-100 */
- --sidebar-foreground: oklch(37.1% 0 none);
- --sidebar-primary: oklch(0.145 0 0);
+ --sidebar: oklch(97% 0.001 106.424); /* stone-100 */
+ --sidebar-foreground: oklch(37.1% 0.0099 67.558);
+ --sidebar-primary: oklch(0.145 0.0039 49.25);
--sidebar-primary-foreground: oklch(1 0 0);
- --sidebar-accent: oklch(0.922 0 0); /* neutral-200 */
- --sidebar-accent-foreground: oklch(0.145 0 0);
- --sidebar-border: oklch(0.9 0 0);
+ --sidebar-accent: oklch(0.922 0.003 48.717); /* stone-200 */
+ --sidebar-accent-foreground: oklch(0.145 0.0039 49.25);
+ --sidebar-border: oklch(0.9 0.0039 48.717);
--sidebar-ring: var(--brand-blue);
/* Status ramps, following Vercel's Geist colour system.
@@ -139,26 +146,26 @@
.dark {
/* Vercel-style "true black" base, with surfaces stepping up in lightness. */
--background: oklch(0 0 0); /* #000000 */
- --foreground: oklch(0.95 0 0); /* #ededed */
- --card: oklch(0.145 0 0); /* #0a0a0a — surface */
- --card-foreground: oklch(0.95 0 0);
- --popover: oklch(0.145 0 0);
- --popover-foreground: oklch(0.95 0 0);
+ --foreground: oklch(0.95 0.0019 106.424); /* stone-100-ish */
+ --card: oklch(0.145 0.0039 49.25); /* stone-950 — surface */
+ --card-foreground: oklch(0.95 0.0019 106.424);
+ --popover: oklch(0.145 0.0039 49.25);
+ --popover-foreground: oklch(0.95 0.0019 106.424);
/* Mirrors the light theme's primary: there a navy fill carries white text,
so here the two swap rather than the button taking on its own colour. */
- --primary: oklch(0.95 0 0);
- --primary-foreground: oklch(0.145 0 0); /* neutral-950 — light theme's primary */
+ --primary: oklch(0.95 0.0019 106.424);
+ --primary-foreground: oklch(0.145 0.0039 49.25); /* stone-950 — light theme's primary */
/* Above --card, but only just. These fill elements that sit *on* a card
(combobox chips, badges, secondary buttons, table header rows), so a value
at or under the card's lightness erases them — while too big a step reads
as a bright band across a full-width table header. Dark mode raises where
light mode lowers, since a surface reads as raised by getting lighter. */
- --secondary: oklch(0.225 0 0);
- --secondary-foreground: oklch(0.95 0 0);
- --muted: oklch(0.185 0 0);
- --muted-foreground: oklch(0.62 0 0); /* #888 */
- --accent: oklch(0.225 0 0); /* hover surface, a step above --muted */
- --accent-foreground: oklch(0.95 0 0);
+ --secondary: oklch(0.225 0.0062 56.043);
+ --secondary-foreground: oklch(0.95 0.0019 106.424);
+ --muted: oklch(0.185 0.0051 56.043);
+ --muted-foreground: oklch(0.62 0.0117 58.071); /* stone-500-ish */
+ --accent: oklch(0.225 0.0062 56.043); /* hover surface, a step above --muted */
+ --accent-foreground: oklch(0.95 0.0019 106.424);
--destructive: oklch(0.704 0.191 22.216);
--border: oklch(1 0 0 / 12%);
--border-subtle: color-mix(in srgb, var(--border) 50%, transparent);
@@ -169,14 +176,14 @@
--chart-3: oklch(0.546 0.245 262.881);
--chart-4: oklch(0.488 0.243 264.376);
--chart-5: oklch(0.424 0.199 265.638);
- --sidebar: oklch(0.145 0 0); /* #0a0a0a — slightly elevated from background */
- --sidebar-foreground: oklch(0.95 0 0);
- --sidebar-primary: oklch(0.95 0 0);
- --sidebar-primary-foreground: oklch(0.145 0 0);
- --sidebar-accent: oklch(0.27 0 0);
- --sidebar-accent-foreground: oklch(0.95 0 0);
+ --sidebar: oklch(0.145 0.0039 49.25); /* stone-950 — slightly elevated from background */
+ --sidebar-foreground: oklch(0.95 0.0019 106.424);
+ --sidebar-primary: oklch(0.95 0.0019 106.424);
+ --sidebar-primary-foreground: oklch(0.145 0.0039 49.25);
+ --sidebar-accent: oklch(0.27 0.0071 34.298);
+ --sidebar-accent-foreground: oklch(0.95 0.0019 106.424);
--sidebar-border: oklch(1 0 0 / 10%);
- --sidebar-ring: oklch(0.708 0 0);
+ --sidebar-ring: oklch(0.708 0.01 56.259);
/* Geist's dark ramps are not the light ones dimmed — the fill becomes a deep
shade of the hue and the text becomes brighter than its light-mode
@@ -420,12 +427,12 @@
@layer base {
:root {
- --scrollbar-thumb: oklch(0.78 0 0); /* neutral-300-ish */
- --scrollbar-thumb-hover: oklch(0.62 0 0);
+ --scrollbar-thumb: oklch(0.78 0.0078 56.259); /* stone-300-ish */
+ --scrollbar-thumb-hover: oklch(0.62 0.0117 58.071);
}
.dark {
- --scrollbar-thumb: oklch(0.35 0 0); /* zinc-700-ish */
- --scrollbar-thumb-hover: oklch(0.45 0 0);
+ --scrollbar-thumb: oklch(0.35 0.0093 67.558); /* stone-700-ish */
+ --scrollbar-thumb-hover: oklch(0.45 0.0111 73.639);
}
/* Themed scrollbar inside floating surfaces only — page scrollbar stays
diff --git a/packages/dashboard-ui/src/ui/accordion.tsx b/packages/dashboard-ui/src/ui/accordion.tsx
new file mode 100644
index 0000000000..879b67b82c
--- /dev/null
+++ b/packages/dashboard-ui/src/ui/accordion.tsx
@@ -0,0 +1,83 @@
+import { Accordion as AccordionPrimitive } from '@base-ui/react/accordion'
+import { ChevronDownIcon } from 'lucide-react'
+import type * as React from 'react'
+import { cn } from '../lib/utils'
+
+/**
+ * Vertically stacked, expandable sections sharing one frame.
+ *
+ * One item is open at a time by default: a list of steps is read in order, and
+ * letting several stand open turns it back into the wall of text the collapse
+ * exists to avoid. Pass `multiple` where the sections are independent rather
+ * than sequential.
+ */
+function Accordion({ ...props }: React.ComponentProps<typeof AccordionPrimitive.Root>) {
+ return <AccordionPrimitive.Root data-slot="accordion" {...props} />
+}
+
+/** One section. `value` identifies it for `defaultValue` and controlled use. */
+function AccordionItem({
+ className,
+ ...props
+}: React.ComponentProps<typeof AccordionPrimitive.Item>) {
+ return (
+ <AccordionPrimitive.Item
+ data-slot="accordion-item"
+ // Rules between items rather than around each: the group is one object,
+ // so the last item closes on the container's own edge.
+ className={cn('border-border border-b last:border-b-0', className)}
+ {...props}
+ />
+ )
+}
+
+/**
+ * The always-visible row that opens its section. Renders a chevron after the
+ * children, so callers pass only the label's own content.
+ */
+function AccordionTrigger({
+ className,
+ children,
+ ...props
+}: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {
+ return (
+ <AccordionPrimitive.Header className="flex">
+ <AccordionPrimitive.Trigger
+ data-slot="accordion-trigger"
+ className={cn(
+ 'group/accordion-trigger flex flex-1 cursor-pointer items-center gap-3 px-4 py-3.5 text-left text-base font-medium transition-colors outline-none hover:bg-accent focus-visible:bg-accent',
+ className,
+ )}
+ {...props}
+ >
+ {children}
+ <ChevronDownIcon className="ms-auto size-4 shrink-0 text-muted-foreground transition-transform duration-200 ease-out group-data-[panel-open]/accordion-trigger:rotate-180 motion-reduce:transition-none" />
+ </AccordionPrimitive.Trigger>
+ </AccordionPrimitive.Header>
+ )
+}
+
+/**
+ * The revealed panel. Carries the section's padding, so `className` styles the
+ * content rather than the animated box around it.
+ */
+function AccordionContent({
+ className,
+ children,
+ ...props
+}: React.ComponentProps<typeof AccordionPrimitive.Panel>) {
+ return (
+ <AccordionPrimitive.Panel
+ data-slot="accordion-content"
+ // Height animates off Base UI's own `--accordion-panel-height`, which it
+ // measures for us — `height: auto` is not animatable, so without the
+ // variable the panel would snap open.
+ className="h-(--accordion-panel-height) overflow-hidden transition-[height] duration-200 ease-out data-[ending-style]:h-0 data-[starting-style]:h-0 motion-reduce:transition-none"
+ {...props}
+ >
+ <div className={cn('px-4 pb-4', className)}>{children}</div>
+ </AccordionPrimitive.Panel>
+ )
+}
+
+export { Accordion, AccordionContent, AccordionItem, AccordionTrigger }
diff --git a/packages/dashboard-ui/src/ui/card.tsx b/packages/dashboard-ui/src/ui/card.tsx
index c8f6a84629..74ebfcaa95 100644
--- a/packages/dashboard-ui/src/ui/card.tsx
+++ b/packages/dashboard-ui/src/ui/card.tsx
@@ -12,7 +12,7 @@ function Card({ className, ...props }: React.ComponentProps<'div'>) {
// the document, laying the whole page out wider than the viewport. `clip`
// rather than `hidden` so `overflow-y` stays `visible` and sticky
// descendants keep resolving against the page.
- 'group/card flex flex-col min-w-0 overflow-x-clip break-words bg-card text-card-foreground border border-border rounded-xl',
+ 'group/card flex flex-col min-w-0 overflow-x-clip break-words bg-card text-card-foreground border border-border/80 rounded-xl',
className,
)}
{...props}
diff --git a/packages/dashboard/src/hooks/use-admin-users.ts b/packages/dashboard/src/hooks/use-admin-users.ts
index f2d12e6300..989fba46e3 100644
--- a/packages/dashboard/src/hooks/use-admin-users.ts
+++ b/packages/dashboard/src/hooks/use-admin-users.ts
@@ -10,7 +10,8 @@ import { adminClient, i18n } from '@spree/dashboard-core'
export function adminUserAutocompleteProps(queryKey: string) {
return {
queryKey,
- search: (q: string) => adminClient.adminUsers.list({ email_cont: q, limit: 10 }),
+ search: (q: string) =>
+ adminClient.adminUsers.list({ email_cont: q, limit: 100, fields: ['email'] }),
hydrate: (ids: string[]) => adminClient.adminUsers.list({ id_in: ids, limit: ids.length }),
getOptionLabel: (a: AdminUser) => a.email ?? a.id,
placeholder: i18n.t('admin.staff.autocomplete.placeholder'),
diff --git a/packages/dashboard/src/hooks/use-categories.ts b/packages/dashboard/src/hooks/use-categories.ts
index 665d7ef348..8cf9c98f97 100644
--- a/packages/dashboard/src/hooks/use-categories.ts
+++ b/packages/dashboard/src/hooks/use-categories.ts
@@ -161,7 +161,12 @@ export function categoryAutocompleteProps(queryKey: string) {
return {
queryKey,
search: (q: string) =>
- adminClient.categories.list({ pretty_name_cont: q, limit: 20, sort: 'pretty_name' }),
+ adminClient.categories.list({
+ pretty_name_cont: q,
+ limit: 100,
+ sort: 'pretty_name',
+ fields: ['pretty_name', 'name'],
+ }),
hydrate: (ids: string[]) => adminClient.categories.list({ id_in: ids, limit: ids.length }),
getOptionLabel: (c: Category) => c.pretty_name ?? c.name ?? c.id,
placeholder: i18n.t('admin.products.category_search_placeholder'),
diff --git a/packages/dashboard/src/hooks/use-channels.ts b/packages/dashboard/src/hooks/use-channels.ts
index f38f29e208..2ba39548cc 100644
--- a/packages/dashboard/src/hooks/use-channels.ts
+++ b/packages/dashboard/src/hooks/use-channels.ts
@@ -66,7 +66,13 @@ export function useDeleteChannel() {
export function channelAutocompleteProps(queryKey: string) {
return {
queryKey,
- search: (q: string) => adminClient.channels.list({ name_cont: q, limit: 20, sort: 'name' }),
+ search: (q: string) =>
+ adminClient.channels.list({
+ name_cont: q,
+ limit: 100,
+ sort: 'name',
+ fields: ['name', 'code'],
+ }),
hydrate: (ids: string[]) => adminClient.channels.list({ id_in: ids, limit: ids.length }),
getOptionLabel: (c: Channel) => c.name ?? c.code ?? c.id,
placeholder: i18n.t('admin.pages.channels.search_placeholder'),
diff --git a/packages/dashboard/src/hooks/use-collections.ts b/packages/dashboard/src/hooks/use-collections.ts
index 19f3f2f8d3..545ddc39c7 100644
--- a/packages/dashboard/src/hooks/use-collections.ts
+++ b/packages/dashboard/src/hooks/use-collections.ts
@@ -169,8 +169,9 @@ export function collectionAutocompleteProps(queryKey: string) {
adminClient.collections.list({
name_cont: q,
automatic_eq: false,
- limit: 20,
+ limit: 100,
sort: 'name',
+ fields: ['name'],
}),
hydrate: (ids: string[]) => adminClient.collections.list({ id_in: ids, limit: ids.length }),
getOptionLabel: (c: Collection) => c.name ?? c.id,
diff --git a/packages/dashboard/src/hooks/use-custom-field-definitions.ts b/packages/dashboard/src/hooks/use-custom-field-definitions.ts
index 80545f3f47..cddbb2a1ff 100644
--- a/packages/dashboard/src/hooks/use-custom-field-definitions.ts
+++ b/packages/dashboard/src/hooks/use-custom-field-definitions.ts
@@ -28,8 +28,9 @@ export function customFieldDefinitionAutocompleteProps(resourceType: string) {
adminClient.customFieldDefinitions.list({
resource_type_eq: resourceType,
label_or_key_cont: q,
- limit: 20,
+ limit: 100,
sort: 'key',
+ fields: ['label', 'key', 'namespace'],
}),
hydrate: (ids: string[]) =>
adminClient.customFieldDefinitions.list({ id_in: ids, limit: ids.length }),
diff --git a/packages/dashboard/src/hooks/use-customer-groups.ts b/packages/dashboard/src/hooks/use-customer-groups.ts
index f35224f3ee..b2a4ffc469 100644
--- a/packages/dashboard/src/hooks/use-customer-groups.ts
+++ b/packages/dashboard/src/hooks/use-customer-groups.ts
@@ -29,7 +29,7 @@ export function customerGroupAutocompleteProps(queryKey: string) {
return {
queryKey,
search: (q: string) =>
- adminClient.customerGroups.list({ name_cont: q, limit: 20, sort: 'name' }),
+ adminClient.customerGroups.list({ name_cont: q, limit: 100, sort: 'name', fields: ['name'] }),
hydrate: (ids: string[]) => adminClient.customerGroups.list({ id_in: ids, limit: ids.length }),
getOptionLabel: (g: CustomerGroup) => g.name ?? g.id,
placeholder: i18n.t('admin.customer_groups.autocomplete.placeholder'),
diff --git a/packages/dashboard/src/hooks/use-customers.ts b/packages/dashboard/src/hooks/use-customers.ts
index 6aa372e1d9..bf5bf7b35d 100644
--- a/packages/dashboard/src/hooks/use-customers.ts
+++ b/packages/dashboard/src/hooks/use-customers.ts
@@ -17,19 +17,24 @@ import { useQuery } from '@tanstack/react-query'
* `Customer.search` is a Ransack alias the admin controller resolves into
* `email_cont OR first_name_cont OR last_name_cont` — so a single query
* narrows by either the email or the name.
- */
-/**
- * Customer picker wiring. Pass `companyId` to narrow the list to people who
- * may buy for that company — members of the node itself or of any ancestor,
- * since standing covers a node and everything below it. The query key carries
- * the company so switching it refetches rather than serving the previous
- * company's people from cache.
+ *
+ * Pass `companyId` to narrow the list to people who may buy for that company —
+ * members of the node itself or of any ancestor, since standing covers a node
+ * and everything below it. The query key carries the company so switching it
+ * refetches rather than serving the previous company's people from cache.
*/
export function customerAutocompleteProps(queryKey: string, companyId?: string | null) {
const scope = companyId ? { with_standing_for_company: companyId } : {}
return {
queryKey: companyId ? `${queryKey}:${companyId}` : queryKey,
- search: (q: string) => adminClient.customers.list({ search: q, limit: 10, ...scope }),
+ search: (q: string) =>
+ adminClient.customers.list({ search: q, limit: 100, fields: ['email'], ...scope }),
+ // Deliberately unscoped, where `search` is not: this resolves ids the form
+ // already holds into labels, and offers nothing selectable. Narrowing it to
+ // the company would make a selection taken before the company changed
+ // resolve to nothing and render as a raw id, trading a correct label for no
+ // gain — the scope that matters is on `search`, which decides what can be
+ // picked.
hydrate: (ids: string[]) => adminClient.customers.list({ id_in: ids, limit: ids.length }),
getOptionLabel: (c: Customer) => c.email ?? c.id,
placeholder: i18n.t('admin.customers.autocomplete.placeholder'),
diff --git a/packages/dashboard/src/hooks/use-gift-cards.ts b/packages/dashboard/src/hooks/use-gift-cards.ts
index 3963e566ab..89fb168d87 100644
--- a/packages/dashboard/src/hooks/use-gift-cards.ts
+++ b/packages/dashboard/src/hooks/use-gift-cards.ts
@@ -86,7 +86,12 @@ export function giftCardBatchAutocompleteProps(queryKey: string) {
return {
queryKey,
search: (q: string) =>
- adminClient.giftCardBatches.list({ prefix_cont: q, limit: 20, sort: '-created_at' }),
+ adminClient.giftCardBatches.list({
+ prefix_cont: q,
+ limit: 100,
+ sort: '-created_at',
+ fields: ['prefix'],
+ }),
hydrate: (ids: string[]) => adminClient.giftCardBatches.list({ id_in: ids, limit: ids.length }),
getOptionLabel: (b: GiftCardBatch) => b.prefix ?? b.id,
placeholder: i18n.t('admin.gift_cards.batch_autocomplete.placeholder'),
diff --git a/packages/dashboard/src/hooks/use-option-types.ts b/packages/dashboard/src/hooks/use-option-types.ts
index e852ed3d44..102dc93cee 100644
--- a/packages/dashboard/src/hooks/use-option-types.ts
+++ b/packages/dashboard/src/hooks/use-option-types.ts
@@ -21,7 +21,13 @@ interface UseOptionTypesParams {
export function optionTypeAutocompleteProps(queryKey: string) {
return {
queryKey,
- search: (q: string) => adminClient.optionTypes.list({ name_cont: q, limit: 20, sort: 'name' }),
+ search: (q: string) =>
+ adminClient.optionTypes.list({
+ name_cont: q,
+ limit: 100,
+ sort: 'name',
+ fields: ['name', 'label'],
+ }),
hydrate: (ids: string[]) => adminClient.optionTypes.list({ id_in: ids, limit: ids.length }),
getOptionLabel: (optionType: OptionType) =>
optionType.label ?? optionType.name ?? optionType.id,
diff --git a/packages/dashboard/src/hooks/use-product-types.ts b/packages/dashboard/src/hooks/use-product-types.ts
index ada1149536..cf06d31690 100644
--- a/packages/dashboard/src/hooks/use-product-types.ts
+++ b/packages/dashboard/src/hooks/use-product-types.ts
@@ -32,7 +32,8 @@ export function useProductTypes({ page = 1, limit = 100 }: UseProductTypesParams
export function productTypeAutocompleteProps(queryKey: string) {
return {
queryKey,
- search: (q: string) => adminClient.productTypes.list({ name_cont: q, limit: 20, sort: 'name' }),
+ search: (q: string) =>
+ adminClient.productTypes.list({ name_cont: q, limit: 100, sort: 'name', fields: ['name'] }),
hydrate: (ids: string[]) => adminClient.productTypes.list({ id_in: ids, limit: ids.length }),
getOptionLabel: (productType: ProductType) => productType.name ?? productType.id,
placeholder: i18n.t('admin.product_types.search_placeholder'),
diff --git a/packages/dashboard/src/hooks/use-products.ts b/packages/dashboard/src/hooks/use-products.ts
index 6447908bee..20d984754b 100644
--- a/packages/dashboard/src/hooks/use-products.ts
+++ b/packages/dashboard/src/hooks/use-products.ts
@@ -25,7 +25,8 @@ interface UseProductsParams {
export function productAutocompleteProps(queryKey: string) {
return {
queryKey,
- search: (q: string) => adminClient.products.list({ name_cont: q, limit: 10, sort: 'name' }),
+ search: (q: string) =>
+ adminClient.products.list({ name_cont: q, limit: 100, sort: 'name', fields: ['name'] }),
hydrate: (ids: string[]) => adminClient.products.list({ id_in: ids, limit: ids.length }),
getOptionLabel: (product: Product) => product.name ?? product.id,
placeholder: i18n.t('admin.products.autocomplete.placeholder'),
diff --git a/packages/dashboard/src/hooks/use-sellers.ts b/packages/dashboard/src/hooks/use-sellers.ts
index 0ff8e9a991..ace0df23e2 100644
--- a/packages/dashboard/src/hooks/use-sellers.ts
+++ b/packages/dashboard/src/hooks/use-sellers.ts
@@ -34,7 +34,8 @@ export function useSellers(params?: ListParams & Record<string, unknown>) {
export function sellerAutocompleteProps(queryKey: string) {
return {
queryKey,
- search: (q: string) => adminClient.sellers.list({ name_cont: q, limit: 20, sort: 'name' }),
+ search: (q: string) =>
+ adminClient.sellers.list({ name_cont: q, limit: 100, sort: 'name', fields: ['name'] }),
hydrate: (ids: string[]) => adminClient.sellers.list({ id_in: ids, limit: ids.length }),
getOptionLabel: (seller: Seller) => seller.name ?? seller.id,
placeholder: i18n.t('admin.sellers.autocomplete.placeholder'),
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/getting-started.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/getting-started.tsx
index 1efee1655a..c5c3c166e4 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/getting-started.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/getting-started.tsx
@@ -1,18 +1,18 @@
import type { SetupTask } from '@spree/admin-sdk'
import { PageHeader, Slot, useStore } from '@spree/dashboard-core'
import {
+ Accordion,
+ AccordionContent,
+ AccordionItem,
+ AccordionTrigger,
Button,
Card,
- CardTitle,
- Collapsible,
- CollapsibleContent,
- CollapsibleTrigger,
Progress,
ProgressValue,
Skeleton,
} from '@spree/dashboard-ui'
import { createFileRoute, Link } from '@tanstack/react-router'
-import { CheckCircle2Icon, ChevronDownIcon, CircleIcon } from 'lucide-react'
+import { CheckCircle2Icon, CircleIcon } from 'lucide-react'
import { useTranslation } from 'react-i18next'
import '../../../components/spree/setup-tasks/register'
import { setupTaskSlot } from '../../../components/spree/setup-tasks/types'
@@ -82,54 +82,58 @@ function GettingStartedPage() {
</ProgressValue>
</Progress>
- <div className="flex flex-col gap-4">
- {tasks.map((task) => {
- const link = TASK_LINKS[task.name]
- const description = taskCopy(task, 'description')
- const cta = taskCopy(task, 'cta')
+ {/* One card holding every step, rather than a card each: this is a single
+ checklist read top to bottom, and five separate frames made it read as
+ five unrelated things. Opens on the first unfinished step. */}
+ <Card className="overflow-hidden py-0">
+ <Accordion defaultValue={firstPending ? [firstPending] : []}>
+ {tasks.map((task) => {
+ const link = TASK_LINKS[task.name]
+ const description = taskCopy(task, 'description')
+ const cta = taskCopy(task, 'cta')
- return (
- <Card key={task.name} className="overflow-hidden py-0">
- <Collapsible defaultOpen={task.name === firstPending}>
- <CollapsibleTrigger className="group flex w-full cursor-pointer items-center gap-3 p-4 text-left hover:bg-accent">
+ return (
+ <AccordionItem key={task.name} value={task.name}>
+ <AccordionTrigger>
{task.done ? (
- <CheckCircle2Icon className="size-5 shrink-0 text-green-600" />
+ <CheckCircle2Icon className="size-5 shrink-0 text-success" />
) : (
<CircleIcon className="size-5 shrink-0 text-muted-foreground" />
)}
- <CardTitle className="grow">{taskCopy(task, 'title')}</CardTitle>
- <ChevronDownIcon className="size-4 shrink-0 text-muted-foreground transition-transform group-data-[panel-open]:rotate-180" />
- </CollapsibleTrigger>
- {/* keepMounted so slot components mount even while their card is
+ {/* Muted once done, so a glance down the list separates what
+ is left from what is finished without reading the icons. */}
+ <span className={task.done ? 'text-muted-foreground' : undefined}>
+ {taskCopy(task, 'title')}
+ </span>
+ </AccordionTrigger>
+ {/* keepMounted so slot components mount even while their step is
collapsed — the storefront task auto-opens its sheet from the
Vercel callback param, which requires being mounted. */}
- <CollapsibleContent keepMounted>
- <div className="flex flex-col items-start gap-3 border-t px-4 py-4 pl-12">
- <Slot
- name={setupTaskSlot(task.name)}
- context={{ task, store, storeId }}
- fallback={
- <>
- {description && (
- <p className="text-muted-foreground text-sm">{description}</p>
- )}
- {link && cta && (
- <Button asChild variant={task.done ? 'outline' : 'default'}>
- <Link to={link} params={{ storeId }}>
- {cta}
- </Link>
- </Button>
- )}
- </>
- }
- />
- </div>
- </CollapsibleContent>
- </Collapsible>
- </Card>
- )
- })}
- </div>
+ <AccordionContent keepMounted className="flex flex-col items-start gap-3 ps-12">
+ <Slot
+ name={setupTaskSlot(task.name)}
+ context={{ task, store, storeId }}
+ fallback={
+ <>
+ {description && (
+ <p className="text-muted-foreground text-sm">{description}</p>
+ )}
+ {link && cta && (
+ <Button asChild variant={task.done ? 'outline' : 'default'}>
+ <Link to={link} params={{ storeId }}>
+ {cta}
+ </Link>
+ </Button>
+ )}
+ </>
+ }
+ />
+ </AccordionContent>
+ </AccordionItem>
+ )
+ })}
+ </Accordion>
+ </Card>
</div>
)
}
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/index.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/index.tsx
index 6327261ea5..dc06feece2 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/index.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/index.tsx
@@ -90,7 +90,7 @@ function SettingsCard({ entry }: { entry: SettingsNavEntry }) {
const description = resolveNavDescription(entry, t)
return (
- <Card className="p-0 transition-colors hover:bg-accent hover:border-neutral-300 dark:hover:border-neutral-800">
+ <Card className="p-0 transition-colors hover:bg-accent/80 hover:border-neutral-200 dark:hover:border-neutral-800">
{/* The whole card is the target — a small title-only link would fail the
44px minimum on touch and leaves most of the card dead to a click. */}
{/* Paths come from a runtime registry plugins extend, so they can't be
diff --git a/packages/dashboard/src/routes/login.tsx b/packages/dashboard/src/routes/login.tsx
index cc5b9c241d..23d52a1278 100644
--- a/packages/dashboard/src/routes/login.tsx
+++ b/packages/dashboard/src/routes/login.tsx
@@ -157,24 +157,38 @@ function PasswordLoginForm() {
/>
{errors.email && <p className="text-sm text-destructive">{errors.email.message}</p>}
</div>
- <div className="grid gap-2">
- <div className="flex items-center justify-between">
- <Label htmlFor="password">{t('admin.fields.password.label')}</Label>
- <Link to="/forgot-password" className="text-sm underline-offset-4 hover:underline">
- {t('admin.auth.forgot_password.link')}
- </Link>
- </div>
+ {/* Password, submit and the recovery link share one grid so the link can
+ sit on the label's row visually while coming last in source order.
+ That makes tabbing run email → password → Sign in — the path someone
+ signing in actually takes — and only then offer the way out to
+ recovery. Ordering it visually rather than dropping it from the tab
+ sequence keeps it reachable by keyboard. */}
+ <div className="grid grid-cols-2 gap-x-2 gap-y-2">
+ <Label htmlFor="password" className="col-start-1 row-start-1 self-center">
+ {t('admin.fields.password.label')}
+ </Label>
<Input
id="password"
type="password"
+ className="col-span-2 row-start-2"
aria-invalid={!!errors.password || undefined}
{...form.register('password')}
/>
- {errors.password && <p className="text-sm text-destructive">{errors.password.message}</p>}
+ {errors.password && (
+ <p className="col-span-2 text-sm text-destructive">{errors.password.message}</p>
+ )}
+ {/* Auto-placed rather than pinned to a row: naming a row would reserve
+ it even when no error renders, leaving a gap above the button. */}
+ <Button type="submit" className="col-span-2 mt-2 w-full" disabled={isLoading}>
+ {isLoading ? t('admin.actions.signing_in') : t('admin.actions.sign_in')}
+ </Button>
+ <Link
+ to="/forgot-password"
+ className="col-start-2 row-start-1 justify-self-end self-center text-sm underline-offset-4 hover:underline"
+ >
+ {t('admin.auth.forgot_password.link')}
+ </Link>
</div>
- <Button type="submit" className="w-full" disabled={isLoading}>
- {isLoading ? t('admin.actions.signing_in') : t('admin.actions.sign_in')}
- </Button>
</div>
</form>
)
diff --git a/packages/dashboard/src/tables/orders.tsx b/packages/dashboard/src/tables/orders.tsx
index b8cfdcf6ea..14634fee25 100644
--- a/packages/dashboard/src/tables/orders.tsx
+++ b/packages/dashboard/src/tables/orders.tsx
@@ -4,6 +4,7 @@ import { Link } from '@tanstack/react-router'
import i18n from 'i18next'
import { ShoppingCartIcon } from 'lucide-react'
import { channelAutocompleteProps } from '../hooks/use-channels'
+import { customerAutocompleteProps } from '../hooks/use-customers'
import { sellerAutocompleteProps } from '../hooks/use-sellers'
import { orderGroupSearch } from '../lib/order-group-search'
@@ -56,6 +57,14 @@ defineTable('orders', {
label: i18n.t('admin.orders.columns.customer'),
sortable: true,
filterable: true,
+ // Picked from a list rather than typed: an operator looking for one
+ // customer's orders knows who they mean, not how their address is
+ // spelled. Filters through the `customer` association's id — `email` is
+ // what the column *shows*, but matching it as free text would also miss
+ // a guest order placed under a second address.
+ filterType: 'resource',
+ filterResource: customerAutocompleteProps('orders-table-customer-filter'),
+ ransackAttribute: 'customer_id',
default: true,
className: 'text-sm',
render: (order) => order.email ?? '—',