Skip to content

Commit 4ea6c5d

Browse files
committed
feat(mobile): improve sidebar experience in mobile
1 parent 528e102 commit 4ea6c5d

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

dev-utility-tauri/tauri.conf.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"titleBarStyle": "Overlay",
1818
"width": 1200,
1919
"height": 800,
20+
"minWidth": 375,
21+
"minHeight": 800,
2022
"transparent": true,
2123
"trafficLightPosition": {
2224
"x": 18,

packages/frontend/src/components/sidebar/index.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import { SearchForm } from "./search-form";
5858
import { ThemeSwitcher } from "./theme-switcher";
5959

6060
const InsetHeader: React.FC<{ title: string }> = ({ title }) => {
61-
const { open } = useSidebar();
61+
const { open, isMobile } = useSidebar();
6262

6363
const setOnTop = async () => {
6464
await getCurrentWindow().setAlwaysOnTop(!isOnTop);
@@ -71,7 +71,9 @@ const InsetHeader: React.FC<{ title: string }> = ({ title }) => {
7171
data-tauri-drag-region
7272
className="flex h-9 shrink-0 items-center gap-2 px-4"
7373
>
74-
<SidebarTrigger className={cn("-ml-1", !open && "ml-16")} />
74+
<SidebarTrigger
75+
className={cn("-ml-1", !open && "ml-16", isMobile && "ml-16")}
76+
/>
7577
<Separator
7678
orientation="vertical"
7779
className="mr-2 data-[orientation=vertical]:h-4"
@@ -94,6 +96,23 @@ const InsetHeader: React.FC<{ title: string }> = ({ title }) => {
9496
);
9597
};
9698

99+
const InsetContent: React.FC<{ children: React.ReactNode }> = ({
100+
children,
101+
}) => {
102+
const { isMobile } = useSidebar();
103+
104+
return (
105+
<SidebarInset
106+
className={cn(
107+
"bg-background rounded-lg m-2 overflow-hidden",
108+
isMobile && "m-0",
109+
)}
110+
>
111+
{children}
112+
</SidebarInset>
113+
);
114+
};
115+
97116
export default function AppSidebar({
98117
children,
99118
...props
@@ -241,12 +260,12 @@ export default function AppSidebar({
241260
</SidebarFooter>
242261
<SidebarRail />
243262
</Sidebar>
244-
<SidebarInset className="bg-background rounded-lg m-2 overflow-hidden">
263+
<InsetContent>
245264
<InsetHeader title={title} />
246265
<main className="@container/main flex-1 max-h-[calc(100vh-3rem)] px-4 pb-2 overflow-hidden">
247266
{children}
248267
</main>
249-
</SidebarInset>
268+
</InsetContent>
250269
</SidebarProvider>
251270
);
252271
}

0 commit comments

Comments
 (0)