diff --git a/frontend/src/Pages/Herosection.jsx b/frontend/src/Pages/Herosection.jsx index 750dcf4..a6e72a0 100644 --- a/frontend/src/Pages/Herosection.jsx +++ b/frontend/src/Pages/Herosection.jsx @@ -1,5 +1,6 @@ import React from "react"; import "./Herosection.css"; +import ThemeToggle from "../components/ThemeToggle" import logo from "../assets/stationsaarthi.svg"; import navigationsvg from "../assets/svg/navigation.svg"; import bookingsvg from "../assets/svg/bookings.svg"; @@ -56,8 +57,9 @@ const Herosection = () => { return ( <>
+
By signing in, I agree to Station Saarthi's{' '} Terms of Service and{' '} Privacy Policy. diff --git a/frontend/src/hooks/useDarkMode.js b/frontend/src/hooks/useDarkMode.js new file mode 100644 index 0000000..b391abf --- /dev/null +++ b/frontend/src/hooks/useDarkMode.js @@ -0,0 +1,18 @@ +import { useState, useEffect } from 'react'; + +const useDarkMode = () => { + const [theme, setTheme] = useState(() => localStorage.getItem('theme') || 'light'); + + useEffect(() => { + const root = document.documentElement; + const isDark = theme === 'dark'; + root.classList.toggle('dark', isDark); + console.log(`Theme set to ${theme}, dark mode is ${isDark ? 'enabled' : 'disabled'}`); + localStorage.setItem('theme', theme); + }, [theme]); + + + return [theme, setTheme]; +}; + +export default useDarkMode; \ No newline at end of file diff --git a/frontend/tailwind.config.js b/frontend/tailwind.config.js index 6bdcac8..52339c9 100644 --- a/frontend/tailwind.config.js +++ b/frontend/tailwind.config.js @@ -1,9 +1,10 @@ /** @type {import('tailwindcss').Config} */ export default { content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'], + darkMode: 'class', theme: { - extend: {}, + extend: { + }, }, plugins: [], -} - +};