diff --git a/package-lock.json b/package-lock.json index 60164f1..f8f91f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,7 +54,6 @@ "integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.29.7", "@babel/generator": "^7.29.7", @@ -1325,7 +1324,6 @@ "integrity": "sha512-vfEqpXTvwT91yhmwdfouStN2hSKwTvyRs8qpLfADyrq/kxDw0hZM7Wk9Ug1FELj8hIby+S/+kQCSRFF32nv2Qw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/prop-types": "*", "csstype": "^3.2.2" @@ -1375,7 +1373,6 @@ "integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -1658,7 +1655,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.10.44", "caniuse-lite": "^1.0.30001806", @@ -2258,7 +2254,6 @@ "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -3994,7 +3989,6 @@ "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", "license": "MIT", - "peer": true, "dependencies": { "loose-envify": "^1.1.0" }, @@ -4007,7 +4001,6 @@ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", "license": "MIT", - "peer": true, "dependencies": { "loose-envify": "^1.1.0", "scheduler": "^0.23.2" @@ -4827,7 +4820,6 @@ "integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.21.3", "postcss": "^8.4.43", diff --git a/src/App.css b/src/App.css index 73a237a..503c403 100644 --- a/src/App.css +++ b/src/App.css @@ -23,55 +23,68 @@ } /* Dark Mode Toggle */ -.dark-toggle { - padding: 3px; - width: fit-content; +.theme-toggle { + display: inline-flex; + align-items: center; position: relative; - background: #222; - border-radius: 30px; } .toggle-checkbox { opacity: 0; position: absolute; + width: 0; + height: 0; } .switch { margin: 0; width: 50px; - background: #222; + height: 27px; + background: #333; display: flex; align-items: center; justify-content: space-between; border-radius: 30px; position: relative; - gap: 0; + padding: 0 5px; + cursor: pointer; + user-select: none; } .switcher { background: #fff; position: absolute; - left: 0; + left: 2px; height: 23px; width: 23px; border-radius: 50%; - transition: 0.3s ease-out; + transition: transform 0.3s ease-out; } .icon { display: flex; + font-size: 13px; } .toggle-checkbox:checked + .switch .switcher { - transform: translateX(calc(50px - 23px)); + transform: translateX(23px); } html[data-theme="dark"] { color-scheme: dark; } +html[data-theme="dark"] .welcome h1 { + color: #f4f4f5; +} + html[data-theme="dark"] .welcome p { - color: #ddd; + color: #a1a1aa; +} + +html[data-theme="dark"] .welcome code { + background: #27272a; + color: #f4f4f5; } /* Error Page */ @@ -199,6 +212,12 @@ html[data-theme="dark"] .welcome p { flex-shrink: 0; } +.navbar-actions { + display: flex; + align-items: center; + gap: 1.5rem; +} + .navbar-links { display: flex; gap: 1.75rem; @@ -238,17 +257,21 @@ html[data-theme="dark"] .welcome p { } html[data-theme="dark"] .navbar { - background: rgba(0, 0, 0, 0.85); - border-bottom-color: #222; + background: rgba(18, 18, 18, 0.85); + border-bottom-color: #27272a; } -html[data-theme="dark"] .navbar-brand, -html[data-theme="dark"] .navbar-link.active { - color: #7da2c3; +html[data-theme="dark"] .navbar-brand { + color: #f4f4f5; } html[data-theme="dark"] .navbar-link { - color: #9fb8cc; + color: #a1a1aa; +} + +html[data-theme="dark"] .navbar-link:hover, +html[data-theme="dark"] .navbar-link.active { + color: #f4f4f5; } @media (max-width: 600px) { @@ -259,7 +282,12 @@ html[data-theme="dark"] .navbar-link { .navbar-content { flex-direction: column; align-items: flex-start; - gap: 0.6rem; + gap: 0.8rem; + } + + .navbar-actions { + width: 100%; + justify-content: space-between; } .navbar-links { @@ -311,6 +339,28 @@ html[data-theme="dark"] .navbar-link { color: #666; } +html[data-theme="dark"] .footer { + background: #18181b; + border-top-color: #27272a; +} + +html[data-theme="dark"] .footer h3, +html[data-theme="dark"] .footer-links a { + color: #f4f4f5; +} + +html[data-theme="dark"] .footer p { + color: #a1a1aa; +} + +html[data-theme="dark"] .error-sub { + color: #e4e4e7; +} + +html[data-theme="dark"] .home-button { + color: #8e8dd3; +} + @media (max-width: 600px) { .footer { padding: 1.5rem 1rem; diff --git a/src/components/Dark-Mode.jsx b/src/components/Dark-Mode.jsx index 4a98db4..c29e41a 100644 --- a/src/components/Dark-Mode.jsx +++ b/src/components/Dark-Mode.jsx @@ -1,45 +1,36 @@ -function DarkMode() { - const rootEl = document.documentElement; - - const savedTheme = localStorage.getItem("theme"); - if (savedTheme) { - rootEl.setAttribute("data-theme", savedTheme); - } - - function printToggle() { - const currentTheme = - rootEl.getAttribute("data-theme") || - (window.matchMedia("(prefers-color-scheme: dark)").matches - ? "dark" - : "light"); +import { useState, useEffect } from "react"; - const newTheme = currentTheme === "dark" ? "light" : "dark"; +function DarkMode() { + const [theme, setTheme] = useState(() => { + const savedTheme = localStorage.getItem("theme"); + if (savedTheme) { + return savedTheme; + } + return window.matchMedia("(prefers-color-scheme: dark)").matches + ? "dark" + : "light"; + }); - rootEl.setAttribute("data-theme", newTheme); - localStorage.setItem("theme", newTheme); - } + useEffect(() => { + document.documentElement.setAttribute("data-theme", theme); + localStorage.setItem("theme", theme); + }, [theme]); - const currentTheme = - rootEl.getAttribute("data-theme") || - (window.matchMedia("(prefers-color-scheme: dark)").matches - ? "dark" - : "light"); + const toggleTheme = () => { + setTheme((prevTheme) => (prevTheme === "dark" ? "light" : "dark")); + }; - const isDark = currentTheme === "dark"; + const isDark = theme === "dark"; return ( -
+
diff --git a/src/components/Navbar.jsx b/src/components/Navbar.jsx index f5ff7a7..e25a600 100644 --- a/src/components/Navbar.jsx +++ b/src/components/Navbar.jsx @@ -1,4 +1,5 @@ import { NavLink } from "react-router-dom"; +import DarkMode from "./Dark-Mode.jsx"; function Navbar() { return ( @@ -9,27 +10,30 @@ function Navbar() { React Open Source - +
+ + +
); diff --git a/src/index.css b/src/index.css index 871f432..d561508 100644 --- a/src/index.css +++ b/src/index.css @@ -11,14 +11,10 @@ body { margin: 0; background-color: #ffffff; color: #213547; - transition: background 0.3s ease-in, color 0.3s ease-in; + transition: background-color 0.3s ease, color 0.3s ease; } -html[data-theme="dark"] { - color-scheme: dark; - - body { - background: #000; - color: #7DA2C3; - } +html[data-theme="dark"] body { + background-color: #121212; + color: #e4e4e7; } \ No newline at end of file