Skip to content

Added Dark Mode Feature to thecodingtrain Website #1554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 48 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
985fe36
feat: :heavy_plus_sign: Add Theme component to Layout.js and Dark Mod…
Yashasewi Apr 13, 2024
99e7212
feat: :wrench: Created the theme component
Yashasewi Apr 13, 2024
c26378d
Merge branch 'CodingTrain:main' into feature-Dark-mode
Yashasewi Apr 13, 2024
61ca5a2
style: :art: fixed text colour and background colour in the guides page
Yashasewi Apr 13, 2024
a5dacba
style: :lipstick: added background color to the whole site
Yashasewi Apr 13, 2024
d176de0
style: :lipstick: Foxed background and text colors in CSS files of sh…
Yashasewi Apr 13, 2024
0a81a57
style: :lipstick: Fixed background and text colors in CSS files in th…
Yashasewi Apr 13, 2024
5d5e5b1
style: :lipstick: Updated CSS files to use var(--text-color) for text…
Yashasewi Apr 13, 2024
71fefad
Merge branch 'CodingTrain:main' into feature-Dark-mode
Yashasewi Apr 14, 2024
f919fd6
style: :adhesive_bandage: fixed the background color and linear gradi…
Yashasewi Apr 14, 2024
67df3d4
style: :lipstick: Updated CSS files to fix text color and background …
Yashasewi Apr 14, 2024
d8d2d4d
style: :lipstick: Updated CSS files to fix text color and background …
Yashasewi Apr 14, 2024
ef05835
Merge branch 'CodingTrain:main' into feature-Dark-mode
Yashasewi Apr 20, 2024
9645c9e
style: Updated CSS files to fix text color on passenger-showcase-guid…
Yashasewi Apr 21, 2024
aefdb9f
style: Updated CSS files to fix text color on tags
Yashasewi Apr 21, 2024
239af39
style: 💄 Updated CSS files to fix text color and background color in …
Yashasewi Apr 21, 2024
0b9e810
Merge branch 'main' into feature-Dark-mode
Yashasewi Apr 27, 2024
0fefcad
style: Fix text color in guide.module.css
Yashasewi Apr 27, 2024
e8b2d76
fix: :bug: added --background-color variable in light mode
Yashasewi Apr 27, 2024
a03a34b
style: Updated CSS files to fix text color and background color in tr…
Yashasewi Apr 27, 2024
f210ce7
style: Updated CSS files to fix text color and background color on th…
Yashasewi Apr 27, 2024
fc779bc
Merge branch 'main' into feature-Dark-mode
Yashasewi Apr 27, 2024
a59084a
Merge branch 'CodingTrain:main' into feature-Dark-mode
Yashasewi Apr 28, 2024
a72dddc
style: Updated CSS to fix text color and background color on about page
Yashasewi Apr 28, 2024
79d13b2
style: Updated CSS files to fix text color on tabs button on hover
Yashasewi Apr 28, 2024
04bc148
fix: :art: updated Footer component to use react-icons for social med…
Yashasewi Apr 28, 2024
9d6797f
fix linter warnings
fturmel Apr 30, 2024
6ac61b8
fix dark theme FOUC
fturmel Apr 30, 2024
b882ca7
color improvement for dropdown filters dark mode
fturmel May 1, 2024
9669bab
fix: :bug: select color to use the text color varibale
Yashasewi May 1, 2024
529a9e8
Merge branch 'main' into feature-Dark-mode
Yashasewi May 2, 2024
b5fe187
restore footer background
fturmel May 2, 2024
97e1425
fix Nebula icon in footer + remove redundant icon color prop
fturmel May 2, 2024
420e2b5
swap social icons in `about` page for the react-icons set to match fo…
fturmel May 2, 2024
2d26f4c
remove unused images from codebase
fturmel May 2, 2024
ea67ec1
(chore) update caniuse-lite
fturmel May 2, 2024
aef5b17
tidy-up selectors
fturmel May 2, 2024
eaa6728
simplify theme toggle code + close mobile nav when activating
fturmel May 2, 2024
35cbeba
remove unused GuideCard color variants and fix its background color f…
fturmel May 2, 2024
b4cf3c9
quick css cleanup
fturmel May 2, 2024
21b87b1
code example link icons dark mode support
fturmel May 2, 2024
49989bf
Merge branch 'main' into feature-Dark-mode
Yashasewi May 2, 2024
111ce94
refactor: css clean up
Yashasewi May 2, 2024
77cc494
trivial change to unstick the GH Netlify plugin actions state
fturmel May 4, 2024
74964aa
style: small tweaks in colors by adding opacity
Yashasewi May 4, 2024
3e891ef
Merge branch 'main' into feature-Dark-mode
Yashasewi May 7, 2024
9c5b12b
Revert "Social media permission" linter fix
fturmel May 7, 2024
f97cc5d
Merge branch 'CodingTrain:main' into feature-Dark-mode
Yashasewi May 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/ButtonPanel.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
overflow: hidden;
margin: 0 var(--spacing-normal) 0 0;
text-transform: uppercase;
color: var(--gray-dark);
color: var(--text-color);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/components/ChallengesPanel.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
flex-wrap: wrap;
border-left: var(--border-cyan);
border-bottom: var(--border-cyan);
color: var(--gray-dark);
color: var(--text-color);
text-transform: uppercase;
background-color: var(--cyan-light);

