Fix navbar highlight for Organized Content sections #182

Merged
a258wang merged 10 commits from amy-navbar-highlight-fix into main 2021-08-31 23:07:21 -04:00
Owner

Also fixes the navbar highlight for the different Advice sections.

Closes #181

Also fixes the navbar highlight for the different Advice sections. Closes #181
a258wang added 1 commit 2021-08-26 16:26:21 -04:00
continuous-integration/drone/push Build is passing Details
db9f5f1c5c
Fix navbar highlight for pages with Organized Content
a3thakra reviewed 2021-08-27 14:49:31 -04:00
@ -201,7 +211,8 @@ function NavItem(props: NavItemProps) {
const isCurrentPage =
router.pathname === props.route ||
(props.submenu != null &&
router.pathname.startsWith(getMainRoute(props.route)));
Owner

What if we do:

const isCurrentPage =
    router.pathname === props.route ||
    (router.pathname !== "/" &&
      router.pathname.startsWith(getMainRoute(props.route)));
What if we do: ```ts const isCurrentPage = router.pathname === props.route || (router.pathname !== "/" && router.pathname.startsWith(getMainRoute(props.route))); ```
Author
Owner

That doesn't work because whenever we navigate to anything in the About submenu, all of the other entries in the submenu will also be highlighted blue. (Same for the Resources submenu.)

That doesn't work because whenever we navigate to anything in the About submenu, all of the other entries in the submenu will also be highlighted blue. (Same for the Resources submenu.)
a3thakra marked this conversation as resolved
a258wang added 4 commits 2021-08-28 18:22:28 -04:00
Author
Owner

Side note: I ended up keeping the About Us page at /about because I was able to make it work, but let me know if we'd prefer to move it to /about/us. :)

Side note: I ended up keeping the About Us page at `/about` because I was able to make it work, but let me know if we'd prefer to move it to `/about/us`. :)
a3thakra reviewed 2021-08-28 22:02:22 -04:00
@ -190,3 +205,4 @@
submenu?: {
name: string;
route: string;
hasSubsections?: boolean;
Owner

We don't need this anymore, correct?

We don't need this anymore, correct?
Author
Owner

Oops yes sorry, I'll get rid of it! I had to do some mergey stuff and I must've forgotten to delete this line lol

Oops yes sorry, I'll get rid of it! I had to do some mergey stuff and I must've forgotten to delete this line lol
a3thakra marked this conversation as resolved
a258wang added 2 commits 2021-08-28 22:56:08 -04:00
a3thakra reviewed 2021-08-29 21:33:30 -04:00
@ -276,0 +295,4 @@
ancestors: { name: string; route: string }[];
}[];
function dfs(
Owner

I think this function should be called something like collectLeaves

I think this function should be called something like `collectLeaves`
Owner

Let's make the signature of this function similar to what reduce takes in. Then we could do

const leaves = menu.reduce(collectLeaves, [] as Leaves)

(or something like this)

Let's make the signature of this function similar to what reduce takes in. Then we could do ```ts const leaves = menu.reduce(collectLeaves, [] as Leaves) ``` (or something like this)
a3thakra reviewed 2021-08-29 21:40:21 -04:00
@ -276,0 +304,4 @@
}
let ret = [] as Leaves;
for (const subEntry of entry.submenu) {
ret = ret.concat(dfs(subEntry, [...ancestors, entry]));
Owner

You can use push

ret.push(...dfs(subEntry, [...ancestors, entry]));

You can use `push` `ret.push(...dfs(subEntry, [...ancestors, entry]));`
Owner

Just some nitpicks, looks good otherwise! :)

Just some nitpicks, looks good otherwise! :)
a258wang added 2 commits 2021-08-30 23:28:43 -04:00
a258wang added 1 commit 2021-08-30 23:30:26 -04:00
continuous-integration/drone/push Build is passing Details
8f5418c312
Merge branch 'main' into amy-navbar-highlight-fix
a3thakra approved these changes 2021-08-31 21:53:10 -04:00
a258wang merged commit 0bb8049db3 into main 2021-08-31 23:07:21 -04:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: www/www-new#182
No description provided.