@@ -255,3 +255,103 @@ This repository contains the source code for the University of Virginia Mathemat
255
255
- People references use include files rather than hardcoded names
256
256
- Categories determine post visibility on different pages
257
257
- Changes take ~5 minutes to appear on live site after GitHub commit
258
+
259
+ ---
260
+
261
+ # # Dark Mode Implementation
262
+
263
+ The website features a comprehensive dark mode that automatically adapts to user preferences and can be manually toggled.
264
+
265
+ # ## Key Features
266
+
267
+ 1. **Automatic OS Detection** : The site respects the user's operating system dark mode preference on first visit
268
+ 2. **Manual Toggle** : Users can override the OS preference using a toggle button in the navbar
269
+ 3. **Persistent Preference** : User's choice is saved in localStorage and persists across sessions
270
+ 4. **Smooth Transitions** : All color changes animate smoothly when switching themes
271
+
272
+ # ## Toggle Button Design
273
+
274
+ - **Location**: Main navbar, positioned to the left of "Support us" link
275
+ - **Mobile**: Remains visible on small screens, positioned to the left of the vertical dots menu on special pages
276
+ - **Design**: Dual-icon toggle showing both cloud-sun (day) and moon (night) icons with a sliding indicator
277
+ - **Interaction**: Click anywhere on the button to toggle between light and dark modes
278
+
279
+ # ## Technical Implementation
280
+
281
+ # ### CSS Architecture
282
+
283
+ The dark mode uses CSS custom properties (variables) defined in `/css/main.css` :
284
+
285
+ ` ` ` css
286
+ :root {
287
+ --bg-color: #ffffff;
288
+ --text-color: #212529;
289
+ --card-bg: #ffffff;
290
+ /* ... other light mode variables */
291
+ }
292
+
293
+ [data-theme="dark"] {
294
+ --bg-color: #0a1628; /* Very dark navy blue */
295
+ --text-color: #e8e8e8;
296
+ --card-bg: #1a2a3f; /* Dark navy blue */
297
+ /* ... other dark mode variables */
298
+ }
299
+ ` ` `
300
+
301
+ # ### Color Scheme
302
+
303
+ The dark mode uses a sophisticated navy blue color palette aligned with UVA branding :
304
+ - **Background**: `#0a1628` (very dark navy)
305
+ - **Cards/Panels**: `#1a2a3f` (dark navy)
306
+ - **Hover States**: `#243448` (slightly lighter navy)
307
+ - **Active States**: `#003d7a` (UVA blue variation)
308
+ - **Text**: `#e8e8e8` (light gray)
309
+ - **Links**: `#4da3ff` (lighter blue for contrast)
310
+
311
+ # ### JavaScript Functionality
312
+
313
+ Located in `_includes/footer.html`, the dark mode script :
314
+ 1. Checks localStorage for saved preference
315
+ 2. Falls back to OS preference if no saved preference
316
+ 3. Applies theme by setting `data-theme` attribute on `<html>`
317
+ 4. Handles toggle button clicks and touch events
318
+ 5. Listens for OS theme changes (respects if user hasn't manually set preference)
319
+
320
+ # ## Component-Specific Styling
321
+
322
+ # ### Navigation
323
+ - **Navbar**: Background remains light with adjusted toggle button colors
324
+ - **Hamburger/Dots**: Icons turn light gray (#e8e8e8) in dark mode
325
+ - **Dropdowns**: Dark backgrounds with appropriate contrast
326
+
327
+ # ### Sidebars
328
+ - **List Groups**: Dark gray (#243448) backgrounds instead of white
329
+ - **Orange Headers**: Adjusted orange tones for visibility
330
+ - **Active Items**: UVA blue variation (#003d7a) for selected items
331
+
332
+ # ### Content Areas
333
+ - **Cards**: All use dark navy backgrounds
334
+ - **Jumbotrons**: Special handling for major-news sections
335
+ - **Zebra Striping**: Alternating rows use darker navy (#162133)
336
+ - **Code Blocks**: Dark backgrounds with syntax highlighting
337
+
338
+ # ### Forms
339
+ - **Search Bar**: Semi-transparent backgrounds with light borders
340
+ - **Input Fields**: Dark backgrounds with light text
341
+ - **Buttons**: Appropriate contrast adjustments
342
+
343
+ # ## Best Practices for Content Creators
344
+
345
+ 1. **Images** : Ensure images have sufficient contrast for both light and dark modes
346
+ 2. **Colors** : Avoid hardcoding colors in inline styles; use CSS classes instead
347
+ 3. **Backgrounds** : Test content visibility in both modes before publishing
348
+ 4. **Icons** : Use Font Awesome icons which automatically adapt to the theme
349
+
350
+ # ## Testing Dark Mode
351
+
352
+ To test dark mode functionality :
353
+ 1. Click the toggle button in the navbar
354
+ 2. Check that all text remains readable
355
+ 3. Verify interactive elements maintain proper contrast
356
+ 4. Ensure images and media display correctly
357
+ 5. Test on both desktop and mobile devices
0 commit comments