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.

Give the seller panel the dashboard's mobile navigation

Damian Legawiecf02715f91503
diff --git a/packages/dashboard-core/src/components/settings-sidebar.tsx b/packages/dashboard-core/src/components/settings-sidebar.tsx
index 9988d5f6e7..dbb4623a68 100644
--- a/packages/dashboard-core/src/components/settings-sidebar.tsx
+++ b/packages/dashboard-core/src/components/settings-sidebar.tsx
@@ -138,9 +138,12 @@ function useIsSettingsSheetHidden() {
export function SettingsNavSheet({
open,
onOpenChange,
+ tenantId,
}: {
open: boolean
onOpenChange: (open: boolean) => void
+ /** See `SettingsSidebar` — a seller id on the marketplace panel. */
+ tenantId?: string
}) {
const { t } = useTranslation()
// Unmounted above `lg` rather than hidden with a utility class: `lg:hidden`
@@ -177,7 +180,11 @@ export function SettingsNavSheet({
{/* Close as the link is tapped rather than from an effect watching the
path: this body renders inside the Sheet, so it remounts on every
open and an effect could not tell "just opened" from "navigated". */}
- <SettingsNavBody tabIndex={0} onNavigate={() => onOpenChange(false)} />
+ <SettingsNavBody
+ tabIndex={0}
+ onNavigate={() => onOpenChange(false)}
+ tenantId={tenantId}
+ />
</div>
</SheetContent>
</Sheet>
diff --git a/packages/dashboard-core/src/components/top-bar-breadcrumbs.tsx b/packages/dashboard-core/src/components/top-bar-breadcrumbs.tsx
index c95a1cce1e..32705c2882 100644
--- a/packages/dashboard-core/src/components/top-bar-breadcrumbs.tsx
+++ b/packages/dashboard-core/src/components/top-bar-breadcrumbs.tsx
@@ -30,8 +30,8 @@ interface Crumb {
* worse than a shorter trail, and the page's own `PageHeader` carries the
* record's title anyway.
*/
-export function TopBarBreadcrumbs() {
- const trail = useCrumbs()
+export function TopBarBreadcrumbs({ tenantId }: { tenantId?: string } = {}) {
+ const trail = useCrumbs(tenantId)
if (!trail) return null
return <CrumbTrail crumbs={trail.crumbs} pathname={trail.pathname} className="min-w-0" />
@@ -49,8 +49,15 @@ export function TopBarBreadcrumbs() {
* the settings nav sheet, which is the fastest way between two settings pages
* on a screen with no settings sidebar.
*/
-export function MobileBreadcrumbBar({ onOpenSettingsNav }: { onOpenSettingsNav?: () => void }) {
- const trail = useCrumbs()
+export function MobileBreadcrumbBar({
+ onOpenSettingsNav,
+ tenantId,
+}: {
+ onOpenSettingsNav?: () => void
+ /** See `SettingsSidebar` — a seller id on the marketplace panel. */
+ tenantId?: string
+}) {
+ const trail = useCrumbs(tenantId)
if (!trail) return null
const { crumbs, pathname, inSettings } = trail
@@ -133,9 +140,14 @@ function CrumbTrail({
}
/** Resolves the trail for the current path, or null when there is nothing worth showing. */
-function useCrumbs(): { crumbs: Crumb[]; pathname: string; inSettings: boolean } | null {
+function useCrumbs(tenantId?: string): {
+ crumbs: Crumb[]
+ pathname: string
+ inSettings: boolean
+} | null {
const { t } = useTranslation()
- const { storeId } = useParams({ strict: false }) as { storeId?: string }
+ const { storeId: routeStoreId } = useParams({ strict: false }) as { storeId?: string }
+ const storeId = tenantId ?? routeStoreId
const pathname = useRouterState({ select: (s) => s.location.pathname })
const { main, bottom } = useNavEntries()
const settings = useSettingsNav()
diff --git a/packages/seller-dashboard/src/panel-chrome.tsx b/packages/seller-dashboard/src/panel-chrome.tsx
index 770c3b509a..6a76bd139c 100644
--- a/packages/seller-dashboard/src/panel-chrome.tsx
+++ b/packages/seller-dashboard/src/panel-chrome.tsx
@@ -1,5 +1,7 @@
import {
AppSidebar,
+ MobileBreadcrumbBar,
+ SettingsNavSheet,
SettingsSidebar,
StickyHeaderProvider,
TenantProvider,
@@ -8,7 +10,7 @@ import {
} from '@spree/dashboard-core'
import { SidebarInset, SidebarProvider, SidebarTrigger } from '@spree/dashboard-ui'
import { useParams, useRouterState } from '@tanstack/react-router'
-import type { ReactNode } from 'react'
+import { type ReactNode, useState } from 'react'
import { SellerSwitcher } from './components/seller-switcher'
/**
@@ -61,6 +63,10 @@ function PanelShell({
}) {
useAutoCollapseSidebar(inSettings)
+ // Below `lg` the settings rail is hidden, so its sheet is the only way
+ // between two settings pages. The trigger lives in the breadcrumb bar.
+ const [settingsNavOpen, setSettingsNavOpen] = useState(false)
+
return (
<>
<AppSidebar tenantId={sellerId} header={<SellerSwitcher />} />
@@ -79,6 +85,16 @@ function PanelShell({
</div>
</header>
+ <MobileBreadcrumbBar
+ tenantId={sellerId}
+ onOpenSettingsNav={() => setSettingsNavOpen(true)}
+ />
+ <SettingsNavSheet
+ open={settingsNavOpen}
+ onOpenChange={setSettingsNavOpen}
+ tenantId={sellerId}
+ />
+
{/* Settings pages bring their own padding, matching the dashboard. */}
{inSettings ? (
children