Expand Down Expand Up @@ -60,7 +60,7 @@
justify-content: space-between;
align-items: center;
margin: 0;
color: var(--gray-dark);
color: var(--text-color);
}
}

Expand Down Expand Up @@ -92,7 +92,7 @@
padding: 0 calc(var(--box-padding) / 2);
border-bottom: var(--border);
border-color: var(--cyan);
color: var(--gray-dark);
color: var(--text-color);
font-weight: normal;
font-size: var(--maru-normal);
text-overflow: ellipsis;
Expand All @@ -112,7 +112,7 @@
height: var(--baseline-4x);
border-bottom: var(--border-cyan);
border-left: var(--border-cyan);
background-color: white;
background-color: var(--background-color);
overflow-x: hidden;
overflow-y: auto;

Expand All @@ -122,7 +122,7 @@
}

.date {
color: var(--gray-dark);
color: var(--text-color);
background-color: var(--cyan-light);
border-bottom: var(--border-cyan);
border-left: var(--border-cyan);
Expand Down
15 changes: 10 additions & 5 deletions src/components/CodeExampleList.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
flex-shrink: 0;
overflow: hidden;
text-overflow: ellipsis;
color: var(--text-color);
}

.description {
Expand All @@ -52,6 +53,7 @@
overflow: hidden;
text-overflow: ellipsis;
padding-right: var(--space);
color: var(--text-color);
}

.icon {
Expand All @@ -73,34 +75,37 @@
text-decoration: underline;
text-transform: lowercase;
white-space: nowrap;
color: var(--gray-dark);
color: var(--text-color);
}
& .linkIcon {
font-family: var(--maru-emoji);
font-size: var(--maru-emoji-normal);
text-decoration: none;
color: var(--gray-dark);
color: var(--text-color);
}
}

.p5 {
height: var(--baseline-1of2);
width: var(--baseline-1of2);
& path {
fill: var(--gray-dark);
fill: var(--text-color);
}
}

.node {
height: var(--baseline-1of2);
width: var(--baseline-1of2);
& path {
fill: var(--text-color);
}
}

.processing {
height: var(--baseline-1of3);
width: var(--baseline-1of3);
& path {
stroke: var(--gray-dark);
stroke: var(--text-color);
}
}

