Skip to content
Source
Sign inSign up
fuko/trytanstackdb-v2
Open History to see the last commit

notes-app.tsx

29 lines863 Bytes

1import type { ReactNode } from "react";
2​
3import { MacSidebar } from "./mac/sidebar";
4import { NotesLayoutProvider, useNotesLayout } from "./notes-layout";
5​
6/**
7 * Root of the Notes clone. On macOS the sidebar stays mounted while routes
8 * swap the columns next to it; on iPhone each route is a full screen.
9 */
10export function NotesApp({ children }: { children: ReactNode }) {
11 return (
12 <NotesLayoutProvider>
13 <NotesAppFrame>{children}</NotesAppFrame>
14 </NotesLayoutProvider>
15 );
17​
18function NotesAppFrame({ children }: { children: ReactNode }) {
19 const { layout, sidebarVisible } = useNotesLayout();
20​
21 if (layout === "ios") return <div className="h-full">{children}</div>;
22​
23 return (
24 <div className="flex h-full bg-mac-content font-sans text-mac-text antialiased">
25 {sidebarVisible && <MacSidebar />}
26 {children}
27 </div>
28 );