Added frontend code quality tooling with Prettier for formatting and ESLint for linting. Provides consistent code style enforcement for all HTML, JS, and CSS files.
- Defines
prettier,eslint, and@eslint/jsas dev dependencies - npm scripts:
format(write),format:check(read-only),lint(ESLint) - Install:
cd frontend && npm install
- 4-space indent, single quotes, trailing commas (ES5), semicolons
printWidth: 80,arrowParens: "always"
- ESLint 9 flat config using
@eslint/jsrecommended rules - Browser globals +
markeddeclared as read-only - Rules:
eqeqeq: error,no-unused-vars: warn,no-console: warn
- Excludes
node_modules/
- Runs
prettier --writeon all frontend HTML/JS/CSS files - Usage:
./scripts/frontend-format.sh
- Runs
prettier --check+eslintwithout modifying files - Exit code 0 = all checks pass; non-zero = issues found
- Usage:
./scripts/frontend-lint.sh
Applied Prettier-consistent formatting throughout:
- Trailing commas added to all multi-line object literals and function call arguments
.map()chains reformatted with method chaining on separate lines- Redundant inline comments removed (self-explanatory code)
- Consistent arrow function parentheses (
(e) =>note =>)
cd frontend
npm installThen use the scripts from the repo root:
./scripts/frontend-format.sh # auto-fix formatting
./scripts/frontend-lint.sh # check only (CI-safe)Added a toggle button that allows users to switch between dark and light themes for the Course Materials Assistant application.
- Added a
.header-contentflex container to the<header>with.header-texton the left and the toggle button on the right - Added
#themeTogglebutton with inline sun and moon SVG icons and anaria-labelattribute
- Dark theme (default) defined on
:root - Light theme defined on
[data-theme="light"] .header-contentusesdisplay: flex; justify-content: space-betweento push the toggle to the top-right.theme-toggle: circular 44×44 px button,border-radius: 50%, hover/focus/active states.sun-icon/.moon-icon:position: absolutesiblings; the active icon hasopacity: 1, scale(1), the inactive one hasopacity: 0, rotate(±180deg) scale(0.8)— both animated withtransition: all 0.3s easebodyand*selectors carrytransition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s easefor smooth theme switching- Responsive: on screens ≤ 768 px the header stacks vertically and the toggle aligns to the right
themeToggleDOM reference added alongside other element refsinitializeTheme()— readslocalStorage.getItem('theme'), defaults to'dark'toggleTheme()— reads the currentdata-themeattribute ondocument.documentElementand callssetTheme()with the opposite valuesetTheme(theme)— sets/removesdata-theme="light"on<html>, updatesaria-label, persists tolocalStorage- Keyboard shortcut
Ctrl/Cmd + Shift + Talso callstoggleTheme()
| Variable | Value |
|---|---|
--background |
#0f172a |
--surface |
#1e293b |
--surface-hover |
#334155 |
--text-primary |
#f1f5f9 |
--text-secondary |
#94a3b8 |
--border-color |
#334155 |
--shadow |
rgba(0,0,0,0.3) |
| Variable | Value |
|---|---|
--background |
#ffffff |
--surface |
#f8fafc |
--surface-hover |
#e2e8f0 |
--text-primary |
#1e293b |
--text-secondary |
#64748b |
--border-color |
#e2e8f0 |
--shadow |
rgba(0,0,0,0.1) |
Both themes share --primary-color: #2563eb, --primary-hover: #1d4ed8, --user-message: #2563eb, and --radius: 12px.
- Toggle button in top-right corner of header
- Sun (dark mode) / Moon (light mode) SVG icon pair with rotation + opacity animation
- Smooth 0.3 s transitions on all theme-sensitive properties
-
data-themeattribute on<html>element drives all CSS variable overrides - Theme preference persisted in
localStorage; dark is the default for new visitors -
aria-labelupdates dynamically ("Switch to light/dark theme") - Keyboard shortcut:
Ctrl/Cmd + Shift + T - Responsive layout — button remains accessible at all viewport sizes