2025-12-07 11:32:07 -07:00
|
|
|
import React, {useContext, useEffect, useState, forwardRef, HTMLAttributes, CSSProperties} from 'react';
|
|
|
|
|
import {ThemeContext} from "../contexts/contexts";
|
|
|
|
|
import {
|
|
|
|
|
Accordion as SAccordion,
|
2026-03-05 16:18:03 -07:00
|
|
|
AccordionContent as SAccordionContent,
|
|
|
|
|
AccordionTitle as SAccordionTitle,
|
2025-12-07 11:32:07 -07:00
|
|
|
Breadcrumb as SBreadcrumb,
|
|
|
|
|
Button as SButton,
|
2026-02-20 14:37:58 -07:00
|
|
|
ButtonGroup as SButtonGroup,
|
2025-12-07 11:32:07 -07:00
|
|
|
Card as SCard,
|
|
|
|
|
Divider as SDivider,
|
|
|
|
|
Form as SForm,
|
|
|
|
|
FormField as SFormField,
|
|
|
|
|
FormGroup as SFormGroup,
|
|
|
|
|
FormInput as SFormInput,
|
|
|
|
|
Header as SHeader,
|
|
|
|
|
Icon as SIcon,
|
Add ordered collections (playlists): polymorphic items + item API (#475)
* Add Playlists: ordered, mixed-type collections
A playlist (Collection kind='playlist') is a manually-curated, ordered list that
mixes item types. Squash of the playlists feature branch (24 commits).
Data model & API:
- CollectionItem is polymorphic via item_kind: 'file' (FileGroup), 'zim'
(zim_id + zim_entry), or 'url' (link to anything the WROLPi browser opens,
e.g. /map?lat=&lon=&z=). CHECK constraint enforces exactly one kind; per-kind
unique constraints; migration a7b1c2d3e4f5.
- Endpoints: create playlist; add/remove/reorder items (idempotent adds: 201 new,
200 existing); GET returns the ordered items. All mutations wrol_mode_check'd.
Config (source of truth):
- playlists.yaml (PlaylistsConfig) stores each playlist's metadata AND ordered
items (file by relative path, zim by path+entry, url inline); round-trips a
DB wipe. Supports backup import (DB_CONFIG_FILE_NAMES).
- The redundant generic CollectionsConfig (collections.yaml) is deleted:
channels/domains own their configs, authors/subjects are re-derived.
On-disk sync (sync_playlists_directory switch):
- Each playlist materializes into the configurable Playlists Directory
(playlists_destination, Settings UI input, excluded from indexing) with
position-prefixed entries: NNNN_<file> hard links (copy fallback across
filesystems) and NNNN_<title>.html stubs for zim/url items.
- Tagged playlists are namespaced like channels: <playlists>/<tag>/<name>;
a tag change moves the directory and prunes the empty old tag dir.
- Deletion safety: managed files are only removed when they are our marked
stubs or still have another hard link (st_nlink > 1) -- never a last copy.
Stray loose files at the playlists root are removed; stub URLs are
scheme-allowlisted (no javascript:/data:).
Frontend:
- /playlists list page (CollectionTable, name filter, New Playlist modal, Tag
column) between Files and Zim in the nav.
- View-only detail page (Name link) and edit page (Edit button): themed table
with model icons/colors + poster thumbnails, items link to their model page
(video/archive/doc) or preview, up/down reorder, remove, add-URL form,
single-tag selector; all editing disabled in WROL Mode.
- Reusable green "Add to Playlist" button on Video/Archive/Doc detail pages,
the FilePreview toolbar, Zim search results, and Map pins (added as a /map
URL item with a map-marker icon).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Playlist edit page parity: rename, custom directory, tag modal move suggestion
Match the ChannelEditPage/DomainEditPage UX on the playlist edit page:
Back/View buttons, an edit form (name, description, directory), and the
shared CollectionTagModal with the violet "Tag" button. The tag modal now
suggests moving the playlist to its managed tag location
(playlists/<tag>/<name>); accepting the suggestion stores directory=None so
the sync keeps auto-managing the location. Tag buttons on the Channel and
Domain edit pages are now violet to match.
Backend: update_collection learns rename (with per-kind validation and
duplicate checks) and playlist custom directories (cleanup of the abandoned
directory, config round-trip, commit-before-switch to avoid the background
sync racing pre-commit state). tag_collection's duplicated untag/tag
branches are merged, and the per-kind config-save dispatch is consolidated
into _activate_config_save().
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Deduplicate Collection error handling and Tag creation
Delete the duplicate UnknownCollection in wrolpi/collections/errors.py and
re-export the canonical one from wrolpi/errors.py, which carries
status_code=NOT_FOUND (the local copy inherited 500). Replace the repeated
query/raise pattern in reorganize.py with Collection.find_by_id.
Add Tag.get_or_create_tag and use it for collection tagging; flush the new
Tag before returning so callers can read .id immediately -- previously
tagging a collection with a brand-new tag name set tag_id=None. Regression
test included.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 19:37:34 -06:00
|
|
|
List as SList,
|
|
|
|
|
ListContent as SListContent,
|
|
|
|
|
ListDescription as SListDescription,
|
|
|
|
|
ListHeader as SListHeader,
|
|
|
|
|
ListIcon as SListIcon,
|
|
|
|
|
ListItem as SListItem,
|
2025-12-07 11:32:07 -07:00
|
|
|
Loader as SLoader,
|
|
|
|
|
Menu as SMenu,
|
Rebuild Inventory as a config-only system with food catalog and calculators
Replace the DB-backed inventory module with a config-only design and build out
food-storage tooling around it.
Inventory (config-only, no database)
- Each inventory is a YAML file at config/inventory/<slug>.yaml, loaded once
into memory and the single source of truth. New reusable MultiFileConfig
(wrolpi/common.py) manages a directory of per-entity files.
- Inventory types (food/fuel/tool) seed a customizable field schema
(text/number/quantity/date/select/location/calories). Unit math/aggregation
moved to the frontend (mathjs); Pint dropped from the backend.
- Minimal API: GET / (all inventories full), POST /, PUT /<slug> (whole-
inventory save with version-based optimistic concurrency; 404 for missing),
DELETE. Legacy inventories.yaml / old tables migrate to per-inventory files
(pound->lb), and an alembic migration drops the tables.
Frontend
- New app/src/components/inventory/ package: spreadsheet-style table with
Tab/Enter keyboard entry, sortable columns, expired-row highlighting,
customizable field editor, and pooled cross-inventory location autocomplete.
- A single useInventories store loads everything once and persists whole
inventories optimistically; list/items/summary/locations derive client-side.
- Summary groups items (default by Category), totals size x count, shows a
calories column, and embeds a ration estimate (how long the stock lasts).
Food catalog
- Shared, editable catalog (config/inventory/catalog.yaml) seeded from
catalog_defaults.yaml (~60 generic items, total calories per package) with
merge-keep-edits + tombstones. GET/PUT /api/inventory/catalog, a management
modal, and entry-row pre-fill of category/size/calories from a name match.
Calculators
- Generic Food Storage planner (like the Water calculator): household +
editable per-person/year amounts -> total to store over a chosen duration,
with women/children weighted by DGA calorie shares and an imperial/metric
toggle.
Also fixes ConfigFile.save() to accept nested file_names. Backend pytest and
frontend jest suites updated/added throughout; alembic check clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 14:20:10 -06:00
|
|
|
MenuItem as SMenuItem,
|
|
|
|
|
MenuHeader as SMenuHeader,
|
|
|
|
|
MenuMenu as SMenuMenu,
|
2025-12-07 11:32:07 -07:00
|
|
|
Modal as SModal,
|
|
|
|
|
ModalActions as SModalActions,
|
|
|
|
|
ModalContent as SModalContent,
|
|
|
|
|
ModalDescription as SModalDescription,
|
|
|
|
|
ModalHeader as SModalHeader,
|
|
|
|
|
Placeholder as SPlaceholder,
|
|
|
|
|
Popup as SPopup,
|
|
|
|
|
Progress as SProgress,
|
2026-07-20 11:38:17 -06:00
|
|
|
Ref as SRef,
|
2025-12-07 11:32:07 -07:00
|
|
|
Segment as SSegment,
|
|
|
|
|
Statistic as SStatistic,
|
|
|
|
|
StatisticGroup as SStatisticGroup,
|
|
|
|
|
Tab as STab,
|
|
|
|
|
Table as STable,
|
2025-12-11 18:32:55 -07:00
|
|
|
TableBody as STableBody,
|
|
|
|
|
TableCell as STableCell,
|
|
|
|
|
TableFooter as STableFooter,
|
|
|
|
|
TableHeader as STableHeader,
|
|
|
|
|
TableHeaderCell as STableHeaderCell,
|
|
|
|
|
TableRow as STableRow,
|
2025-12-07 11:32:07 -07:00
|
|
|
TabPane as STabPane,
|
|
|
|
|
TextArea as STextArea,
|
2026-03-05 16:18:03 -07:00
|
|
|
AccordionContentProps,
|
2025-12-07 11:32:07 -07:00
|
|
|
AccordionProps,
|
2026-03-05 16:18:03 -07:00
|
|
|
AccordionTitleProps,
|
2025-12-07 11:32:07 -07:00
|
|
|
BreadcrumbProps,
|
|
|
|
|
ButtonProps,
|
2026-02-20 14:37:58 -07:00
|
|
|
ButtonGroupProps,
|
2025-12-07 11:32:07 -07:00
|
|
|
CardProps as SCardProps,
|
|
|
|
|
DividerProps,
|
|
|
|
|
FormProps,
|
|
|
|
|
FormFieldProps,
|
|
|
|
|
FormGroupProps,
|
|
|
|
|
FormInputProps,
|
|
|
|
|
HeaderProps,
|
|
|
|
|
IconProps,
|
Add ordered collections (playlists): polymorphic items + item API (#475)
* Add Playlists: ordered, mixed-type collections
A playlist (Collection kind='playlist') is a manually-curated, ordered list that
mixes item types. Squash of the playlists feature branch (24 commits).
Data model & API:
- CollectionItem is polymorphic via item_kind: 'file' (FileGroup), 'zim'
(zim_id + zim_entry), or 'url' (link to anything the WROLPi browser opens,
e.g. /map?lat=&lon=&z=). CHECK constraint enforces exactly one kind; per-kind
unique constraints; migration a7b1c2d3e4f5.
- Endpoints: create playlist; add/remove/reorder items (idempotent adds: 201 new,
200 existing); GET returns the ordered items. All mutations wrol_mode_check'd.
Config (source of truth):
- playlists.yaml (PlaylistsConfig) stores each playlist's metadata AND ordered
items (file by relative path, zim by path+entry, url inline); round-trips a
DB wipe. Supports backup import (DB_CONFIG_FILE_NAMES).
- The redundant generic CollectionsConfig (collections.yaml) is deleted:
channels/domains own their configs, authors/subjects are re-derived.
On-disk sync (sync_playlists_directory switch):
- Each playlist materializes into the configurable Playlists Directory
(playlists_destination, Settings UI input, excluded from indexing) with
position-prefixed entries: NNNN_<file> hard links (copy fallback across
filesystems) and NNNN_<title>.html stubs for zim/url items.
- Tagged playlists are namespaced like channels: <playlists>/<tag>/<name>;
a tag change moves the directory and prunes the empty old tag dir.
- Deletion safety: managed files are only removed when they are our marked
stubs or still have another hard link (st_nlink > 1) -- never a last copy.
Stray loose files at the playlists root are removed; stub URLs are
scheme-allowlisted (no javascript:/data:).
Frontend:
- /playlists list page (CollectionTable, name filter, New Playlist modal, Tag
column) between Files and Zim in the nav.
- View-only detail page (Name link) and edit page (Edit button): themed table
with model icons/colors + poster thumbnails, items link to their model page
(video/archive/doc) or preview, up/down reorder, remove, add-URL form,
single-tag selector; all editing disabled in WROL Mode.
- Reusable green "Add to Playlist" button on Video/Archive/Doc detail pages,
the FilePreview toolbar, Zim search results, and Map pins (added as a /map
URL item with a map-marker icon).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Playlist edit page parity: rename, custom directory, tag modal move suggestion
Match the ChannelEditPage/DomainEditPage UX on the playlist edit page:
Back/View buttons, an edit form (name, description, directory), and the
shared CollectionTagModal with the violet "Tag" button. The tag modal now
suggests moving the playlist to its managed tag location
(playlists/<tag>/<name>); accepting the suggestion stores directory=None so
the sync keeps auto-managing the location. Tag buttons on the Channel and
Domain edit pages are now violet to match.
Backend: update_collection learns rename (with per-kind validation and
duplicate checks) and playlist custom directories (cleanup of the abandoned
directory, config round-trip, commit-before-switch to avoid the background
sync racing pre-commit state). tag_collection's duplicated untag/tag
branches are merged, and the per-kind config-save dispatch is consolidated
into _activate_config_save().
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Deduplicate Collection error handling and Tag creation
Delete the duplicate UnknownCollection in wrolpi/collections/errors.py and
re-export the canonical one from wrolpi/errors.py, which carries
status_code=NOT_FOUND (the local copy inherited 500). Replace the repeated
query/raise pattern in reorganize.py with Collection.find_by_id.
Add Tag.get_or_create_tag and use it for collection tagging; flush the new
Tag before returning so callers can read .id immediately -- previously
tagging a collection with a brand-new tag name set tag_id=None. Regression
test included.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 19:37:34 -06:00
|
|
|
ListProps,
|
|
|
|
|
ListItemProps,
|
|
|
|
|
ListIconProps,
|
|
|
|
|
ListContentProps,
|
|
|
|
|
ListHeaderProps,
|
|
|
|
|
ListDescriptionProps,
|
2025-12-07 11:32:07 -07:00
|
|
|
LoaderProps,
|
|
|
|
|
MenuProps,
|
Rebuild Inventory as a config-only system with food catalog and calculators
Replace the DB-backed inventory module with a config-only design and build out
food-storage tooling around it.
Inventory (config-only, no database)
- Each inventory is a YAML file at config/inventory/<slug>.yaml, loaded once
into memory and the single source of truth. New reusable MultiFileConfig
(wrolpi/common.py) manages a directory of per-entity files.
- Inventory types (food/fuel/tool) seed a customizable field schema
(text/number/quantity/date/select/location/calories). Unit math/aggregation
moved to the frontend (mathjs); Pint dropped from the backend.
- Minimal API: GET / (all inventories full), POST /, PUT /<slug> (whole-
inventory save with version-based optimistic concurrency; 404 for missing),
DELETE. Legacy inventories.yaml / old tables migrate to per-inventory files
(pound->lb), and an alembic migration drops the tables.
Frontend
- New app/src/components/inventory/ package: spreadsheet-style table with
Tab/Enter keyboard entry, sortable columns, expired-row highlighting,
customizable field editor, and pooled cross-inventory location autocomplete.
- A single useInventories store loads everything once and persists whole
inventories optimistically; list/items/summary/locations derive client-side.
- Summary groups items (default by Category), totals size x count, shows a
calories column, and embeds a ration estimate (how long the stock lasts).
Food catalog
- Shared, editable catalog (config/inventory/catalog.yaml) seeded from
catalog_defaults.yaml (~60 generic items, total calories per package) with
merge-keep-edits + tombstones. GET/PUT /api/inventory/catalog, a management
modal, and entry-row pre-fill of category/size/calories from a name match.
Calculators
- Generic Food Storage planner (like the Water calculator): household +
editable per-person/year amounts -> total to store over a chosen duration,
with women/children weighted by DGA calorie shares and an imperial/metric
toggle.
Also fixes ConfigFile.save() to accept nested file_names. Backend pytest and
frontend jest suites updated/added throughout; alembic check clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 14:20:10 -06:00
|
|
|
MenuItemProps,
|
|
|
|
|
MenuMenuProps,
|
2025-12-07 11:32:07 -07:00
|
|
|
ModalProps,
|
|
|
|
|
ModalActionsProps,
|
|
|
|
|
ModalContentProps,
|
|
|
|
|
ModalDescriptionProps,
|
|
|
|
|
ModalHeaderProps,
|
|
|
|
|
PlaceholderProps,
|
|
|
|
|
PopupProps,
|
|
|
|
|
ProgressProps,
|
|
|
|
|
SegmentProps,
|
|
|
|
|
StatisticProps,
|
|
|
|
|
StatisticGroupProps,
|
|
|
|
|
TabProps,
|
|
|
|
|
TableProps,
|
2025-12-11 18:32:55 -07:00
|
|
|
TableBodyProps,
|
|
|
|
|
TableCellProps,
|
|
|
|
|
TableFooterProps,
|
|
|
|
|
TableHeaderProps,
|
|
|
|
|
TableHeaderCellProps,
|
|
|
|
|
TableRowProps,
|
2025-12-07 11:32:07 -07:00
|
|
|
TabPaneProps,
|
|
|
|
|
TextAreaProps,
|
|
|
|
|
} from "semantic-ui-react";
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
import {MantineProvider} from "@mantine/core";
|
|
|
|
|
import {Notifications} from "@mantine/notifications";
|
|
|
|
|
import {cssVariablesResolver, mantineTheme} from "../themes/mantine";
|
ui: theme picker in Settings, and ship the component gallery
The gallery at /theme-sample is now a normal route rather than a development
one, and Settings links to it, so a user can see what a theme actually looks
like before committing to it. Every new component belongs in the gallery: it is
how the design gets reviewed, and how a component that only looks wrong in one
of the four themes gets caught.
Settings gains a Theme section with the new ThemePicker, which explains what
each theme is for - notably that night mode filters videos, documents and maps
to red as well, not just the interface.
Theme names and picker options move to themes/names.ts so the component library
can read them without importing components/Theme.tsx, which still pulls in
Semantic UI. Theme.tsx re-exports them, so existing call sites are unchanged.
The navigation bar's compact picker now reads the same list, so the two cannot
drift apart.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:38:04 -06:00
|
|
|
import {
|
|
|
|
|
amberTheme,
|
|
|
|
|
darkTheme,
|
|
|
|
|
defaultTheme,
|
|
|
|
|
explicitOnlyThemes,
|
|
|
|
|
isDarkTheme,
|
|
|
|
|
isThemeName,
|
|
|
|
|
lightTheme,
|
|
|
|
|
nightTheme,
|
|
|
|
|
systemTheme,
|
|
|
|
|
themeChoices,
|
|
|
|
|
themeNames,
|
|
|
|
|
themeSessionKey,
|
|
|
|
|
} from "../themes/names";
|
2025-12-25 16:03:09 -07:00
|
|
|
import {ColorToSemanticHexColor} from "./Vars";
|
2025-12-07 11:32:07 -07:00
|
|
|
import _ from "lodash";
|
|
|
|
|
import {ThemeContextValue, ThemeName, SavedThemeName} from "../types/theme";
|
|
|
|
|
|
ui: theme picker in Settings, and ship the component gallery
The gallery at /theme-sample is now a normal route rather than a development
one, and Settings links to it, so a user can see what a theme actually looks
like before committing to it. Every new component belongs in the gallery: it is
how the design gets reviewed, and how a component that only looks wrong in one
of the four themes gets caught.
Settings gains a Theme section with the new ThemePicker, which explains what
each theme is for - notably that night mode filters videos, documents and maps
to red as well, not just the interface.
Theme names and picker options move to themes/names.ts so the component library
can read them without importing components/Theme.tsx, which still pulls in
Semantic UI. Theme.tsx re-exports them, so existing call sites are unchanged.
The navigation bar's compact picker now reads the same list, so the two cannot
drift apart.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:38:04 -06:00
|
|
|
// Theme names and picker choices live in themes/names so the component library can use
|
|
|
|
|
// them without importing this module (which still pulls in Semantic UI). Re-exported
|
|
|
|
|
// here because most call sites already import them from Theme.
|
|
|
|
|
export {
|
|
|
|
|
amberTheme,
|
|
|
|
|
darkTheme,
|
|
|
|
|
defaultTheme,
|
|
|
|
|
isDarkTheme,
|
|
|
|
|
lightTheme,
|
|
|
|
|
nightTheme,
|
|
|
|
|
systemTheme,
|
|
|
|
|
themeChoices,
|
|
|
|
|
themeNames,
|
|
|
|
|
themeSessionKey,
|
|
|
|
|
};
|
ui: theme tokens and a four-theme runtime
Every color now resolves through CSS custom properties on
html[data-theme=...], so a theme is a table of values rather than code.
Four themes ship: light, dark, night (red hues only, to preserve dark
adaptation off-grid) and amber (monochrome amber terminal).
Fonts are exposed as two roles, --font-body and --font-mono, which a theme
assigns a bundled face to; amber uses the mono face. Faces must be
self-hosted, never fetched from a CDN, so the app keeps working offline.
Night mode also filters media that cannot consume tokens - video, images,
PDFs, embedded pages, canvases - through an SVG color matrix that maps
luminance onto the red channel. Tag such an element with `.media`; a filter
on an app-level ancestor would create a containing block and break fixed
positioning.
ThemeProvider persists the choice and index.html stamps data-theme from
localStorage before the bundle loads, so the first paint already matches the
saved theme on a slow connection. The OS preference is followed only while
"system" is selected; night and amber are explicit choices. The nav toggle
becomes a five-item picker.
Semantic components still render themselves, so only the shell is
token-driven for now; the inverted props stay in place until each component
is migrated.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 18:32:50 -06:00
|
|
|
|
|
|
|
|
/** Resolve the saved preference to the theme that should be applied right now. */
|
|
|
|
|
export const resolveTheme = (saved: SavedThemeName): ThemeName => {
|
|
|
|
|
if (isThemeName(saved)) {
|
|
|
|
|
return saved;
|
|
|
|
|
}
|
|
|
|
|
// `system`, null, or a value written by an older version.
|
|
|
|
|
const prefersDark = typeof window.matchMedia === 'function'
|
|
|
|
|
&& window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
|
|
|
return prefersDark ? darkTheme : lightTheme;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const readSavedTheme = (): SavedThemeName => {
|
|
|
|
|
try {
|
|
|
|
|
const value = localStorage.getItem(themeSessionKey);
|
|
|
|
|
if (isThemeName(value) || value === systemTheme) {
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// localStorage can throw when cookies/storage are blocked.
|
|
|
|
|
console.error('Unable to read the saved theme', e);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-07 11:32:07 -07:00
|
|
|
interface ThemeProviderProps {
|
|
|
|
|
children: React.ReactNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function ThemeProvider({children, ...props}: ThemeProviderProps) {
|
|
|
|
|
if (!_.isEmpty(props)) {
|
|
|
|
|
console.log(props);
|
|
|
|
|
console.error('ThemeWrapper does not support props!');
|
|
|
|
|
}
|
|
|
|
|
|
ui: theme tokens and a four-theme runtime
Every color now resolves through CSS custom properties on
html[data-theme=...], so a theme is a table of values rather than code.
Four themes ship: light, dark, night (red hues only, to preserve dark
adaptation off-grid) and amber (monochrome amber terminal).
Fonts are exposed as two roles, --font-body and --font-mono, which a theme
assigns a bundled face to; amber uses the mono face. Faces must be
self-hosted, never fetched from a CDN, so the app keeps working offline.
Night mode also filters media that cannot consume tokens - video, images,
PDFs, embedded pages, canvases - through an SVG color matrix that maps
luminance onto the red channel. Tag such an element with `.media`; a filter
on an app-level ancestor would create a containing block and break fixed
positioning.
ThemeProvider persists the choice and index.html stamps data-theme from
localStorage before the bundle loads, so the first paint already matches the
saved theme on a slow connection. The OS preference is followed only while
"system" is selected; night and amber are explicit choices. The nav toggle
becomes a five-item picker.
Semantic components still render themselves, so only the shell is
token-driven for now; the inverted props stay in place until each component
is migrated.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 18:32:50 -06:00
|
|
|
// savedTheme is the user's preference: a theme name, `system`, or null (never chosen).
|
|
|
|
|
const [savedTheme, setSavedTheme] = useState<SavedThemeName>(readSavedTheme);
|
|
|
|
|
// theme is what is currently applied.
|
|
|
|
|
const [theme, setThemeName] = useState<ThemeName>(() => resolveTheme(readSavedTheme()));
|
2025-12-07 11:32:07 -07:00
|
|
|
|
ui: theme tokens and a four-theme runtime
Every color now resolves through CSS custom properties on
html[data-theme=...], so a theme is a table of values rather than code.
Four themes ship: light, dark, night (red hues only, to preserve dark
adaptation off-grid) and amber (monochrome amber terminal).
Fonts are exposed as two roles, --font-body and --font-mono, which a theme
assigns a bundled face to; amber uses the mono face. Faces must be
self-hosted, never fetched from a CDN, so the app keeps working offline.
Night mode also filters media that cannot consume tokens - video, images,
PDFs, embedded pages, canvases - through an SVG color matrix that maps
luminance onto the red channel. Tag such an element with `.media`; a filter
on an app-level ancestor would create a containing block and break fixed
positioning.
ThemeProvider persists the choice and index.html stamps data-theme from
localStorage before the bundle loads, so the first paint already matches the
saved theme on a slow connection. The OS preference is followed only while
"system" is selected; night and amber are explicit choices. The nav toggle
becomes a five-item picker.
Semantic components still render themselves, so only the shell is
token-driven for now; the inverted props stay in place until each component
is migrated.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 18:32:50 -06:00
|
|
|
// `data-theme` on <html> is what the token CSS keys off of. index.html stamps it before
|
|
|
|
|
// first paint from the same localStorage value, so the first render already matches.
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
document.documentElement.setAttribute('data-theme', theme);
|
|
|
|
|
}, [theme]);
|
|
|
|
|
|
|
|
|
|
// Follow the OS preference only while the user has not chosen a specific theme.
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (isThemeName(savedTheme) || typeof window.matchMedia !== 'function') {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const query = window.matchMedia('(prefers-color-scheme: dark)');
|
|
|
|
|
const onChange = () => setThemeName(resolveTheme(savedTheme));
|
|
|
|
|
query.addEventListener('change', onChange);
|
|
|
|
|
return () => query.removeEventListener('change', onChange);
|
|
|
|
|
}, [savedTheme]);
|
|
|
|
|
|
|
|
|
|
const saveTheme = (value: SavedThemeName) => {
|
|
|
|
|
setSavedTheme(value);
|
|
|
|
|
try {
|
|
|
|
|
if (value === null) {
|
|
|
|
|
localStorage.removeItem(themeSessionKey);
|
|
|
|
|
} else {
|
|
|
|
|
localStorage.setItem(themeSessionKey, value);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('Unable to save the theme', e);
|
2025-12-07 11:32:07 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
ui: theme tokens and a four-theme runtime
Every color now resolves through CSS custom properties on
html[data-theme=...], so a theme is a table of values rather than code.
Four themes ship: light, dark, night (red hues only, to preserve dark
adaptation off-grid) and amber (monochrome amber terminal).
Fonts are exposed as two roles, --font-body and --font-mono, which a theme
assigns a bundled face to; amber uses the mono face. Faces must be
self-hosted, never fetched from a CDN, so the app keeps working offline.
Night mode also filters media that cannot consume tokens - video, images,
PDFs, embedded pages, canvases - through an SVG color matrix that maps
luminance onto the red channel. Tag such an element with `.media`; a filter
on an app-level ancestor would create a containing block and break fixed
positioning.
ThemeProvider persists the choice and index.html stamps data-theme from
localStorage before the bundle loads, so the first paint already matches the
saved theme on a slow connection. The OS preference is followed only while
"system" is selected; night and amber are explicit choices. The nav toggle
becomes a five-item picker.
Semantic components still render themselves, so only the shell is
token-driven for now; the inverted props stay in place until each component
is migrated.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 18:32:50 -06:00
|
|
|
/** Apply and persist a theme. Pass `system` to follow the OS preference. */
|
|
|
|
|
const setTheme = (value: SavedThemeName) => {
|
|
|
|
|
if (value !== systemTheme && value !== null && !isThemeName(value)) {
|
|
|
|
|
console.error(`Unknown theme! ${value}`);
|
|
|
|
|
return;
|
2025-12-07 11:32:07 -07:00
|
|
|
}
|
ui: theme tokens and a four-theme runtime
Every color now resolves through CSS custom properties on
html[data-theme=...], so a theme is a table of values rather than code.
Four themes ship: light, dark, night (red hues only, to preserve dark
adaptation off-grid) and amber (monochrome amber terminal).
Fonts are exposed as two roles, --font-body and --font-mono, which a theme
assigns a bundled face to; amber uses the mono face. Faces must be
self-hosted, never fetched from a CDN, so the app keeps working offline.
Night mode also filters media that cannot consume tokens - video, images,
PDFs, embedded pages, canvases - through an SVG color matrix that maps
luminance onto the red channel. Tag such an element with `.media`; a filter
on an app-level ancestor would create a containing block and break fixed
positioning.
ThemeProvider persists the choice and index.html stamps data-theme from
localStorage before the bundle loads, so the first paint already matches the
saved theme on a slow connection. The OS preference is followed only while
"system" is selected; night and amber are explicit choices. The nav toggle
becomes a five-item picker.
Semantic components still render themselves, so only the shell is
token-driven for now; the inverted props stay in place until each component
is migrated.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 18:32:50 -06:00
|
|
|
saveTheme(value);
|
|
|
|
|
setThemeName(resolveTheme(value));
|
2025-12-07 11:32:07 -07:00
|
|
|
}
|
|
|
|
|
|
ui: theme tokens and a four-theme runtime
Every color now resolves through CSS custom properties on
html[data-theme=...], so a theme is a table of values rather than code.
Four themes ship: light, dark, night (red hues only, to preserve dark
adaptation off-grid) and amber (monochrome amber terminal).
Fonts are exposed as two roles, --font-body and --font-mono, which a theme
assigns a bundled face to; amber uses the mono face. Faces must be
self-hosted, never fetched from a CDN, so the app keeps working offline.
Night mode also filters media that cannot consume tokens - video, images,
PDFs, embedded pages, canvases - through an SVG color matrix that maps
luminance onto the red channel. Tag such an element with `.media`; a filter
on an app-level ancestor would create a containing block and break fixed
positioning.
ThemeProvider persists the choice and index.html stamps data-theme from
localStorage before the bundle loads, so the first paint already matches the
saved theme on a slow connection. The OS preference is followed only while
"system" is selected; night and amber are explicit choices. The nav toggle
becomes a five-item picker.
Semantic components still render themselves, so only the shell is
token-driven for now; the inverted props stay in place until each component
is migrated.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 18:32:50 -06:00
|
|
|
// Retained for callers written against the old two-theme API.
|
|
|
|
|
const setDarkTheme = (save = false) => {
|
|
|
|
|
setThemeName(darkTheme);
|
|
|
|
|
if (save) saveTheme(darkTheme);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const setLightTheme = (save = false) => {
|
|
|
|
|
setThemeName(lightTheme);
|
|
|
|
|
if (save) saveTheme(lightTheme);
|
2025-12-07 11:32:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const cycleSavedTheme = (e?: React.MouseEvent) => {
|
ui: theme tokens and a four-theme runtime
Every color now resolves through CSS custom properties on
html[data-theme=...], so a theme is a table of values rather than code.
Four themes ship: light, dark, night (red hues only, to preserve dark
adaptation off-grid) and amber (monochrome amber terminal).
Fonts are exposed as two roles, --font-body and --font-mono, which a theme
assigns a bundled face to; amber uses the mono face. Faces must be
self-hosted, never fetched from a CDN, so the app keeps working offline.
Night mode also filters media that cannot consume tokens - video, images,
PDFs, embedded pages, canvases - through an SVG color matrix that maps
luminance onto the red channel. Tag such an element with `.media`; a filter
on an app-level ancestor would create a containing block and break fixed
positioning.
ThemeProvider persists the choice and index.html stamps data-theme from
localStorage before the bundle loads, so the first paint already matches the
saved theme on a slow connection. The OS preference is followed only while
"system" is selected; night and amber are explicit choices. The nav toggle
becomes a five-item picker.
Semantic components still render themselves, so only the shell is
token-driven for now; the inverted props stay in place until each component
is migrated.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 18:32:50 -06:00
|
|
|
// Cycle: System -> Light -> Dark -> Night -> Amber -> System
|
2025-12-07 11:32:07 -07:00
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
ui: theme tokens and a four-theme runtime
Every color now resolves through CSS custom properties on
html[data-theme=...], so a theme is a table of values rather than code.
Four themes ship: light, dark, night (red hues only, to preserve dark
adaptation off-grid) and amber (monochrome amber terminal).
Fonts are exposed as two roles, --font-body and --font-mono, which a theme
assigns a bundled face to; amber uses the mono face. Faces must be
self-hosted, never fetched from a CDN, so the app keeps working offline.
Night mode also filters media that cannot consume tokens - video, images,
PDFs, embedded pages, canvases - through an SVG color matrix that maps
luminance onto the red channel. Tag such an element with `.media`; a filter
on an app-level ancestor would create a containing block and break fixed
positioning.
ThemeProvider persists the choice and index.html stamps data-theme from
localStorage before the bundle loads, so the first paint already matches the
saved theme on a slow connection. The OS preference is followed only while
"system" is selected; night and amber are explicit choices. The nav toggle
becomes a five-item picker.
Semantic components still render themselves, so only the shell is
token-driven for now; the inverted props stay in place until each component
is migrated.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 18:32:50 -06:00
|
|
|
const order: SavedThemeName[] = [systemTheme, ...themeNames];
|
|
|
|
|
const current = order.indexOf(isThemeName(savedTheme) ? savedTheme : systemTheme);
|
|
|
|
|
setTheme(order[(current + 1) % order.length]);
|
2025-12-07 11:32:07 -07:00
|
|
|
}
|
|
|
|
|
|
ui: theme tokens and a four-theme runtime
Every color now resolves through CSS custom properties on
html[data-theme=...], so a theme is a table of values rather than code.
Four themes ship: light, dark, night (red hues only, to preserve dark
adaptation off-grid) and amber (monochrome amber terminal).
Fonts are exposed as two roles, --font-body and --font-mono, which a theme
assigns a bundled face to; amber uses the mono face. Faces must be
self-hosted, never fetched from a CDN, so the app keeps working offline.
Night mode also filters media that cannot consume tokens - video, images,
PDFs, embedded pages, canvases - through an SVG color matrix that maps
luminance onto the red channel. Tag such an element with `.media`; a filter
on an app-level ancestor would create a containing block and break fixed
positioning.
ThemeProvider persists the choice and index.html stamps data-theme from
localStorage before the bundle loads, so the first paint already matches the
saved theme on a slow connection. The OS preference is followed only while
"system" is selected; night and amber are explicit choices. The nav toggle
becomes a five-item picker.
Semantic components still render themselves, so only the shell is
token-driven for now; the inverted props stay in place until each component
is migrated.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 18:32:50 -06:00
|
|
|
const dark = isDarkTheme(theme);
|
2025-12-07 11:32:07 -07:00
|
|
|
|
ui: theme tokens and a four-theme runtime
Every color now resolves through CSS custom properties on
html[data-theme=...], so a theme is a table of values rather than code.
Four themes ship: light, dark, night (red hues only, to preserve dark
adaptation off-grid) and amber (monochrome amber terminal).
Fonts are exposed as two roles, --font-body and --font-mono, which a theme
assigns a bundled face to; amber uses the mono face. Faces must be
self-hosted, never fetched from a CDN, so the app keeps working offline.
Night mode also filters media that cannot consume tokens - video, images,
PDFs, embedded pages, canvases - through an SVG color matrix that maps
luminance onto the red channel. Tag such an element with `.media`; a filter
on an app-level ancestor would create a containing block and break fixed
positioning.
ThemeProvider persists the choice and index.html stamps data-theme from
localStorage before the bundle loads, so the first paint already matches the
saved theme on a slow connection. The OS preference is followed only while
"system" is selected; night and amber are explicit choices. The nav toggle
becomes a five-item picker.
Semantic components still render themselves, so only the shell is
token-driven for now; the inverted props stay in place until each component
is migrated.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 18:32:50 -06:00
|
|
|
// Compatibility layer for components which have not been migrated to tokens yet. Semantic
|
|
|
|
|
// has no concept of the night/amber themes, so they reuse its dark treatment while pulling
|
|
|
|
|
// their colors from the tokens. These values disappear with the last Semantic component.
|
|
|
|
|
const i = dark ? {inverted: true} : {inverted: undefined};
|
|
|
|
|
const inverted = dark ? 'inverted' : '';
|
|
|
|
|
let s: {style?: CSSProperties} = {};
|
|
|
|
|
let t: {style?: CSSProperties} = {};
|
|
|
|
|
if (theme === darkTheme) {
|
|
|
|
|
s = {style: {backgroundColor: '#1B1C1D', color: '#dddddd'}};
|
|
|
|
|
t = {style: {color: '#eeeeee'}};
|
|
|
|
|
} else if (explicitOnlyThemes.includes(theme)) {
|
|
|
|
|
s = {style: {backgroundColor: 'var(--panel)', color: 'var(--text)'}};
|
|
|
|
|
t = {style: {color: 'var(--text)'}};
|
|
|
|
|
}
|
2025-12-07 11:32:07 -07:00
|
|
|
|
|
|
|
|
const themeValue: ThemeContextValue = {
|
|
|
|
|
i, // Used for Semantic elements which support "inverted".
|
|
|
|
|
s, // Used to invert the style some elements.
|
|
|
|
|
t, // Used to invert text.
|
|
|
|
|
inverted, // Used to add "invert" to className.
|
|
|
|
|
theme,
|
|
|
|
|
savedTheme,
|
ui: theme tokens and a four-theme runtime
Every color now resolves through CSS custom properties on
html[data-theme=...], so a theme is a table of values rather than code.
Four themes ship: light, dark, night (red hues only, to preserve dark
adaptation off-grid) and amber (monochrome amber terminal).
Fonts are exposed as two roles, --font-body and --font-mono, which a theme
assigns a bundled face to; amber uses the mono face. Faces must be
self-hosted, never fetched from a CDN, so the app keeps working offline.
Night mode also filters media that cannot consume tokens - video, images,
PDFs, embedded pages, canvases - through an SVG color matrix that maps
luminance onto the red channel. Tag such an element with `.media`; a filter
on an app-level ancestor would create a containing block and break fixed
positioning.
ThemeProvider persists the choice and index.html stamps data-theme from
localStorage before the bundle loads, so the first paint already matches the
saved theme on a slow connection. The OS preference is followed only while
"system" is selected; night and amber are explicit choices. The nav toggle
becomes a five-item picker.
Semantic components still render themselves, so only the shell is
token-driven for now; the inverted props stay in place until each component
is migrated.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 18:32:50 -06:00
|
|
|
isDark: dark,
|
|
|
|
|
setTheme,
|
2025-12-07 11:32:07 -07:00
|
|
|
setDarkTheme,
|
|
|
|
|
setLightTheme,
|
|
|
|
|
cycleSavedTheme,
|
|
|
|
|
};
|
|
|
|
|
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
// Mantine's own scheme decides the surfaces its internals use (overlays, scrollbars,
|
|
|
|
|
// focus rings). Night and amber are neither of its two schemes, so they ride on dark
|
|
|
|
|
// and take their actual colors from our tokens. This is the theme `base` flag.
|
2025-12-07 11:32:07 -07:00
|
|
|
return <ThemeContext.Provider value={themeValue}>
|
ui: token-driven component library on Mantine
Adds src/components/ui: buttons, messages, labels, progress, status, tables,
form controls, panels, cards, statistics, modals, tooltips, tabs, and icons.
Everything resolves its colors through theme tokens, so no component branches
on the current theme, and Semantic UI keeps rendering the app meanwhile.
Mantine is bridged rather than restyled: its own CSS variables are pointed at
our tokens. Four details were not obvious, and each caused a visible defect
in night mode before being fixed:
- Structural colors must go in the resolver's light/dark blocks. Mantine
emits its values under [data-mantine-color-scheme], which outranks the
:root block that `variables` becomes, so its grays were winning.
- The dark and gray palettes are mapped shade by shade to tokens. Mantine
reads them directly for table borders, zebra stripes and input chrome;
they can be neither flattened nor left alone.
- Mantine writes --button-* as inline styles, which no stylesheet can
outrank, so the dashed danger treatment sets real properties instead.
- Switch colors are written onto inner elements, so they need scoped CSS
rather than a variable on the root. Adds a --knob token for control
handles, because Mantine's default thumb follows theme.white, which is
near-black in the dark-based themes.
An audit of every painted pixel in the /theme-sample gallery now finds no
non-red channel in night mode.
Icons come from @tabler/icons-react with the 102 Semantic names the app uses
mapped to components; they stroke with currentColor, so they follow the theme
without any rule of their own. Toasts keep the react-semantic-toasts-2
signature so those call sites migrate by changing an import.
TypeScript 5 is required: Mantine's declarations use `const` type parameters,
which 4.9 cannot parse (Mantine 7 is the same, so downgrading is no escape).
That needs two npm overrides to keep clean installs working, both verified
against a Docker build: react-scripts declares peerOptional typescript ^3||^4,
and fork-ts-checker 6.5.2 assigns typescript.performance.mark, which TS 5
made getter-only - crashing the dev server's type checker on every rebuild.
semantic-baseline.test.js ratchets the removal: it fails if a file not already
listed imports Semantic UI. An ESLint rule would have printed 75 warnings per
rebuild, and CI unsets CI= for its build step, so it would guard nothing there.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 19:22:03 -06:00
|
|
|
<MantineProvider
|
|
|
|
|
theme={mantineTheme}
|
|
|
|
|
cssVariablesResolver={cssVariablesResolver}
|
|
|
|
|
forceColorScheme={dark ? 'dark' : 'light'}
|
|
|
|
|
>
|
|
|
|
|
<Notifications position='bottom-right' limit={5}/>
|
|
|
|
|
{children}
|
|
|
|
|
</MantineProvider>
|
2025-12-07 11:32:07 -07:00
|
|
|
</ThemeContext.Provider>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Simple wrappers for Semantic UI elements to use the current theme.
|
|
|
|
|
|
|
|
|
|
const invertedNull = <T extends {inverted?: boolean | null}>(props: T): T => {
|
|
|
|
|
if (props['inverted'] === true) {
|
|
|
|
|
return {...props, inverted: null};
|
|
|
|
|
}
|
|
|
|
|
return props;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const defaultGrey = <T extends object>(props: T, inverted: boolean): T => {
|
|
|
|
|
// Some elements look softer when grey, use grey only if another color is not provided.
|
|
|
|
|
if (inverted) {
|
|
|
|
|
return {color: 'grey', ...props} as T;
|
|
|
|
|
}
|
|
|
|
|
return props;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-05 16:18:03 -07:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
// Accordion Compound Component
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
type AccordionTitleComponent = React.FC<AccordionTitleProps>;
|
|
|
|
|
type AccordionContentComponent = React.FC<AccordionContentProps>;
|
|
|
|
|
|
|
|
|
|
interface AccordionComponent extends React.FC<AccordionProps> {
|
|
|
|
|
Title: AccordionTitleComponent;
|
|
|
|
|
Content: AccordionContentComponent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const AccordionTitle: AccordionTitleComponent = (props) => {
|
|
|
|
|
return <SAccordionTitle {...props}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const AccordionContent: AccordionContentComponent = (props) => {
|
|
|
|
|
return <SAccordionContent {...props}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const AccordionBase: React.FC<AccordionProps> = (props) => {
|
2025-12-07 11:32:07 -07:00
|
|
|
const {i, inverted} = useContext(ThemeContext);
|
|
|
|
|
const mergedProps = defaultGrey({...i, ...props}, !!inverted);
|
|
|
|
|
return <SAccordion {...mergedProps}/>
|
2026-03-05 16:18:03 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const Accordion: AccordionComponent = Object.assign(AccordionBase, {
|
|
|
|
|
Title: AccordionTitle,
|
|
|
|
|
Content: AccordionContent,
|
|
|
|
|
});
|
2025-12-07 11:32:07 -07:00
|
|
|
|
2026-02-20 14:37:58 -07:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
// Button Compound Component
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
type ButtonGroupComponent = React.FC<ButtonGroupProps>;
|
|
|
|
|
|
|
|
|
|
interface ButtonComponent extends React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<any>> {
|
|
|
|
|
Group: ButtonGroupComponent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ButtonGroup: ButtonGroupComponent = (props) => {
|
|
|
|
|
return <SButtonGroup {...props}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ButtonBase = forwardRef<any, ButtonProps>((props, ref) => {
|
2025-12-07 11:32:07 -07:00
|
|
|
const {i, inverted} = useContext(ThemeContext);
|
|
|
|
|
const mergedProps = defaultGrey({...i, ...props}, !!inverted);
|
2026-07-20 11:38:17 -06:00
|
|
|
// SButton is a class component, so a forwarded `ref` would resolve to the class instance rather than the DOM
|
|
|
|
|
// node. Semantic UI's Modal/Popup use the trigger's ref with `node.contains(...)`, which throws on a non-DOM
|
|
|
|
|
// value. Wrap in Ref (findDOMNode) so the forwarded ref always resolves to the underlying <button> element.
|
|
|
|
|
if (ref) {
|
|
|
|
|
return <SRef innerRef={ref}><SButton {...mergedProps}/></SRef>
|
|
|
|
|
}
|
|
|
|
|
return <SButton {...mergedProps}/>
|
2025-12-07 11:32:07 -07:00
|
|
|
});
|
2026-02-20 14:37:58 -07:00
|
|
|
ButtonBase.displayName = 'ButtonBase';
|
|
|
|
|
|
|
|
|
|
export const Button: ButtonComponent = Object.assign(ButtonBase, {
|
|
|
|
|
Group: ButtonGroup,
|
|
|
|
|
});
|
2025-12-07 11:32:07 -07:00
|
|
|
|
|
|
|
|
export function Divider(props: DividerProps) {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
return <SDivider {...i} {...props}/>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function Header(props: HeaderProps) {
|
|
|
|
|
const {t} = useContext(ThemeContext);
|
Add Drive Ratio calculator (pulleys, gears, sprockets)
A new "Drive Ratio" calculator under /more/calculators for belt, gear, and
chain-sprocket drives, supporting a compound train of 2–6 wheels on a single
shared belt/chain (constant size·rpm across the train).
- Pure, unit-tested math: size·rpm solver, ratio, torque, surface/belt speed,
belt length, sprocket pitch diameter, chain length, gear pitch diameter.
- Mode toggle (Pulley/Gear/Sprocket) with imperial/metric units; torque in
lb·ft or N·m.
- Add/remove wheels (2–6), each with a colorblind-friendly color shared between
its inputs and the schematic SVG diagram (Paul Tol bright palette).
- Dependency-free inline-SVG diagram: colored wheels threaded by one belt/chain,
or meshing gear teeth; auto-fitting viewBox.
- Per-mode details: belt/chain length and center distance (2-wheel only, with an
info popup), per-wheel pitch diameters, and constant train speed.
- Guards against impossible geometry (wheels overlapping) and ideal-torque note.
- Integer teeth enforced in gear/sprocket modes; pulley diameters stay continuous.
Also fix Theme.Header dropping the theme's text color when a caller passes a
`style` prop (now merges {...t.style, ...props.style}).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-28 15:01:34 -06:00
|
|
|
// Merge the caller's style on top of the theme's text style; a bare `{...props}`
|
|
|
|
|
// would let an incoming `style` prop replace (and drop) the theme's text color.
|
|
|
|
|
return <SHeader {...t} {...props} style={{...t.style, ...props.style}}/>
|
2025-12-07 11:32:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function Icon(props: IconProps) {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
return <SIcon {...i} {...props}/>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function Loader(props: LoaderProps) {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
return <SLoader {...i} {...props}/>
|
|
|
|
|
}
|
|
|
|
|
|
Rebuild Inventory as a config-only system with food catalog and calculators
Replace the DB-backed inventory module with a config-only design and build out
food-storage tooling around it.
Inventory (config-only, no database)
- Each inventory is a YAML file at config/inventory/<slug>.yaml, loaded once
into memory and the single source of truth. New reusable MultiFileConfig
(wrolpi/common.py) manages a directory of per-entity files.
- Inventory types (food/fuel/tool) seed a customizable field schema
(text/number/quantity/date/select/location/calories). Unit math/aggregation
moved to the frontend (mathjs); Pint dropped from the backend.
- Minimal API: GET / (all inventories full), POST /, PUT /<slug> (whole-
inventory save with version-based optimistic concurrency; 404 for missing),
DELETE. Legacy inventories.yaml / old tables migrate to per-inventory files
(pound->lb), and an alembic migration drops the tables.
Frontend
- New app/src/components/inventory/ package: spreadsheet-style table with
Tab/Enter keyboard entry, sortable columns, expired-row highlighting,
customizable field editor, and pooled cross-inventory location autocomplete.
- A single useInventories store loads everything once and persists whole
inventories optimistically; list/items/summary/locations derive client-side.
- Summary groups items (default by Category), totals size x count, shows a
calories column, and embeds a ration estimate (how long the stock lasts).
Food catalog
- Shared, editable catalog (config/inventory/catalog.yaml) seeded from
catalog_defaults.yaml (~60 generic items, total calories per package) with
merge-keep-edits + tombstones. GET/PUT /api/inventory/catalog, a management
modal, and entry-row pre-fill of category/size/calories from a name match.
Calculators
- Generic Food Storage planner (like the Water calculator): household +
editable per-person/year amounts -> total to store over a chosen duration,
with women/children weighted by DGA calorie shares and an imperial/metric
toggle.
Also fixes ConfigFile.save() to accept nested file_names. Backend pytest and
frontend jest suites updated/added throughout; alembic check clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 14:20:10 -06:00
|
|
|
// Menu is a compound component (Menu.Item / Menu.Header / Menu.Menu) so callers get the same API as Semantic's
|
|
|
|
|
// Menu while inheriting the theme. The parent menu is `inverted` in dark mode so item text stays readable.
|
|
|
|
|
const MenuBase: React.FC<MenuProps> = (props) => {
|
2025-12-07 11:32:07 -07:00
|
|
|
const {i} = useContext(ThemeContext);
|
Rebuild Inventory as a config-only system with food catalog and calculators
Replace the DB-backed inventory module with a config-only design and build out
food-storage tooling around it.
Inventory (config-only, no database)
- Each inventory is a YAML file at config/inventory/<slug>.yaml, loaded once
into memory and the single source of truth. New reusable MultiFileConfig
(wrolpi/common.py) manages a directory of per-entity files.
- Inventory types (food/fuel/tool) seed a customizable field schema
(text/number/quantity/date/select/location/calories). Unit math/aggregation
moved to the frontend (mathjs); Pint dropped from the backend.
- Minimal API: GET / (all inventories full), POST /, PUT /<slug> (whole-
inventory save with version-based optimistic concurrency; 404 for missing),
DELETE. Legacy inventories.yaml / old tables migrate to per-inventory files
(pound->lb), and an alembic migration drops the tables.
Frontend
- New app/src/components/inventory/ package: spreadsheet-style table with
Tab/Enter keyboard entry, sortable columns, expired-row highlighting,
customizable field editor, and pooled cross-inventory location autocomplete.
- A single useInventories store loads everything once and persists whole
inventories optimistically; list/items/summary/locations derive client-side.
- Summary groups items (default by Category), totals size x count, shows a
calories column, and embeds a ration estimate (how long the stock lasts).
Food catalog
- Shared, editable catalog (config/inventory/catalog.yaml) seeded from
catalog_defaults.yaml (~60 generic items, total calories per package) with
merge-keep-edits + tombstones. GET/PUT /api/inventory/catalog, a management
modal, and entry-row pre-fill of category/size/calories from a name match.
Calculators
- Generic Food Storage planner (like the Water calculator): household +
editable per-person/year amounts -> total to store over a chosen duration,
with women/children weighted by DGA calorie shares and an imperial/metric
toggle.
Also fixes ConfigFile.save() to accept nested file_names. Backend pytest and
frontend jest suites updated/added throughout; alembic check clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 14:20:10 -06:00
|
|
|
return <SMenu {...i} {...props}/>;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const MenuItem: React.FC<MenuItemProps> = (props) => <SMenuItem {...props}/>;
|
|
|
|
|
const MenuHeader: React.FC<MenuItemProps> = (props) => <SMenuHeader {...props}/>;
|
|
|
|
|
const MenuMenu: React.FC<MenuMenuProps> = (props) => <SMenuMenu {...props}/>;
|
|
|
|
|
|
|
|
|
|
interface MenuComponent extends React.FC<MenuProps> {
|
|
|
|
|
Item: React.FC<MenuItemProps>;
|
|
|
|
|
Header: React.FC<MenuItemProps>;
|
|
|
|
|
Menu: React.FC<MenuMenuProps>;
|
2025-12-07 11:32:07 -07:00
|
|
|
}
|
|
|
|
|
|
Rebuild Inventory as a config-only system with food catalog and calculators
Replace the DB-backed inventory module with a config-only design and build out
food-storage tooling around it.
Inventory (config-only, no database)
- Each inventory is a YAML file at config/inventory/<slug>.yaml, loaded once
into memory and the single source of truth. New reusable MultiFileConfig
(wrolpi/common.py) manages a directory of per-entity files.
- Inventory types (food/fuel/tool) seed a customizable field schema
(text/number/quantity/date/select/location/calories). Unit math/aggregation
moved to the frontend (mathjs); Pint dropped from the backend.
- Minimal API: GET / (all inventories full), POST /, PUT /<slug> (whole-
inventory save with version-based optimistic concurrency; 404 for missing),
DELETE. Legacy inventories.yaml / old tables migrate to per-inventory files
(pound->lb), and an alembic migration drops the tables.
Frontend
- New app/src/components/inventory/ package: spreadsheet-style table with
Tab/Enter keyboard entry, sortable columns, expired-row highlighting,
customizable field editor, and pooled cross-inventory location autocomplete.
- A single useInventories store loads everything once and persists whole
inventories optimistically; list/items/summary/locations derive client-side.
- Summary groups items (default by Category), totals size x count, shows a
calories column, and embeds a ration estimate (how long the stock lasts).
Food catalog
- Shared, editable catalog (config/inventory/catalog.yaml) seeded from
catalog_defaults.yaml (~60 generic items, total calories per package) with
merge-keep-edits + tombstones. GET/PUT /api/inventory/catalog, a management
modal, and entry-row pre-fill of category/size/calories from a name match.
Calculators
- Generic Food Storage planner (like the Water calculator): household +
editable per-person/year amounts -> total to store over a chosen duration,
with women/children weighted by DGA calorie shares and an imperial/metric
toggle.
Also fixes ConfigFile.save() to accept nested file_names. Backend pytest and
frontend jest suites updated/added throughout; alembic check clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 14:20:10 -06:00
|
|
|
export const Menu: MenuComponent = Object.assign(MenuBase, {
|
|
|
|
|
Item: MenuItem,
|
|
|
|
|
Header: MenuHeader,
|
|
|
|
|
Menu: MenuMenu,
|
|
|
|
|
});
|
|
|
|
|
|
2025-12-07 11:32:07 -07:00
|
|
|
export function Placeholder(props: PlaceholderProps) {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
return <SPlaceholder {...i} {...props}/>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function Popup(props: PopupProps) {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
return <SPopup {...i} style={{border: '1px solid grey'}} {...props}/>
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-12 17:48:35 -06:00
|
|
|
// Bar colors that always need dark percent text (light bars in any theme).
|
|
|
|
|
const PROGRESS_BAR_COLORS = ['yellow', 'olive', 'teal'];
|
|
|
|
|
// Bar colors that need dark percent text only in dark mode (inverted makes bar lighter).
|
|
|
|
|
const DARK_MODE_PROGRESS_BAR_COLORS = ['grey', 'blue'];
|
|
|
|
|
|
2025-12-07 11:32:07 -07:00
|
|
|
export function Progress(props: ProgressProps) {
|
2026-03-12 17:48:35 -06:00
|
|
|
const {i, inverted} = useContext(ThemeContext);
|
|
|
|
|
const classes = [props.className || ''];
|
|
|
|
|
if (inverted) classes.push('inverted-progress-text');
|
|
|
|
|
const color = props.color as string;
|
|
|
|
|
if (PROGRESS_BAR_COLORS.includes(color) || (inverted && DARK_MODE_PROGRESS_BAR_COLORS.includes(color))) {
|
|
|
|
|
classes.push('light-bar-progress-text');
|
|
|
|
|
}
|
|
|
|
|
return <SProgress {...i} {...props} className={classes.join(' ').trim()}/>
|
2025-12-07 11:32:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function Segment(props: SegmentProps) {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
return <SSegment {...i} {...props}/>
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-11 18:32:55 -07:00
|
|
|
// Table is now a compound component - see COMPOUND COMPONENTS section below
|
2025-12-07 11:32:07 -07:00
|
|
|
|
|
|
|
|
export function TextArea(props: TextAreaProps) {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
const mergedProps = invertedNull({...i, ...props});
|
|
|
|
|
return <STextArea {...mergedProps}/>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
|
// COMPOUND COMPONENTS
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
// Modal Compound Component
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
type ModalActionsComponent = React.FC<ModalActionsProps>;
|
|
|
|
|
type ModalContentComponent = React.FC<ModalContentProps>;
|
|
|
|
|
type ModalDescriptionComponent = React.FC<ModalDescriptionProps>;
|
|
|
|
|
type ModalHeaderComponent = React.FC<ModalHeaderProps>;
|
|
|
|
|
|
|
|
|
|
interface ModalComponent extends React.FC<ModalProps> {
|
|
|
|
|
Actions: ModalActionsComponent;
|
|
|
|
|
Content: ModalContentComponent;
|
|
|
|
|
Description: ModalDescriptionComponent;
|
|
|
|
|
Header: ModalHeaderComponent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ModalActions: ModalActionsComponent = (props) => {
|
|
|
|
|
const {inverted} = useContext(ThemeContext);
|
|
|
|
|
return <SModalActions {...props} className={`${inverted}`}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ModalContent: ModalContentComponent = (props) => {
|
|
|
|
|
const {inverted} = useContext(ThemeContext);
|
|
|
|
|
return <SModalContent {...props} className={`${inverted}`}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ModalDescription: ModalDescriptionComponent = (props) => {
|
|
|
|
|
const {inverted} = useContext(ThemeContext);
|
|
|
|
|
return <SModalDescription {...props} className={`${inverted}`}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ModalHeader: ModalHeaderComponent = (props) => {
|
|
|
|
|
const {inverted} = useContext(ThemeContext);
|
|
|
|
|
return <SModalHeader {...props} className={`${inverted}`}>
|
|
|
|
|
{props.children}
|
|
|
|
|
</SModalHeader>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ModalBase: React.FC<ModalProps> = (props) => {
|
|
|
|
|
const {inverted} = useContext(ThemeContext);
|
|
|
|
|
return <SModal {...props} className={`${inverted}`}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const Modal: ModalComponent = Object.assign(ModalBase, {
|
|
|
|
|
Actions: ModalActions,
|
|
|
|
|
Content: ModalContent,
|
|
|
|
|
Description: ModalDescription,
|
|
|
|
|
Header: ModalHeader,
|
|
|
|
|
});
|
|
|
|
|
|
Add ordered collections (playlists): polymorphic items + item API (#475)
* Add Playlists: ordered, mixed-type collections
A playlist (Collection kind='playlist') is a manually-curated, ordered list that
mixes item types. Squash of the playlists feature branch (24 commits).
Data model & API:
- CollectionItem is polymorphic via item_kind: 'file' (FileGroup), 'zim'
(zim_id + zim_entry), or 'url' (link to anything the WROLPi browser opens,
e.g. /map?lat=&lon=&z=). CHECK constraint enforces exactly one kind; per-kind
unique constraints; migration a7b1c2d3e4f5.
- Endpoints: create playlist; add/remove/reorder items (idempotent adds: 201 new,
200 existing); GET returns the ordered items. All mutations wrol_mode_check'd.
Config (source of truth):
- playlists.yaml (PlaylistsConfig) stores each playlist's metadata AND ordered
items (file by relative path, zim by path+entry, url inline); round-trips a
DB wipe. Supports backup import (DB_CONFIG_FILE_NAMES).
- The redundant generic CollectionsConfig (collections.yaml) is deleted:
channels/domains own their configs, authors/subjects are re-derived.
On-disk sync (sync_playlists_directory switch):
- Each playlist materializes into the configurable Playlists Directory
(playlists_destination, Settings UI input, excluded from indexing) with
position-prefixed entries: NNNN_<file> hard links (copy fallback across
filesystems) and NNNN_<title>.html stubs for zim/url items.
- Tagged playlists are namespaced like channels: <playlists>/<tag>/<name>;
a tag change moves the directory and prunes the empty old tag dir.
- Deletion safety: managed files are only removed when they are our marked
stubs or still have another hard link (st_nlink > 1) -- never a last copy.
Stray loose files at the playlists root are removed; stub URLs are
scheme-allowlisted (no javascript:/data:).
Frontend:
- /playlists list page (CollectionTable, name filter, New Playlist modal, Tag
column) between Files and Zim in the nav.
- View-only detail page (Name link) and edit page (Edit button): themed table
with model icons/colors + poster thumbnails, items link to their model page
(video/archive/doc) or preview, up/down reorder, remove, add-URL form,
single-tag selector; all editing disabled in WROL Mode.
- Reusable green "Add to Playlist" button on Video/Archive/Doc detail pages,
the FilePreview toolbar, Zim search results, and Map pins (added as a /map
URL item with a map-marker icon).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Playlist edit page parity: rename, custom directory, tag modal move suggestion
Match the ChannelEditPage/DomainEditPage UX on the playlist edit page:
Back/View buttons, an edit form (name, description, directory), and the
shared CollectionTagModal with the violet "Tag" button. The tag modal now
suggests moving the playlist to its managed tag location
(playlists/<tag>/<name>); accepting the suggestion stores directory=None so
the sync keeps auto-managing the location. Tag buttons on the Channel and
Domain edit pages are now violet to match.
Backend: update_collection learns rename (with per-kind validation and
duplicate checks) and playlist custom directories (cleanup of the abandoned
directory, config round-trip, commit-before-switch to avoid the background
sync racing pre-commit state). tag_collection's duplicated untag/tag
branches are merged, and the per-kind config-save dispatch is consolidated
into _activate_config_save().
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Deduplicate Collection error handling and Tag creation
Delete the duplicate UnknownCollection in wrolpi/collections/errors.py and
re-export the canonical one from wrolpi/errors.py, which carries
status_code=NOT_FOUND (the local copy inherited 500). Replace the repeated
query/raise pattern in reorganize.py with Collection.find_by_id.
Add Tag.get_or_create_tag and use it for collection tagging; flush the new
Tag before returning so callers can read .id immediately -- previously
tagging a collection with a brand-new tag name set tag_id=None. Regression
test included.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 19:37:34 -06:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
// List Compound Component
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
// Semantic's List supports `inverted`; the inverted class on the parent handles the item text,
|
|
|
|
|
// but List.Icon must also receive `inverted` so its color flips in dark mode (the parent's
|
|
|
|
|
// inverted class alone does not restyle the icon).
|
|
|
|
|
|
|
|
|
|
interface ListComponent extends React.FC<ListProps> {
|
|
|
|
|
Item: React.FC<ListItemProps>;
|
|
|
|
|
Icon: React.FC<ListIconProps>;
|
|
|
|
|
Content: React.FC<ListContentProps>;
|
|
|
|
|
Header: React.FC<ListHeaderProps>;
|
|
|
|
|
Description: React.FC<ListDescriptionProps>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ListBase: React.FC<ListProps> = (props) => {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
return <SList {...i} {...props}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ListIcon: React.FC<ListIconProps> = (props) => {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
return <SListIcon {...i} {...props}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const List: ListComponent = Object.assign(ListBase, {
|
|
|
|
|
Item: SListItem,
|
|
|
|
|
Icon: ListIcon,
|
|
|
|
|
Content: SListContent,
|
|
|
|
|
Header: SListHeader,
|
|
|
|
|
Description: SListDescription,
|
|
|
|
|
});
|
|
|
|
|
|
2025-12-07 11:32:07 -07:00
|
|
|
// ----------------------------------------------------------------------------
|
2025-12-25 16:03:09 -07:00
|
|
|
// Confirm Component
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
export interface ConfirmProps {
|
|
|
|
|
open: boolean;
|
|
|
|
|
header?: string;
|
|
|
|
|
content?: string | React.ReactNode;
|
|
|
|
|
confirmButton?: string;
|
|
|
|
|
cancelButton?: string;
|
|
|
|
|
onConfirm?: () => void;
|
|
|
|
|
onCancel?: () => void;
|
|
|
|
|
onClose?: () => void;
|
|
|
|
|
size?: 'mini' | 'tiny' | 'small' | 'large' | 'fullscreen';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const Confirm: React.FC<ConfirmProps> = ({
|
|
|
|
|
open,
|
|
|
|
|
header,
|
|
|
|
|
content,
|
|
|
|
|
confirmButton = 'OK',
|
|
|
|
|
cancelButton = 'Cancel',
|
|
|
|
|
onConfirm,
|
|
|
|
|
onCancel,
|
|
|
|
|
onClose,
|
|
|
|
|
size = 'tiny',
|
|
|
|
|
}) => {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Modal open={open} onClose={onClose} size={size} className="themed-confirm">
|
|
|
|
|
{header && <Modal.Header>{header}</Modal.Header>}
|
|
|
|
|
<Modal.Content>
|
|
|
|
|
{typeof content === 'string' ? <p>{content}</p> : content}
|
|
|
|
|
</Modal.Content>
|
|
|
|
|
<Modal.Actions>
|
|
|
|
|
<Button onClick={onCancel} {...i}>{cancelButton}</Button>
|
|
|
|
|
<Button onClick={onConfirm} color="green" {...i}>{confirmButton}</Button>
|
|
|
|
|
</Modal.Actions>
|
|
|
|
|
</Modal>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2025-12-07 11:32:07 -07:00
|
|
|
// Form Compound Component
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
type FormFieldComponent = React.FC<FormFieldProps>;
|
|
|
|
|
type FormGroupComponent = React.FC<FormGroupProps>;
|
|
|
|
|
type FormInputComponent = React.FC<FormInputProps>;
|
|
|
|
|
|
|
|
|
|
interface FormComponent extends React.FC<FormProps> {
|
|
|
|
|
Field: FormFieldComponent;
|
|
|
|
|
Group: FormGroupComponent;
|
|
|
|
|
Input: FormInputComponent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FormField: FormFieldComponent = (props) => {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
const mergedProps = invertedNull({...i, ...props});
|
|
|
|
|
return <SFormField {...mergedProps}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const FormGroup: FormGroupComponent = (props) => {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
const mergedProps = invertedNull({...i, ...props});
|
|
|
|
|
return <SFormGroup {...mergedProps}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const FormInput: FormInputComponent = (props) => {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
return <SFormInput {...i} {...props}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const FormBase: React.FC<FormProps> = (props) => {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
return <SForm {...i} {...props}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const Form: FormComponent = Object.assign(FormBase, {
|
|
|
|
|
Field: FormField,
|
|
|
|
|
Group: FormGroup,
|
|
|
|
|
Input: FormInput,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
// Card Compound Component
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
interface CardIconProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
|
|
onClick?: () => void;
|
|
|
|
|
children?: React.ReactNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type CardIconComponent = React.FC<CardIconProps>;
|
|
|
|
|
|
|
|
|
|
interface CardProps extends Omit<SCardProps, 'color'> {
|
|
|
|
|
color?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface CardComponent extends React.FC<CardProps> {
|
|
|
|
|
Icon: CardIconComponent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CardIcon: CardIconComponent = ({onClick, children, ...props}) => {
|
|
|
|
|
const {inverted} = useContext(ThemeContext);
|
|
|
|
|
const cardIcon = <center className={`card-icon ${inverted}`} {...props}>{children}</center>;
|
|
|
|
|
if (onClick) {
|
|
|
|
|
return <div onClick={onClick} className='clickable'>
|
|
|
|
|
{cardIcon}
|
|
|
|
|
</div>
|
|
|
|
|
} else {
|
|
|
|
|
return cardIcon;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const CardBase: React.FC<CardProps> = ({color, ...props}) => {
|
|
|
|
|
const {inverted} = useContext(ThemeContext);
|
|
|
|
|
|
|
|
|
|
const style: CSSProperties = props.style || {};
|
|
|
|
|
const emphasisColor = ColorToSemanticHexColor(color);
|
|
|
|
|
if (emphasisColor) {
|
|
|
|
|
// Increase drop shadow to emphasize color.
|
|
|
|
|
const borderColor = inverted ? '#888' : '#ddd';
|
|
|
|
|
style.boxShadow = `0 0 0 2px ${borderColor}, 0 5px 0 0 ${emphasisColor}, 0 0px 3px 0 #d4d4d5`;
|
|
|
|
|
}
|
|
|
|
|
return <SCard {...props} style={style}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const Card: CardComponent = Object.assign(CardBase, {
|
|
|
|
|
Icon: CardIcon,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
// Tab Compound Component
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
type TabPaneComponent = React.FC<TabPaneProps>;
|
|
|
|
|
|
|
|
|
|
interface TabComponent extends React.FC<TabProps> {
|
|
|
|
|
Pane: TabPaneComponent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TabPane: TabPaneComponent = (props) => {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
return <STabPane {...i} {...props}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TabBase: React.FC<TabProps> = (props) => {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
const mergedProps = invertedNull({...i, ...props});
|
|
|
|
|
return <STab {...mergedProps}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const Tab: TabComponent = Object.assign(TabBase, {
|
|
|
|
|
Pane: TabPane,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
// Statistic Compound Component
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
type StatisticGroupComponent = React.FC<StatisticGroupProps>;
|
|
|
|
|
|
|
|
|
|
interface StatisticComponent extends React.FC<StatisticProps> {
|
|
|
|
|
Group: StatisticGroupComponent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const StatisticGroup: StatisticGroupComponent = (props) => {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
const style: CSSProperties = {...props.style, marginLeft: 0, marginRight: 0};
|
|
|
|
|
return <SStatisticGroup {...i} {...props} style={style}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const StatisticBase: React.FC<StatisticProps> = (props) => {
|
|
|
|
|
const {i, inverted} = useContext(ThemeContext);
|
|
|
|
|
const mergedProps = defaultGrey({...i, ...props}, !!inverted);
|
|
|
|
|
return <SStatistic {...mergedProps}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const Statistic: StatisticComponent = Object.assign(StatisticBase, {
|
|
|
|
|
Group: StatisticGroup,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
// Breadcrumb Compound Component
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
interface BreadcrumbDividerProps {
|
|
|
|
|
icon?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type BreadcrumbDividerComponent = React.FC<BreadcrumbDividerProps>;
|
|
|
|
|
|
|
|
|
|
interface BreadcrumbComponent extends React.FC<BreadcrumbProps> {
|
|
|
|
|
Divider: BreadcrumbDividerComponent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const BreadcrumbDivider: BreadcrumbDividerComponent = ({icon, ...props}) => {
|
|
|
|
|
const {inverted} = useContext(ThemeContext);
|
|
|
|
|
|
|
|
|
|
// TODO this only handles icons for now.
|
|
|
|
|
const className = `divider icon ${inverted} ${icon || ''}`;
|
|
|
|
|
return <i aria-hidden="true" className={className}></i>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const BreadcrumbBase: React.FC<BreadcrumbProps> = (props) => {
|
|
|
|
|
const {t} = useContext(ThemeContext);
|
|
|
|
|
return <SBreadcrumb {...props} {...t}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const Breadcrumb: BreadcrumbComponent = Object.assign(BreadcrumbBase, {
|
|
|
|
|
Divider: BreadcrumbDivider,
|
|
|
|
|
});
|
2025-12-11 18:32:55 -07:00
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
// Table Compound Component
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
type TableBodyComponent = React.FC<TableBodyProps>;
|
|
|
|
|
type TableCellComponent = React.FC<TableCellProps>;
|
|
|
|
|
type TableFooterComponent = React.FC<TableFooterProps>;
|
|
|
|
|
type TableHeaderComponent = React.FC<TableHeaderProps>;
|
|
|
|
|
type TableHeaderCellComponent = React.FC<TableHeaderCellProps>;
|
|
|
|
|
type TableRowComponent = React.FC<TableRowProps>;
|
|
|
|
|
|
|
|
|
|
interface TableComponent extends React.FC<TableProps> {
|
|
|
|
|
Body: TableBodyComponent;
|
|
|
|
|
Cell: TableCellComponent;
|
|
|
|
|
Footer: TableFooterComponent;
|
|
|
|
|
Header: TableHeaderComponent;
|
|
|
|
|
HeaderCell: TableHeaderCellComponent;
|
|
|
|
|
Row: TableRowComponent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TableBody: TableBodyComponent = (props) => {
|
|
|
|
|
return <STableBody {...props}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TableCell: TableCellComponent = (props) => {
|
|
|
|
|
return <STableCell {...props}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TableFooter: TableFooterComponent = (props) => {
|
|
|
|
|
return <STableFooter {...props}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TableHeader: TableHeaderComponent = (props) => {
|
|
|
|
|
return <STableHeader {...props}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TableHeaderCell: TableHeaderCellComponent = (props) => {
|
|
|
|
|
return <STableHeaderCell {...props}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TableRow: TableRowComponent = (props) => {
|
|
|
|
|
return <STableRow {...props}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TableBase: React.FC<TableProps> = (props) => {
|
|
|
|
|
const {i} = useContext(ThemeContext);
|
|
|
|
|
return <STable {...i} {...props}/>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const Table: TableComponent = Object.assign(TableBase, {
|
|
|
|
|
Body: TableBody,
|
|
|
|
|
Cell: TableCell,
|
|
|
|
|
Footer: TableFooter,
|
|
|
|
|
Header: TableHeader,
|
|
|
|
|
HeaderCell: TableHeaderCell,
|
|
|
|
|
Row: TableRow,
|
|
|
|
|
});
|