Skip to content

Commit a160d5f

Browse files
committed
Show selected page on left navigation.
1 parent 2c475fd commit a160d5f

File tree

4 files changed

+35
-17
lines changed

4 files changed

+35
-17
lines changed

frontend/app/routes/_index/components/left-navigation/left-navigation.module.css

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,20 @@
2525
color: inherit;
2626
}
2727

28-
@media not (pointer: coarse), (min-width: 900px) {
29-
.item:hover {
30-
background-color: #002b36;
28+
@media not (pointer: coarse), (min-width: 900px) {
29+
.item:not(.selected):hover {
30+
background-color: hsl(192, 100%, 8%);
3131
cursor: pointer;
3232
}
3333
}
3434

35-
.item:active {
36-
background-color: #073642;
35+
.item:not(.selected):active {
36+
background-color: hsl(192, 80%, 14%);
37+
}
38+
39+
.selected {
40+
background-color: hsl(192, 100%, 11%);
41+
user-select: none;
3742
}
3843

3944
.queue-icon {

frontend/app/routes/_index/components/left-navigation/left-navigation.module.css.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ declare const styles: {
1212
readonly "stream-icon": string;
1313
readonly "title": string;
1414
readonly "unstyled": string;
15+
readonly "selected": string;
1516
};
1617
export = styles;
1718

frontend/app/routes/_index/components/left-navigation/left-navigation.tsx

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
import { Form, Link } from "react-router";
1+
import { Form, Link, useLocation, useNavigation } from "react-router";
22
import styles from "./left-navigation.module.css";
3+
import { className } from "~/utils/styling";
4+
import type React from "react";
35

4-
export type LefNavigationProps = {
5-
}
6-
7-
8-
export function LeftNavigation(props: LefNavigationProps) {
6+
export function LeftNavigation() {
97
return (
108
<div className={styles.container}>
11-
<Link className={styles.item} to={"/queue"}>
9+
<Item target="/queue">
1210
<div className={styles["queue-icon"]} />
1311
<div className={styles.title}>Queue & History</div>
14-
</Link>
15-
<Link className={styles.item} to={"/explore"}>
12+
</Item>
13+
<Item target="/explore">
1614
<div className={styles["explore-icon"]} />
1715
<div className={styles.title}>Dav Explore</div>
18-
</Link>
19-
<Link className={styles.item} to={"/settings"}>
16+
</Item>
17+
<Item target="/settings">
2018
<div className={styles["settings-icon"]} />
2119
<div className={styles.title}>Settings</div>
22-
</Link>
20+
</Item>
2321

2422
<div className={styles.footer}>
2523
<div className={styles["footer-item"]}>
@@ -45,4 +43,17 @@ export function LeftNavigation(props: LefNavigationProps) {
4543
</div>
4644
</div>
4745
);
46+
}
47+
48+
function Item({ target, children }: { target: string, children: React.ReactNode }) {
49+
const location = useLocation();
50+
const navigation = useNavigation();
51+
const pathname = navigation.location?.pathname ?? location.pathname;
52+
const isSelected = pathname.startsWith(target);
53+
const classes = [styles.item, isSelected ? styles.selected : null];
54+
return <>
55+
<Link {...className(classes)} to={target}>
56+
{children}
57+
</Link>
58+
</>;
4859
}

frontend/app/routes/_index/components/top-navigation/top-navigation.module.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
}
2727

2828
.logo {
29+
width: 26.23px;
2930
height: 30px;
3031
margin: auto;
3132
}

0 commit comments

Comments
 (0)