Skip to content

Commit 00c708d

Browse files
1.5 Styles JSX
1 parent a676468 commit 00c708d

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

components/NavBar.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
import Link from "next/link";
22
import { useRouter } from "next/router";
3-
import styles from "./NavBar.module.css";
43

54
export default function NavBar() {
65
const router = useRouter();
76
return (
87
<nav>
98
<Link href="/">
10-
<a
11-
className={`${styles.link} ${
12-
router.pathname === "/" ? styles.active : ""
13-
}`}
14-
>
15-
Home
16-
</a>
9+
<a className={router.pathname === "/" ? "active" : ""}>Home</a>
1710
</Link>
1811
<Link href="/about">
19-
<a
20-
className={[
21-
styles.link,
22-
router.pathname === "/about" ? styles.active : "",
23-
].join(" ")}
24-
>
25-
About
26-
</a>
12+
<a className={router.pathname === "/about" ? "active" : ""}>About</a>
2713
</Link>
14+
<style jsx>{`
15+
nav {
16+
background-color: tomato;
17+
}
18+
a {
19+
text-decoration: none;
20+
}
21+
.active {
22+
color: yellow;
23+
}
24+
`}</style>
2825
</nav>
2926
);
3027
}

components/NavBar.module.css

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

pages/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ export default function Home() {
44
return (
55
<div>
66
<NavBar />
7-
<h1>Hello</h1>
7+
<h1 className="active">Hello</h1>
8+
<style jsx>{`
9+
a {
10+
color: white;
11+
}
12+
`}</style>
813
</div>
914
);
1015
}

0 commit comments

Comments
 (0)