Skip to content

Commit 8905ee6

Browse files
authored
Merge pull request #6 from leahbrenny/darkmode
Darkmode
2 parents 04101dc + 24d82d9 commit 8905ee6

File tree

8 files changed

+130
-7
lines changed

8 files changed

+130
-7
lines changed

components/bluesky.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default function BlueskyLogo() {
44
xmlns="http://www.w3.org/2000/svg"
55
viewBox="0 -3.268 64 68.414"
66
width="38"
7-
height="auto"
7+
height="100%"
88
>
99
<path
1010
fill="var(--footer-icons)"

components/footer.js

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Gh from "./github";
33
import Tw from "./twitter";
44
import Li from "./linkedin";
55
import Bs from "./bluesky";
6+
import ThemeIcons from "./themeicons";
67

78
export default function Footer({ twitter, linkedin, github, bluesky }) {
89
return (
@@ -47,6 +48,9 @@ export default function Footer({ twitter, linkedin, github, bluesky }) {
4748
</div>
4849
</li>
4950
</ul>
51+
<div className="theme-icons">
52+
<ThemeIcons />
53+
</div>
5054
</footer>
5155
);
5256
}

components/themeicons.js

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"use client";
2+
3+
import { useEffect, useState } from "react";
4+
5+
export default function ThemeIcons() {
6+
const [theme, setTheme] = useState("light");
7+
8+
useEffect(() => {
9+
const storedTheme = localStorage.getItem("theme");
10+
const prefersDark = window.matchMedia(
11+
"(prefers-color-scheme: dark)"
12+
).matches;
13+
setTheme(storedTheme || (prefersDark ? "dark" : "light"));
14+
}, []);
15+
16+
useEffect(() => {
17+
document.documentElement.setAttribute("data-theme", theme);
18+
localStorage.setItem("theme", theme);
19+
}, [theme]);
20+
21+
const toggleTheme = () => {
22+
setTheme((prevTheme) => (prevTheme === "light" ? "dark" : "light"));
23+
};
24+
25+
return (
26+
<button
27+
onClick={toggleTheme}
28+
aria-label={`Activate ${theme === "light" ? "dark" : "light"} mode`}
29+
title={`Activate ${theme === "light" ? "dark" : "light"} mode`}
30+
className="theme-toggle"
31+
>
32+
{theme === "light" ? (
33+
<svg
34+
xmlns="http://www.w3.org/2000/svg"
35+
width="36px"
36+
height="100%"
37+
viewBox="0 -960 960 960"
38+
fill="var(--text-footer)"
39+
role="img"
40+
>
41+
<title>Dark Mode Icon</title>
42+
<path d="M480-120q-150 0-255-105T120-480q0-150 105-255t255-105q14 0 27.5 1t26.5 3q-41 29-65.5 75.5T444-660q0 90 63 153t153 63q55 0 101-24.5t75-65.5q2 13 3 26.5t1 27.5q0 150-105 255T480-120Zm0-80q88 0 158-48.5T740-375q-20 5-40 8t-40 3q-123 0-209.5-86.5T364-660q0-20 3-40t8-40q-78 32-126.5 102T200-480q0 116 82 198t198 82Z" />
43+
</svg>
44+
) : (
45+
<svg
46+
xmlns="http://www.w3.org/2000/svg"
47+
width="36px"
48+
height="100%"
49+
viewBox="0 -960 960 960"
50+
fill="var(--text-footer)"
51+
role="img"
52+
>
53+
<title>Light Mode Icon</title>
54+
<path d="M480-360q50 0 85-35t35-85q0-50-35-85t-85-35q-50 0-85 35t-35 85q0 50 35 85t85 35Zm0 80q-83 0-141.5-58.5T280-480q0-83 58.5-141.5T480-680q83 0 141.5 58.5T680-480q0 83-58.5 141.5T480-280ZM200-440H40v-80h160v80Zm720 0H760v-80h160v80ZM440-760v-160h80v160h-80Zm0 720v-160h80v160h-80ZM256-650l-101-97 57-59 96 100-52 56Zm492 496-97-101 53-55 101 97-57 59Zm-98-550 97-101 59 57-100 96-56-52ZM154-212l101-97 55 53-97 101-59-57Z" />
55+
</svg>
56+
)}
57+
</button>
58+
);
59+
}

components/twitter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default function Twitter() {
22
return (
33
<svg
44
fill="none"
5-
height="auto"
5+
height="100%"
66
width="32"
77
xmlns="http://www.w3.org/2000/svg"
88
viewBox="0.254 0.25 500 451.95400000000006"

lessons/01-the-first-section/A-intro.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ keywords:
1010

1111
Hello! And welcome to the Next.js course starter by [Brian Holt][twitter].
1212

13-
![Cat, dog, and rat logo for the course](./images/BRAND-WHearts.png)
13+
![Cat, dog, and rat logo for the course](/next-course-starter/images/BRAND-WHearts.png)
1414

1515
This is a course starter specifically made for making online courses and optimized for use with [Frontend Masters][fem].
1616

styles/courses.css

+5-2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ a {
7373
flex-direction: row;
7474
align-items: center;
7575
justify-content: center;
76+
color: var(--lesson-text);
7677
}
7778

7879
header .cta-btn {
@@ -287,7 +288,7 @@ header .cta-btn {
287288
}
288289

289290
.lesson-content td {
290-
border: 1px solid black;
291+
border: 1px solid var(--lesson-text);
291292
padding: 8px;
292293
}
293294

@@ -354,12 +355,13 @@ blockquote > *:last-child {
354355

355356
.lesson-content {
356357
line-height: 1.5;
358+
color: var(--lesson-text);
357359
}
358360

359361
.lesson-text {
360362
width: 100%;
361363
padding: 25px 5px 25px 35px;
362-
min-height: 200px;
364+
min-height: 200px
363365
}
364366

365367
.sections-name {
@@ -507,6 +509,7 @@ ol.sections-name .lesson-details {
507509
.cta-btn:hover,
508510
.lesson-links a:hover {
509511
background: #152837;
512+
color: var(--nav-buttons-text-hover);
510513
text-decoration: none;
511514
}
512515

styles/footer.css

+11-2
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,19 @@
4545
text-decoration: underline;
4646
}
4747

48-
.social svg {
48+
.social svg, .theme-icons svg {
4949
transition: opacity 0.25s;
5050
}
5151

52-
.social svg:hover {
52+
.social svg:hover, .theme-icons svg:hover {
5353
opacity: 0.4;
5454
}
55+
56+
.theme-toggle {
57+
background: none;
58+
border: none;
59+
padding: 0;
60+
cursor: pointer;
61+
display: inline-flex;
62+
align-items: center;
63+
}

styles/variables.css

+48
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
--secondary: #93aca7;
44
--highlight: #224159;
55

6+
--lesson-text: rgb(8, 8, 8);
7+
68
--text-header: var(--primary);
79
--text-main-headers: var(--highlight);
810
--text-links: #007bff;
@@ -14,6 +16,7 @@
1416

1517
--nav-buttons: var(--highlight);
1618
--nav-buttons-text: white;
19+
--nav-buttons-text-hover: white;
1720

1821
--corner-active: var(--highlight);
1922
--corner-inactive: #f4f4f4;
@@ -23,3 +26,48 @@
2326
--emphasized-bg: #dce8ff;
2427
--emphasized-border: #aab6d2;
2528
}
29+
30+
[data-theme="dark"] {
31+
--primary: #224159;
32+
--secondary: #93aca7;
33+
--highlight: #dfa067;
34+
35+
--text-header: var(--primary);
36+
--text-main-headers: var(--highlight);
37+
--text-links: #ff6f00;
38+
--text-footer: var(--highlight);
39+
40+
--lesson-text: rgb(218, 218, 218);
41+
42+
--bg-main: #1f1f1f;
43+
--bg-dots: var(--highlight);
44+
--bg-lesson: #323232;
45+
--nav-buttons: var(--highlight);
46+
--nav-buttons-text: var(--primary);
47+
--nav-buttons-text-hover: var(--highlight);
48+
49+
--corner-active: var(--highlight);
50+
--corner-inactive: #2a2a2a;
51+
--icons: var(--primary);
52+
--footer-icons: var(--highlight);
53+
54+
--emphasized-bg: #dce8ff;
55+
--emphasized-border: #5a6c89;
56+
}
57+
58+
.lesson-title {
59+
color: var(--highlight);
60+
}
61+
62+
.lesson-section-title {
63+
color: var(--primary);
64+
}
65+
66+
.terms {
67+
color: var(--highlight);
68+
}
69+
70+
li {
71+
color: var(--highlight);
72+
}
73+

0 commit comments

Comments
 (0)