Skip to content
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

Dark Mode feature added #20

Merged
merged 2 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SLIIT POSON | IM</title>
<title>SLIIT Vesak | IM</title>
</head>
<body>
<div id="root"></div>
Expand Down
19 changes: 18 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
import { useState } from "react";
import AppRoutes from "./routes/app-routes";
import { DarkModeToggle } from "./components";

function App() {
const [darkToggle, setDarkToggle] = useState(
localStorage.getItem("theme") === "dark" ? true : false
);

const toggleDark = () => {
if (darkToggle) {
localStorage.setItem("theme", "light");
setDarkToggle(false);
} else {
localStorage.setItem("theme", "dark");
setDarkToggle(true);
}
};

return (
<div>
<div className={darkToggle ? "dark" : ""}>
<DarkModeToggle toggleDark={toggleDark} />
<AppRoutes />
</div>
);
Expand Down
20 changes: 20 additions & 0 deletions src/components/DarkModeToggle/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const DarkModeToggle = ({ toggleDark }) => {
return (
<button
className="fixed bottom-0 right-0 z-50 flex items-center justify-center w-12 h-12 mr-4 mb-4 text-2xl font-bold text-white transition duration-500 ease-in-out transform bg-gray-800 rounded-full dark:bg-gray-200 hover:bg-gray-700 dark:hover:bg-gray-300 focus:outline-none"
onClick={toggleDark}
>
{localStorage.getItem("theme") === "dark" ? (
<span role="img" aria-label="sun">
☀️
</span>
) : (
<span role="img" aria-label="moon">
🌙
</span>
)}
</button>
);
};

export default DarkModeToggle;
3 changes: 2 additions & 1 deletion src/components/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Header from "./Header";
import Footer from "./Footer";
import DarkModeToggle from "./DarkModeToggle";

export { Header, Footer };
export { Header, Footer, DarkModeToggle };
6 changes: 4 additions & 2 deletions src/views/Committee/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { Link } from "react-router-dom";
*/
const Committee = () => {
return (
<div className="flex flex-col items-center justify-center h-screen bg-gray-100">
<h1 className="text-3xl font-bold underline">Organizing Committee</h1>
<div className="flex flex-col items-center justify-center h-screen bg-gray-100 dark:bg-gray-900">
<h1 className="text-3xl font-bold underline dark:text-white">
Organizing Committee
</h1>
<Link
to="/team"
className="mt-10 px-4 py-2 text-sm font-medium text-white bg-blue-500 rounded-md hover:bg-blue-600"
Expand Down
4 changes: 2 additions & 2 deletions src/views/Feedback/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*/
const Feedback = () => {
return (
<div className="flex flex-col items-center justify-center h-screen bg-gray-100">
<h1 className="text-3xl font-bold underline">Feedback</h1>
<div className="flex flex-col items-center justify-center h-screen bg-gray-100 dark:bg-gray-900">
<h1 className="text-3xl font-bold underline dark:text-white">Feedback</h1>
</div>
);
};
Expand Down
6 changes: 4 additions & 2 deletions src/views/Hero/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
*/
const Hero = () => {
return (
<div className="flex flex-col items-center justify-center h-screen bg-gray-100">
<h1 className="text-3xl font-bold underline">Hello world!</h1>
<div className="flex flex-col items-center justify-center h-screen bg-gray-100 dark:bg-gray-900">
<h1 className="text-3xl font-bold underline dark:text-white">
Hello world!
</h1>
</div>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/views/Mentors/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*/
const Mentors = () => {
return (
<div className="flex flex-col items-center justify-center h-screen bg-gray-100">
<h1 className="text-3xl font-bold underline">Mentors</h1>
<div className="flex flex-col items-center justify-center h-screen bg-gray-100 dark:bg-gray-900">
<h1 className="text-3xl font-bold underline dark:text-white">Our Mentors</h1>
</div>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/views/OurWork/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*/
const OurWork = () => {
return (
<div className="flex flex-col items-center justify-center h-screen bg-gray-100">
<h1 className="text-3xl font-bold underline">Our Work</h1>
<div className="flex flex-col items-center justify-center h-screen bg-gray-100 dark:bg-gray-900">
<h1 className="text-3xl font-bold underline dark:text-white">Our Work</h1>
</div>
);
};
Expand Down
6 changes: 3 additions & 3 deletions src/views/Team/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*/
const Team = () => {
return (
<>
<h1 className="text-3xl font-bold underline">Our Team</h1>
</>
<div className="flex flex-col items-center justify-center h-screen bg-gray-100 dark:bg-gray-900">
<h1 className="text-3xl font-bold underline dark:text-white">Our Team Page</h1>
</div>
);
};

Expand Down
6 changes: 4 additions & 2 deletions src/views/VesakZone/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
*/
const VesakZone = () => {
return (
<div className="flex flex-col items-center justify-center h-screen bg-gray-100">
<h1 className="text-3xl font-bold underline">Vesak Zone</h1>
<div className="flex flex-col items-center justify-center h-screen bg-gray-100 dark:bg-gray-900">
<h1 className="text-3xl font-bold underline dark:text-white">
Vesak Zone
</h1>
</div>
);
};
Expand Down
1 change: 1 addition & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @type {import('tailwindcss').Config} */
export default {
darkMode: "class",
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {
Expand Down