Skip to content
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
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Asap:ital,wght@0,100..900;1,100..900&display=swap"
rel="stylesheet"
/>
<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" />
Expand Down
33 changes: 18 additions & 15 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import { ThemeProvider } from './contexts/ThemeContext';
import AppLayout from './components/AppLayout.tsx';
import Home from './pages/Home.tsx';
import Register from './pages/Register.tsx';
Expand All @@ -13,21 +14,23 @@ import Settings from './pages/Settings.tsx';
function App() {
return (
<>
<BrowserRouter>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/register" element={<Register />} />
<Route element={<AppLayout />}>
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/events" element={<Events />} />
<Route path="/calendar" element={<Calendar />} />
<Route path="/roster" element={<Roster />} />
<Route path="/notifications" element={<Notifications />} />
<Route path="/profile" element={<Profile />} />
<Route path="/settings" element={<Settings />} />
</Route>
</Routes>
</BrowserRouter>
<ThemeProvider>
<BrowserRouter>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/register" element={<Register />} />
<Route element={<AppLayout />}>
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/events" element={<Events />} />
<Route path="/calendar" element={<Calendar />} />
<Route path="/roster" element={<Roster />} />
<Route path="/notifications" element={<Notifications />} />
<Route path="/profile" element={<Profile />} />
<Route path="/settings" element={<Settings />} />
</Route>
</Routes>
</BrowserRouter>
</ThemeProvider>
</>
);
}
Expand Down
Empty file removed src/components/.gitkeep
Empty file.
14 changes: 14 additions & 0 deletions src/components/DarkModeToggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useTheme } from '../contexts/ThemeContext';

export function DarkModeToggle() {
const { theme, toggleTheme } = useTheme();

return (
<input
type="checkbox"
checked={theme === 'dark'}
onChange={toggleTheme}
style={{ height: '20px', width: '20px' }}
/>
);
}
3 changes: 3 additions & 0 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import '../css/header.css';
import { useNavigate } from 'react-router-dom';
import { DarkModeToggle } from './DarkModeToggle.tsx';

export default function Header() {
const navigate = useNavigate();

return (
<div className="header-container">
<h1 className="header-title">CAPY Web UI</h1>
Expand All @@ -13,6 +15,7 @@ export default function Header() {
<a className="register-btn" onClick={() => navigate('/register')}>
Register
</a>
<DarkModeToggle />
</div>
</div>
);
Expand Down
47 changes: 47 additions & 0 deletions src/contexts/ThemeContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* eslint-disable react-refresh/only-export-components */

import React, { createContext, useContext, useEffect, useState } from 'react';

type Theme = 'light' | 'dark';

interface ThemeContextType {
theme: Theme;
toggleTheme: () => void;
setTheme: (theme: Theme) => void;
}

const ThemeContext = createContext<ThemeContextType | undefined>(undefined);

export const ThemeProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const [theme, setThemeState] = useState<Theme>(() => {
const saved = localStorage.getItem('site_mode');
return (saved as Theme) || 'light';
});

const setTheme = (newTheme: Theme) => {
setThemeState(newTheme);
};

const toggleTheme = () => {
setThemeState((prev) => (prev === 'dark' ? 'light' : 'dark'));
};

useEffect(() => {
document.documentElement.setAttribute('data-theme', theme);
localStorage.setItem('site_mode', theme);
}, [theme]);

return (
<ThemeContext.Provider value={{ theme, toggleTheme, setTheme }}>
{children}
</ThemeContext.Provider>
);
};

export const useTheme = (): ThemeContextType => {
const context = useContext(ThemeContext);
if (!context) {
throw new Error('useTheme must be used within a ThemeProvider');
}
return context;
};
71 changes: 62 additions & 9 deletions src/css/colors.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,66 @@
/* All of the Web UI's color variables in one place */
/* colors.css: All of the Web UI's color variables in one place */

/*

PURPOSE: Consistent, easily modifiable color variables
abstracted to a single file.

HOW TO USE: All variables in the CAPY COLOR SUITE should be treated
as constants. These constants should NOT be found in other CSS files.
Instead, create variables in the COLOR VARIABLES section, and use those.
COLOR VARIABLES should be duplicated and properly adjusted in the dark
mode section as well.

*/

:root {
/* GLOBAL STYLES ============================ */
--site-transition: 0.25s;
--site-bg: #f5f5f5;
--header-bg: #fff;
--sidebar-bg: #fff;
--sidebar-link-hover-bg: #f4f4f4;
--sidebar-active-link-bg: #e4e4e4;
--standard-white: #fff;
--standard-black: #000;
--standard-text: #1c1c1c;
--site-font: 'Asap', sans-serif;

/* ========================================== */

/* CAPY COLOR SUITE ========================= */

/* All colors used on the site are found here */
--primary-light: #339b92;
--primary: #007a75;
--primary-dark: #00464d;
--primary-extra-dark: #002633;
--accent: #f1602f;
--off-white: #f9fafa;
--highlight: #f4f8f6;
--off-black: #20201f;

/* ========================================== */

/* COLOR VARIABLES ========================== */

/* Global Styles: backgrounds, text */
--site-bg: var(--off-white);
--standard-white: var(--off-white);
--standard-black: var(--off-black);
--standard-text: var(--primary);

/* Sidebar / Header */
--header-bg: var(--highlight);
--sidebar-bg: var(--highlight);
--sidebar-link-hover-bg: var(--off-white);
--sidebar-active-link-bg: var(--primary-light);
}

[data-theme='dark'] {
/* COLOR VARIABLES ========================== */

/* Global Styles: backgrounds, text */
--site-bg: var(--off-black);
--standard-white: var(--off-black);
--standard-black: var(--off-white);
--standard-text: var(--primary);

/* Sidebar / Header */
--header-bg: var(--primary-extra-dark);
--sidebar-bg: var(--primary-extra-dark);
--sidebar-link-hover-bg: var(--accent);
--sidebar-active-link-bg: var(--accent);
}
3 changes: 2 additions & 1 deletion src/css/header.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@
.header-title {
margin: 0;
flex-grow: 1;
font-weight: 500;
}

.header-right-btns {
display: flex;
flex-direction: row;
gap: 1.75rem;
align-items: center;
}

.profile-btn,
.register-btn {
cursor: pointer;
font-size: 1.25rem;
font-weight: bold;
padding: 0.35rem 1rem;
border-radius: 0.7rem;
display: flex;
Expand Down
3 changes: 2 additions & 1 deletion src/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/* ================================================= */
:root {
font-family: Helvetica, Arial, sans-serif;
font-family: var(--site-font);
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
Expand Down Expand Up @@ -32,6 +32,7 @@ body {

h1 {
color: var(--standard-text);
font-weight: 500;
}

/* ================================================= */
Expand Down
1 change: 0 additions & 1 deletion src/css/sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@

.sidebar-link-label {
font-size: 1rem;
font-weight: bold;
max-width: 200px;
overflow: hidden;
white-space: nowrap;
Expand Down
Empty file removed src/hooks/.gitkeep
Empty file.