Skip to content

Commit

Permalink
Merge pull request #178 from Ayushmaanagarwal1211/Dark-mode
Browse files Browse the repository at this point in the history
Added Dark Mode
  • Loading branch information
Avdhesh-Varshney authored Jul 3, 2024
2 parents 92e7f7f + 52cda53 commit 6c8c41f
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 7 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"bootstrap": "^5.3.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^5.2.1",
"react-parallax-tilt": "^1.7.229",
"react-player": "^2.16.0",
"react-router-dom": "^6.23.1",
Expand Down
20 changes: 19 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,28 @@ import ContributorDetail from "./pages/contributor/ContributorDetail";

import SignIn from "./pages/auth/SignIn";
import SignUp from "./pages/auth/SignUp";
import { createContext } from 'react';


//theme context
export const ThemeContext = createContext(null);
function App() {
const [progress, setProgress] = useState(0);

const [theme, setTheme] = useState("light");

//Toggle theme
const toggleTheme = () => {
console.log('cliocking')
document.body.classList.toggle('dark')
if(theme=='dark'){
setTheme('light')
}else{
setTheme('dark')
}
}
return (
<ThemeContext.Provider value={{theme, toggleTheme}}>

<div className='container d-flex flex-column min-vh-100'>
<Router>
<Navbar />
Expand Down Expand Up @@ -72,6 +89,7 @@ function App() {
<Footer />
</Router>
</div>
</ThemeContext.Provider>
);
}

Expand Down
8 changes: 6 additions & 2 deletions src/components/shared/Navbar.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react';
import { ThemeContext } from '../../App';
import React, { useContext } from 'react';
import { Link } from 'react-router-dom';

import {FaSun,FaMoon} from 'react-icons/fa6'
const Navbar = () => {
let {theme,toggleTheme}=useContext(ThemeContext)
return (
<nav className="navbar navbar-expand-lg navbar-dark bg-dark mt-2 rounded">
<div className="container-fluid">
Expand Down Expand Up @@ -50,6 +52,8 @@ const Navbar = () => {
<button type='button' className='btn btn-light'>Sign Up</button>
</Link>
</li>
<li onClick={toggleTheme} className='mode'>
{theme == 'dark' ?<FaSun style={{color:"white"}}/>:<FaMoon style={{color:"white"}}/> }</li>
</ul>
</div>
</div>
Expand Down
18 changes: 15 additions & 3 deletions src/css/About.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.dark .about-container{
background-color: black;
border: 2px solid white ;
color: white ;
}
.about-container h1 {
text-align: center;
color: #874343;
Expand Down Expand Up @@ -49,7 +53,9 @@
margin-bottom: 10px;
color: #780d0d;
}

.dark .about-text ul li {
color: rgb(241, 66, 66);
}
blockquote {
margin: 20px 0;
padding: 10px 20px;
Expand All @@ -58,7 +64,10 @@ blockquote {
font-style: italic;
color: #333;
}

.dark blockquote{
background-color: black;
color: white;
}
@media (min-width: 768px) {
.about-image {
width: 35%;
Expand All @@ -83,4 +92,7 @@ blockquote {
{
font-size: 20px;
}
}
.dark .about-text{
color:white !important;
}
7 changes: 6 additions & 1 deletion src/css/Contributor.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
transition: all 0.3s ease;
}

.dark .card{
background-color: black;
box-shadow: 0px 0px 5px white;
color: white ;

}
.card:hover {
transform: translateY(-5px);
box-shadow: 0 15px 30px rgba(31, 38, 135, 0.5);
Expand Down
20 changes: 20 additions & 0 deletions src/css/Home.css
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,23 @@
box-shadow: 0 0 0 45px rgba(0, 0, 0, 0);
}
}
.dark .feat-3{
background-color: black;
color: white;
}
.dark .feat-card-2{
background-color: black;
box-shadow: 0px 0px 10px white;
border: solid white 2px;
}
.dark .feat-card{
background-color: black ;
box-shadow: 0px 0px 10px white;
color: white;
}
.mode{
display: flex;
justify-content: center;
align-items: center;
font-size: 1.5rem;
}
4 changes: 4 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
*{
cursor: url('/src/assets/CURSOR1.png'),auto;
}
.dark {
background-color: black;
color: white;
}

0 comments on commit 6c8c41f

Please sign in to comment.