Expand All @@ -123,7 +128,7 @@
@media (--reduced) {
.red .example,
.cyan .example {
background-color: white;
background-color: var(--background-color);
}

.description {
Expand Down
4 changes: 2 additions & 2 deletions src/components/CreditList.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
align-items: center;
padding-left: var(--box-padding);
border-left: var(--border);
color: var(--gray-dark);
color: var(--text-color);

&:first-child {
margin-top: -2px;
Expand Down Expand Up @@ -57,7 +57,7 @@
@media (--reduced) {
.red .credit,
.cyan .credit {
background-color: white;
background-color: var(--background-color);
}
}

Expand Down
31 changes: 17 additions & 14 deletions src/components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import cn from 'classnames';
import * as css from './Footer.module.css';

import Logo from '../images/logo.svg';
import Github from '../images/github.svg';
import Twitch from '../images/twitch.svg';
import Nebula from '../images/nebula.svg';
import Twitter from '../images/twitter.svg';
import Discord from '../images/discord.svg';
import Youtube from '../images/youtube.svg';
import Instagram from '../images/instagram.svg';

import {
FaGithub,
FaTwitch,
FaTwitter,
FaDiscord,
FaYoutube,
FaInstagram
} from 'react-icons/fa6';
import { IoStarSharp } from 'react-icons/io5';

import { cols } from '../styles/styles.module.css';

Expand Down Expand Up @@ -83,28 +86,28 @@ const Footer = () => {
<a
href="https://www.youtube.com/c/TheCodingTrain/"
aria-label="Youtube">
<Youtube width={30} />
<FaYoutube size={30} />
<span>Youtube</span>
</a>
</li>
<li>
<a
href="https://www.twitch.tv/codingtrainchoochoo"
aria-label="Twitch">
<Twitch width={30} />
<FaTwitch size={30} />
<span>Twitch</span>
</a>
</li>

<li>
<a href="https://nebula.tv/codingtrain" aria-label="Nebula">
<Nebula width={30} />
<IoStarSharp size={30} style={{ transform: 'scaleY(-1)' }} />
<span>Nebula</span>
</a>
</li>
<li>
<a href="https://twitter.com/thecodingtrain" aria-label="Twitter">
<Twitter width={30} />
<FaTwitter size={30} />
<span>Twitter</span>
</a>
</li>
Expand All @@ -113,19 +116,19 @@ const Footer = () => {
<a
href="https://www.instagram.com/the.coding.train/"
aria-label="Instagram">
<Instagram width={30} />
<FaInstagram size={30} />
<span>Instagram</span>
</a>
</li>
<li>
<a href="https://thecodingtrain.com/discord" aria-label="Discord">
<Discord width={30} />
<FaDiscord size={30} />
<span>Discord</span>
</a>
</li>
<li>
<a href="https://github.com/CodingTrain" aria-label="GitHub">
<Github width={30} />
<FaGithub size={30} />
<span>GitHub</span>
</a>
</li>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Footer.module.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.root {
color: var(--gray-dark);
background-color: var(--gray-light);
color: var(--text-color);
flex-wrap: wrap;

& a {
padding-left: 0;
text-decoration: none;
color: var(--gray-dark);
color: var(--text-color);
}
}

Expand Down
21 changes: 7 additions & 14 deletions src/components/GuideCard.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
import React, { memo } from 'react';
import { Link } from 'gatsby';
import cn from 'classnames';

import ButtonPanel from './ButtonPanel';
import Image from './Image';

import * as css from './GuideCard.module.css';

const GuideCard = ({
title,
slug,
meta,
icon = '📒',
description,
image,
variant
}) => {
const GuideCard = ({ title, slug, meta, icon = '📒', description, image }) => {
// TODO refactor this to use a single ButtonPanel instance?

return (
<article className={cn(css.root, css[variant])}>
<article className={css.root}>
<div className={css.top}>
<div className={css.icon}>{icon}</div>
<h2>
<h2 className={css.title}>
<Link to={slug}>{title}</Link>
</h2>
</div>
Expand All @@ -32,7 +25,7 @@ const GuideCard = ({
text={meta}
buttonLink={slug}
buttonText="Read"
variant={variant}
variant="purple"
rainbow
/>
</div>
Expand All @@ -45,7 +38,7 @@ const GuideCard = ({
text={meta}
buttonLink={slug}
buttonText="Read"
variant={variant}
variant="purple"
rainbow
/>
</div>
Expand Down
41 changes: 10 additions & 31 deletions src/components/GuideCard.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,17 @@
display: flex;
flex-direction: column;

--color: var(--gray-dark);
--color: var(--purple);
--border: var(--border-purple);

@media (--medium) {
width: 100%;
flex-basis: 100%;
}
}

/* variants */
.root.purple {
--color: var(--purple);
--border: var(--border-purple);
--background-color: var(--purple-light);
}

.root.red {
--color: var(--red);
--border: var(--border-red);
--background-color: var(--red-light);
}

.root.orange {
--color: var(--orange);
--border: var(--border-orange);
--background-color: var(--orange-light);
}

.root.cyan {
--color: var(--cyan);
--border: var(--border-cyan);
--background-color: var(--cyan-light);
}

.icon {
border-right: var(--border);
border-bottom: var(--border);
border-left: var(--border);
.title {
color: var(--text-color);
}

.top {
Expand All @@ -60,6 +34,10 @@
display: flex;
justify-content: center;
align-items: center;

border-right: var(--border);
border-bottom: var(--border);
border-left: var(--border);
}

.top h2 {
Expand Down Expand Up @@ -96,7 +74,8 @@
text-overflow: ellipsis;
border-bottom: var(--border);
border-left: var(--border);
background-color: white;
background-color: var(--background-color);
color: var(--text-color);
}

.left .meta {
Expand Down
9 changes: 9 additions & 0 deletions src/components/Head.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ const Head = ({ title, description, image }) => {
content={description ?? defaultDescription}
/>
<meta property="twitter:image" content={`${siteUrl}${metaImage}`} />

{/* Theme toggle bootstrap */}
<script>{`
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark');
} else {
document.documentElement.classList.remove('dark');
}
`}</script>
</Helmet>
);
};
Expand Down
1 change: 1 addition & 0 deletions src/components/HomepageScene.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
margin: 0;
max-width: 600px;
padding: 0 var(--box-padding);
color: var(--text-color);
}

.train {
Expand Down
Loading
Loading