Skip to content

Commit c707be2

Browse files
committed
feat: stop using a hamburger menu on mobile, use a CSS Grid powered sub-nav
1 parent 8ab9de5 commit c707be2

File tree

6 files changed

+50
-158
lines changed

6 files changed

+50
-158
lines changed

.notes/todo.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
- [ ] Fix janky width changing when scrollbar shows or hides, again. now it's on smaller screens?
2424
- [ ] more accessible focus states
2525
- [ ] new icon. dark mode icon would be sick whilst I'm at it.
26-
- [ ] selecting a menu option in mobile menu should close that menu
27-
- [ ] mobile menu should disable scroll
28-
- [ ] fix navbar appearance & alignment in mobile menu- mobile menu options should be left-aligned with navbar
29-
- [ ] navbar also aligns jankily with Home and Blog, and shifts jankily when scrollbar is present. maybe a bigger fix needed
3026
- [ ] styling
3127
- [ ] find a more ergonomic solution for light/dark/system mode
3228
- [ ] stop using global transition variables, and standardize transitions more generally
@@ -35,7 +31,7 @@
3531
- [ ] obliterate `pageStyles` directory
3632
- [ ] restyle so all pages can share `.centeringWrapper` etc. and Navbar can be pulled into the main layout
3733
- [ ] could then expand the use of grid from something that lives inside the blog post, to something used globally
38-
- [ ] that'd also let me make footer spacing really consistent, by defining it on the main wrapepr
34+
- [ ] that'd also let me make footer spacing really consistent, by defining it on the main wrapper
3935
- [ ] make a better README
4036
- [ ] get rid of ugly typecasts and disorganized logic in the metadata helpers
4137
- [ ] stop using Adobe fonts so I can host locally and preload. go directly through Canada Type

src/app/_components/DarkModeToggle.css.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import {
88
} from "#viriditas/theme/theme.css"
99

1010
export const root = style({
11+
position: "relative",
12+
top: -1, // for visual centering with the display font
13+
1114
selectors: {
1215
// One can only toggle the color mode when JS is active to control the color mode.
1316
// If the default `SYSTEM_COLOR_MODE_CLASS` is still set, then we can't control the color mode.

src/app/_components/MobileMenu.css.ts

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/app/_components/MobileMenu.tsx

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/app/_components/Navbar.css.ts

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,15 @@ import { style } from "@vanilla-extract/css"
22

33
import { breakpoints, tokens } from "#viriditas/theme/theme.css"
44

5-
export const interactionHover = style({
6-
opacity: 0.5,
7-
transition: "opacity 0.3s ease",
8-
9-
":hover": {
10-
opacity: 1,
11-
},
12-
})
13-
14-
export const iconButton = style([
15-
interactionHover,
16-
{
17-
alignItems: "center",
18-
borderRadius: "5px",
19-
display: "flex",
20-
height: "25px",
21-
justifyContent: "center",
22-
position: "relative",
23-
width: "40px",
24-
},
25-
])
26-
275
export const root = style({
28-
display: "flex",
29-
height: "40px",
6+
alignItems: "center",
7+
display: "grid",
8+
gridTemplateColumns: "min-content 1fr min-content",
9+
gridTemplateRows: "auto",
10+
gridTemplateAreas: `
11+
"logo controls right-button"
12+
"sub-nav sub-nav sub-nav"
13+
`,
3014
justifyContent: "space-between",
3115
marginTop: "100px",
3216
maxWidth: "1440px",
@@ -48,9 +32,33 @@ export const root = style({
4832
},
4933
})
5034

35+
export const interactionHover = style({
36+
opacity: 0.5,
37+
transition: "opacity 0.3s ease",
38+
39+
":hover": {
40+
opacity: 1,
41+
},
42+
})
43+
44+
export const iconButton = style([
45+
interactionHover,
46+
{
47+
alignItems: "center",
48+
borderRadius: "5px",
49+
display: "flex",
50+
gridArea: "right-button",
51+
height: "25px",
52+
justifyContent: "center",
53+
position: "relative",
54+
width: "40px",
55+
},
56+
])
57+
5158
export const logoLink = style({
5259
color: tokens.color.primary,
5360
fontSize: "27px",
61+
gridArea: "logo",
5462
transition: "color 0.3s ease",
5563

5664
":hover": {
@@ -59,13 +67,18 @@ export const logoLink = style({
5967
})
6068

6169
export const controls = style({
70+
// By default, the control are in the top row, between the logo and dark mode toggle.
6271
alignItems: "center",
6372
display: "flex",
73+
gridArea: "controls",
74+
justifyContent: "flex-end",
6475
position: "relative",
6576

6677
"@media": {
6778
[breakpoints.tablet]: {
68-
display: "none",
79+
// On small screens, the controls go in a second row.
80+
gridArea: "sub-nav",
81+
justifyContent: "flex-start",
6982
},
7083
},
7184
})
@@ -82,5 +95,11 @@ export const link = style([
8295
{
8396
color: tokens.color.primary,
8497
fontSize: "27px",
98+
99+
"@media": {
100+
[breakpoints.tablet]: {
101+
fontSize: "18px",
102+
},
103+
},
85104
},
86105
])

src/app/_components/Navbar.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import Link from "next/link"
22

33
import { centeringWrapper } from "#pageStyles/main.css"
44
import { DarkModeToggle } from "./DarkModeToggle"
5-
import { MobileMenu } from "./MobileMenu"
6-
import { logoLink, root, controls, linkList, link } from "./Navbar.css"
5+
import { controls, link, linkList, logoLink, root } from "./Navbar.css"
76

87
export function Navbar() {
98
return (
@@ -31,10 +30,9 @@ export function Navbar() {
3130
</Link>
3231
</li>
3332
</ul>
34-
<DarkModeToggle />
3533
</div>
3634

37-
<MobileMenu />
35+
<DarkModeToggle />
3836
</nav>
3937
</div>
4038
)

0 commit comments

Comments
 (0)