Docs: backfill JSDoc, utility docs, and CLAUDE.md API/schema sections
- Add JSDoc to paychecks.js helpers: buildVirtualPaychecks, generatePaychecks, fetchPaychecksForMonth - Add JSDoc to financing.js helpers: remainingPeriods, calcPaymentAmount, enrichPlan - Add JSDoc to validateBillFields (bills.js) and getAllConfig (config.js) - Add JSDoc to ThemeProvider and useTheme in ThemeContext.jsx - Add Database Schema reference table to CLAUDE.md - Add complete API Endpoints reference section to CLAUDE.md covering all routes Nightshift-Task: docs-backfill Nightshift-Ref: https://github.com/marcus/nightshift
This commit is contained in:
@@ -2,6 +2,18 @@ import { createContext, useContext, useEffect, useState } from 'react';
|
||||
|
||||
const ThemeContext = createContext(null);
|
||||
|
||||
/**
|
||||
* Provides light/dark theme state to the component tree.
|
||||
*
|
||||
* On mount, the active theme is read from `localStorage`; if absent it
|
||||
* falls back to the OS `prefers-color-scheme` media query. The chosen
|
||||
* theme is applied as a `data-theme` attribute on `<html>` and persisted
|
||||
* to `localStorage` whenever it changes.
|
||||
*
|
||||
* Exposes `{ theme, toggle }` via {@link useTheme}.
|
||||
*
|
||||
* @param {{ children: React.ReactNode }} props
|
||||
*/
|
||||
export function ThemeProvider({ children }) {
|
||||
const [theme, setTheme] = useState(() => {
|
||||
const stored = localStorage.getItem('theme');
|
||||
@@ -25,6 +37,13 @@ export function ThemeProvider({ children }) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current theme context provided by {@link ThemeProvider}.
|
||||
*
|
||||
* @returns {{ theme: 'light'|'dark', toggle: () => void }}
|
||||
* - `theme` — the active color scheme name
|
||||
* - `toggle` — flips between `'light'` and `'dark'`
|
||||
*/
|
||||
export function useTheme() {
|
||||
return useContext(ThemeContext);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user