Skip to content

Commit

Permalink
(feature) Adding Dark Mode feature on all webpage
Browse files Browse the repository at this point in the history
This commit will add dark mode feture

issue truethari#3
  • Loading branch information
sksabbirhossain committed Nov 1, 2023
1 parent fd68e9b commit 49890bc
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 17 deletions.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="theme-color" content="#000000" />
<title>Reactfolio</title>
</head>
<body>
<body className="light-theme">
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
Expand Down
8 changes: 4 additions & 4 deletions src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}

::-webkit-scrollbar-track {
background-color: #f1f1f1;
background-color: var(--secondary-background);
}

::-webkit-scrollbar-thumb {
Expand All @@ -18,7 +18,7 @@
}

.page-content {
background-color: white;
background-color: var(--secondary-background);
position: relative;
}

Expand All @@ -29,8 +29,8 @@
top: 0;
bottom: 0;
width: calc((100% - 1200px) / 2);
background-color: #fafafa;
border: 1px solid #f4f4f5;
background-color: var(--background);
border: 1px solid var(--border-color);
}

.page-content:before {
Expand Down
4 changes: 2 additions & 2 deletions src/components/articles/style/article.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}

.article-right-side:hover {
background: #fafafa;
background: var(--hover-background);
opacity: 1;
transition: background-color 0.3s ease-in-out;
}
Expand All @@ -35,7 +35,7 @@
}

.article-title {
color: #000000;
color: var(--secondary-color);
font-size: 16px;
font-weight: 600;
}
Expand Down
33 changes: 31 additions & 2 deletions src/components/common/navBar.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
import React from "react";
import { faCloudMoon, faSun } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import React, { useEffect, useState } from "react";
import { Link } from "react-router-dom";

import "./styles/navBar.css";

const NavBar = (props) => {
const { active } = props;
const [theme, setTheme] = useState(
localStorage.getItem("theme") || "light-theme"
);

// change theme function
const themeToggle = () => {
if (theme === "light-theme") {
setTheme("dark-theme");
} else {
setTheme("light-theme");
}
};

// save the theme preference to local storage
useEffect(() => {
document.body.className = theme;
localStorage.setItem("theme", theme);
}, [theme]);

return (
<React.Fragment>
Expand Down Expand Up @@ -57,6 +76,16 @@ const NavBar = (props) => {
>
<Link to="/contact">Contact</Link>
</li>
<li
className="nav-item-icon"
onClick={() => themeToggle()}
>
{theme === "light-theme" ? (
<FontAwesomeIcon icon={faCloudMoon} />
) : (
<FontAwesomeIcon icon={faSun} />
)}
</li>
</ul>
</div>
</nav>
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/styles/card.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.card {
mix-blend-mode: normal;
border-radius: 20px;
outline: 2px solid #f4f4f5;
outline: 2px solid var(--border-color);
}

.card-container {
Expand Down
9 changes: 8 additions & 1 deletion src/components/common/styles/navBar.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
height: 40px;
padding-left: 0%;
padding-right: 0%;
background: #fff;
background: var(--background);
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1);
border-radius: 40px;
}
Expand Down Expand Up @@ -55,6 +55,13 @@
transition: color 0.3s ease-in-out;
}

.nav-item-icon {
cursor: pointer;
font-weight: bold;
font-size: 85%;
color: var(--primary-color);
}

@media (max-width: 600px) {
.navbar {
margin-left: 25%;
Expand Down
2 changes: 1 addition & 1 deletion src/components/homepage/styles/article.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}

.homepage-article:hover {
background: #fafafa;
background: var(--hover-background);
opacity: 1;
transition: background-color 0.3s ease-in-out;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/projects/styles/project.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}

.project:hover {
background: #fafafa;
background: var(--hover-background);
opacity: 1;
transition: background-color 0.3s ease-in-out;
}
Expand Down
30 changes: 28 additions & 2 deletions src/data/styles.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
:root {
/* light theme colors */
.light-theme {
/* ------- colors ------- */
--primary-color: #27272a;
--secondary-color: #65656d;
--tertiary-color: #acacb4;
--tertiary-color: #929292;
--quaternary-color: #e4e4e7;
--link-color: #14b8a6;
/* --border-color: #e9e6e6; */
--border-color: #f4f4f5;
--background: #fff;
--hover-background: #f8f8f8;
--secondary-background: #fbfdfd;
/* ---------------------- */

/* ------- fonts ------- */
--primary-font: "Heebo", sans-serif;
--secondary-font: "Roboto", sans-serif;
/* --------------------- */
}

/* dark theme colors */
.dark-theme {
/* ------- colors ------- */
--primary-color: #fefeff;
--secondary-color: #d8d8db;
--tertiary-color: #9c9c9c;
--quaternary-color: #1e1e1f;
--link-color: #14b8a6;
--border-color: #111331;
--background: #0e182c;
--hover-background: #0e182c;
--secondary-background: #101e38;
/* ---------------------- */

/* ------- fonts ------- */
Expand Down
2 changes: 2 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}


4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import { BrowserRouter } from "react-router-dom";
import App from "./App";
import "./index.css";
import reportWebVitals from "./reportWebVitals";
import { BrowserRouter } from "react-router-dom";

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
Expand Down

0 comments on commit 49890bc

Please sign in to comment.