Skip to content

Commit 244cc2e

Browse files
committed
Move the new note button
1 parent 6763296 commit 244cc2e

File tree

2 files changed

+54
-38
lines changed

2 files changed

+54
-38
lines changed

src/components/app-header.tsx

+32-36
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,37 @@ export function AppHeader({ title, icon, className, actions }: AppHeaderProps) {
4444
<header className="flex h-10 items-center gap-2 px-2 coarse:h-14">
4545
<div className="hidden items-center empty:hidden sm:flex">
4646
{sidebar === "collapsed" ? (
47-
<IconButton
48-
aria-label="Expand sidebar"
49-
size="small"
50-
onClick={() => setSidebar("expanded")}
51-
>
52-
<SidebarIcon16 />
53-
</IconButton>
47+
<>
48+
<IconButton
49+
aria-label="Expand sidebar"
50+
size="small"
51+
onClick={() => setSidebar("expanded")}
52+
>
53+
<SidebarIcon16 />
54+
</IconButton>
55+
<IconButton
56+
aria-label="New note"
57+
shortcut={["⌘", "⇧", "O"]}
58+
size="small"
59+
onClick={() => {
60+
navigate({
61+
to: "/notes/$",
62+
params: { _splat: `${Date.now()}` },
63+
search: {
64+
mode: "write",
65+
query: undefined,
66+
view: "grid",
67+
},
68+
})
69+
}}
70+
>
71+
<PlusIcon16 />
72+
</IconButton>
73+
<div
74+
role="separator"
75+
className={cx("mx-2 hidden h-5 w-px bg-border-secondary sm:block")}
76+
/>
77+
</>
5478
) : null}
5579
<IconButton
5680
aria-label="Go back"
@@ -78,35 +102,7 @@ export function AppHeader({ title, icon, className, actions }: AppHeaderProps) {
78102
<div className="truncate font-content font-bold">{title}</div>
79103
</div>
80104
<div className="flex items-center gap-2 justify-self-end">
81-
{actions ? (
82-
<>
83-
<div className="flex items-center">{actions}</div>
84-
<div
85-
role="separator"
86-
className={cx("hidden h-5 w-px bg-border-secondary sm:block")}
87-
/>
88-
</>
89-
) : null}
90-
<div className="hidden items-center sm:flex">
91-
<IconButton
92-
aria-label="New note"
93-
shortcut={["⌘", "⇧", "O"]}
94-
size="small"
95-
onClick={() => {
96-
navigate({
97-
to: "/notes/$",
98-
params: { _splat: `${Date.now()}` },
99-
search: {
100-
mode: "write",
101-
query: undefined,
102-
view: "grid",
103-
},
104-
})
105-
}}
106-
>
107-
<PlusIcon16 />
108-
</IconButton>
109-
</div>
105+
{actions ? <div className="flex items-center">{actions}</div> : null}
110106
</div>
111107
</header>
112108
</div>

src/components/sidebar.tsx

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1+
import { useNavigate } from "@tanstack/react-router"
12
import { useSetAtom } from "jotai"
23
import { sidebarAtom } from "../global-state"
34
import { useIsScrolled } from "../hooks/is-scrolled"
45
import { cx } from "../utils/cx"
56
import { IconButton } from "./icon-button"
6-
import { SidebarFillIcon16 } from "./icons"
7+
import { PlusIcon16, SidebarFillIcon16 } from "./icons"
78
import { NavItems } from "./nav-items"
89

910
export function Sidebar() {
1011
const setSidebar = useSetAtom(sidebarAtom)
12+
const navigate = useNavigate()
1113

1214
const { isScrolled, topSentinelProps } = useIsScrolled()
1315

1416
return (
1517
<div className="grid w-56 flex-shrink-0 grid-rows-[auto_1fr] overflow-hidden border-r border-border-secondary">
1618
<div
1719
className={cx(
18-
"flex w-full border-b p-2",
20+
"flex w-full justify-between border-b p-2",
1921
isScrolled ? "border-border-secondary" : "border-transparent",
2022
)}
2123
>
@@ -27,6 +29,24 @@ export function Sidebar() {
2729
>
2830
<SidebarFillIcon16 />
2931
</IconButton>
32+
<IconButton
33+
aria-label="New note"
34+
shortcut={["⌘", "⇧", "O"]}
35+
size="small"
36+
onClick={() => {
37+
navigate({
38+
to: "/notes/$",
39+
params: { _splat: `${Date.now()}` },
40+
search: {
41+
mode: "write",
42+
query: undefined,
43+
view: "grid",
44+
},
45+
})
46+
}}
47+
>
48+
<PlusIcon16 />
49+
</IconButton>
3050
</div>
3151
<div className="relative flex scroll-py-2 flex-col gap-2 overflow-auto p-2 pt-0">
3252
<div {...topSentinelProps} />

0 commit comments

Comments
 (0)