Skip to content

Commit cbdcb00

Browse files
committed
feat(web): add interactive compact sidebar setting preview
1 parent 22af646 commit cbdcb00

3 files changed

Lines changed: 71 additions & 12 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { useState } from "react";
2+
3+
import { cn } from "~/lib/utils";
4+
5+
export function CompactSidebarPreview() {
6+
const [collapsed, setCollapsed] = useState(false);
7+
8+
return (
9+
<button
10+
type="button"
11+
aria-label="Toggle compact sidebar preview"
12+
aria-pressed={collapsed}
13+
className="group/compact-preview relative flex h-10 w-full cursor-pointer overflow-hidden rounded-lg border border-border bg-background p-1 shadow-xs/5 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"
14+
onClick={() => setCollapsed((value) => !value)}
15+
>
16+
<span
17+
aria-hidden
18+
className={cn(
19+
"flex h-full shrink-0 flex-col justify-center gap-1 overflow-hidden rounded-md bg-sidebar px-1 transition-[width] duration-250 ease-out motion-reduce:transition-none",
20+
collapsed ? "w-3" : "w-9",
21+
)}
22+
>
23+
{[0, 1, 2].map((row) => (
24+
<span key={row} className="flex h-1 shrink-0 items-center gap-1">
25+
<span className="size-1 shrink-0 rounded-[1px] bg-muted-foreground/50" />
26+
<span
27+
className={cn(
28+
"h-0.5 w-4 shrink-0 rounded-full bg-muted-foreground/25 transition-opacity duration-250 ease-out motion-reduce:transition-none",
29+
collapsed && "opacity-0",
30+
)}
31+
/>
32+
</span>
33+
))}
34+
</span>
35+
<span aria-hidden className="flex min-w-0 flex-1 flex-col gap-1 px-1 pt-1">
36+
<span className="h-0.5 w-full rounded-full bg-muted-foreground/25" />
37+
<span className="h-0.5 w-4/5 rounded-full bg-muted-foreground/20" />
38+
<span className="h-0.5 w-3/5 rounded-full bg-muted-foreground/15" />
39+
</span>
40+
<span
41+
aria-hidden
42+
className={cn(
43+
"pointer-events-none absolute top-3 left-5 flex w-9 flex-col gap-1 rounded-sm border border-border bg-popover p-1 opacity-0 shadow-xs transition-opacity duration-150 ease-out motion-reduce:transition-none",
44+
collapsed &&
45+
"group-hover/compact-preview:opacity-100 group-focus-visible/compact-preview:opacity-100",
46+
)}
47+
>
48+
<span className="h-0.5 w-full rounded-full bg-popover-foreground/45" />
49+
<span className="h-0.5 w-2/3 rounded-full bg-popover-foreground/25" />
50+
</span>
51+
</button>
52+
);
53+
}

‎apps/web/src/components/settings/SettingsPanels.tsx‎

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ import {
160160
import { searchableSetting } from "./settingsSearch";
161161
import { ProjectFavicon } from "../ProjectFavicon";
162162
import { PanelAnimationsPreview } from "./PanelAnimationsPreview";
163+
import { CompactSidebarPreview } from "./CompactSidebarPreview";
163164

164165
const ENVIRONMENT_IDENTIFICATION_LABELS: Record<EnvironmentIdentificationMode, string> = {
165166
artwork: "Artwork",
@@ -1361,23 +1362,28 @@ export function AppearanceSettingsPanel() {
13611362
/>
13621363
</SettingsSection>
13631364

1364-
<TypographySection />
1365-
1366-
<SettingsSection id="appearance-advanced" title="Advanced">
1365+
<SettingsSection id="appearance-sidebar" title="Sidebar">
13671366
<SettingsRow
13681367
{...searchableSetting("compact-sidebar")}
1369-
description="Keep an icon rail when the sidebar is collapsed."
1368+
description="Keep an icon rail when the sidebar is collapsed. Click the preview to try it."
13701369
control={
1371-
<Switch
1372-
checked={settings.compactSidebarEnabled}
1373-
onCheckedChange={(checked) =>
1374-
updateSettings({ compactSidebarEnabled: Boolean(checked) })
1375-
}
1376-
aria-label="Compact sidebar"
1377-
/>
1370+
<div className="grid w-full grid-cols-[5rem_minmax(0,1fr)] items-center gap-3 sm:w-auto sm:grid-cols-[7rem_13rem] sm:gap-4">
1371+
<CompactSidebarPreview />
1372+
<div className="flex justify-end">
1373+
<Switch
1374+
checked={settings.compactSidebarEnabled}
1375+
onCheckedChange={(checked) =>
1376+
updateSettings({ compactSidebarEnabled: Boolean(checked) })
1377+
}
1378+
aria-label="Compact sidebar"
1379+
/>
1380+
</div>
1381+
</div>
13781382
}
13791383
/>
13801384
</SettingsSection>
1385+
1386+
<TypographySection />
13811387
</SettingsPageContainer>
13821388
);
13831389
}

‎apps/web/src/components/settings/settingsSearch.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export const SETTINGS_SEARCH_ITEMS = [
163163
id: "compact-sidebar",
164164
title: "Compact sidebar",
165165
to: "/settings/appearance",
166-
searchTerms: ["advanced collapsed icons rail hover navigation"],
166+
searchTerms: ["collapsed icons rail hover navigation preview"],
167167
},
168168
{
169169
id: "environment-identification",

0 commit comments

Comments
 (0)