Skip to content

Commit 8cc1ceb

Browse files
improvement(settings): make the sidebar wordmark a plane attribute
Replacing the Back chip everywhere was too broad — account and organization are reached from inside the app, so Back is right there. Self-host is reached from outside it (the CLI wizard, the README), so it leads with the brand mark instead. SETTINGS_PLANE_CHROME declares that per plane, keyed on StandaloneSettingsPlane so adding a plane forces the decision rather than defaulting silently. It also absorbs the shell's parallel plane-label map.
1 parent 2fa102e commit 8cc1ceb

3 files changed

Lines changed: 58 additions & 17 deletions

File tree

apps/sim/components/settings/navigation.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,23 @@ export const ACCOUNT_SETTINGS_GROUPS = [
283283
{ key: 'platform', title: 'Platform' },
284284
] as const
285285

286+
/** Planes with their own standalone shell; the workspace plane renders inside the editor. */
287+
export type StandaloneSettingsPlane = Exclude<SettingsPlane, 'workspace'>
288+
289+
/**
290+
* Per-plane sidebar chrome. Self-host is reached from outside the app (the CLI
291+
* wizard, the README), so it leads with the brand mark rather than a Back link
292+
* into a workspace the visitor may not even be using.
293+
*/
294+
export const SETTINGS_PLANE_CHROME: Record<
295+
StandaloneSettingsPlane,
296+
{ label: string; showWordmark: boolean }
297+
> = {
298+
account: { label: 'Account', showWordmark: false },
299+
organization: { label: 'Organization', showWordmark: false },
300+
selfhost: { label: 'Self-host', showWordmark: true },
301+
}
302+
286303
export const SELFHOST_SETTINGS_GROUPS = [
287304
{ key: 'account', title: 'Account' },
288305
{ key: 'developer', title: 'Developer' },

apps/sim/components/settings/settings-sidebar.tsx

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22

33
import { useEffect, useRef, useState } from 'react'
44
import { ChipConfirmModal, chipVariants, cn, Tooltip } from '@sim/emcn'
5+
import { ChevronDown } from '@sim/emcn/icons'
56
import { useRouter } from 'next/navigation'
6-
import type { SettingsNavigationItem, SettingsSection } from '@/components/settings/navigation'
7+
import {
8+
SETTINGS_PLANE_CHROME,
9+
type SettingsNavigationItem,
10+
type SettingsSection,
11+
type StandaloneSettingsPlane,
12+
} from '@/components/settings/navigation'
713
import { SimWordmark } from '@/app/(landing)/components/navbar/components'
814
import { useSettingsDirtyStore } from '@/stores/settings/dirty/store'
915

@@ -13,6 +19,9 @@ import { useSettingsDirtyStore } from '@/stores/settings/dirty/store'
1319
*/
1420
const LANDING_HREF = '/?home'
1521

22+
/** Where the Back chip goes on planes that don't show the wordmark. */
23+
const WORKSPACE_HREF = '/workspace'
24+
1625
interface SettingsNavigationGroup {
1726
key: string
1827
title: string
@@ -25,6 +34,7 @@ interface SidebarSettingsItem<Section extends SettingsSection>
2534

2635
interface SettingsSidebarProps<Section extends SettingsSection> {
2736
activeSection: string
37+
plane: StandaloneSettingsPlane
2838
groups: readonly SettingsNavigationGroup[]
2939
hrefForSection: (section: Section) => string
3040
items: readonly SidebarSettingsItem<Section>[]
@@ -52,6 +62,7 @@ function SidebarTooltip({
5262

5363
export function SettingsSidebar<Section extends SettingsSection>({
5464
activeSection,
65+
plane,
5566
groups,
5667
hrefForSection,
5768
items,
@@ -86,15 +97,30 @@ export function SettingsSidebar<Section extends SettingsSection>({
8697
return (
8798
<>
8899
<div className='flex flex-shrink-0 flex-col gap-0.5 px-2 pb-1.5'>
89-
{/* Stays a button, not a Link: leaving settings must run the unsaved-changes guard. */}
90-
<button
91-
type='button'
92-
aria-label='Sim home'
93-
onClick={() => requestLeave(() => router.push(LANDING_HREF))}
94-
className='flex h-[30px] flex-shrink-0 items-center px-2 transition-opacity hover:opacity-70'
95-
>
96-
<SimWordmark />
97-
</button>
100+
{/* Both stay buttons, not Links: leaving settings must run the unsaved-changes guard. */}
101+
{SETTINGS_PLANE_CHROME[plane].showWordmark ? (
102+
<button
103+
type='button'
104+
aria-label='Sim home'
105+
onClick={() => requestLeave(() => router.push(LANDING_HREF))}
106+
className='flex h-[30px] flex-shrink-0 items-center px-2 transition-opacity hover:opacity-70'
107+
>
108+
<SimWordmark />
109+
</button>
110+
) : (
111+
<SidebarTooltip label='Back' enabled={showCollapsedTooltips}>
112+
<button
113+
type='button'
114+
onClick={() => requestLeave(() => router.push(WORKSPACE_HREF))}
115+
className={chipVariants({ fullWidth: true })}
116+
>
117+
<div className='flex size-[16px] flex-shrink-0 items-center justify-center text-[var(--text-icon)]'>
118+
<ChevronDown className='size-[10px] rotate-90' />
119+
</div>
120+
<span className='sidebar-collapse-hide truncate text-[var(--text-body)]'>Back</span>
121+
</button>
122+
</SidebarTooltip>
123+
)}
98124
</div>
99125

100126
<div

apps/sim/components/settings/standalone-settings-shell.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,14 @@ import {
1919
resolveOrganizationSectionAccess,
2020
SELFHOST_SETTINGS_GROUPS,
2121
SELFHOST_SETTINGS_ITEMS,
22+
SETTINGS_PLANE_CHROME,
2223
} from '@/components/settings/navigation'
2324
import { SettingsHeaderProvider, SettingsHeaderShell } from '@/components/settings/settings-header'
2425
import { SettingsSectionProvider } from '@/components/settings/settings-panel'
2526
import { SettingsSidebar } from '@/components/settings/settings-sidebar'
2627
import { useSettingsBeforeUnload } from '@/components/settings/use-settings-before-unload'
2728
import { isBillingEnabled } from '@/lib/core/config/env-flags'
2829

29-
const SHELL_PLANE_LABELS: Record<'account' | 'organization' | 'selfhost', string> = {
30-
account: 'Account',
31-
organization: 'Organization',
32-
selfhost: 'Self-host',
33-
}
34-
3530
interface StandaloneSettingsShellBaseProps {
3631
children: ReactNode
3732
}
@@ -109,20 +104,23 @@ export function StandaloneSettingsShell(props: StandaloneSettingsShellProps) {
109104
plane === 'selfhost' ? (
110105
<SettingsSidebar
111106
activeSection={selfHostSection}
107+
plane={plane}
112108
groups={SELFHOST_SETTINGS_GROUPS}
113109
hrefForSection={getSelfHostSettingsHref}
114110
items={selfHostItems}
115111
/>
116112
) : plane === 'account' ? (
117113
<SettingsSidebar
118114
activeSection={accountSection}
115+
plane={plane}
119116
groups={ACCOUNT_SETTINGS_GROUPS}
120117
hrefForSection={getAccountSettingsHref}
121118
items={accountItems}
122119
/>
123120
) : (
124121
<SettingsSidebar
125122
activeSection={organizationSection}
123+
plane={plane}
126124
groups={ORGANIZATION_SETTINGS_GROUPS}
127125
hrefForSection={(section) => getOrganizationSettingsHref(props.organizationId, section)}
128126
items={organizationItems}
@@ -134,7 +132,7 @@ export function StandaloneSettingsShell(props: StandaloneSettingsShellProps) {
134132
<div className='flex h-screen w-full overflow-hidden bg-[var(--surface-1)] p-2'>
135133
<aside
136134
className='mr-2 flex w-[248px] flex-shrink-0 flex-col rounded-[8px] border border-[var(--border)] bg-[var(--surface-1)] pt-3'
137-
aria-label={`${SHELL_PLANE_LABELS[plane]} settings navigation`}
135+
aria-label={`${SETTINGS_PLANE_CHROME[plane].label} settings navigation`}
138136
>
139137
{sidebar}
140138
</aside>

0 commit comments

Comments
 (0)