2022-08-06 05:22:07 +00:00
|
|
|
import React, {useContext, useEffect, useState} from "react";
|
2026-03-17 18:35:57 -06:00
|
|
|
import {Link, NavLink, useNavigate} from "react-router";
|
2023-04-18 22:03:45 -06:00
|
|
|
import {
|
2024-11-02 15:14:02 -06:00
|
|
|
Accordion,
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
Breadcrumbs as UIBreadcrumbs,
|
2023-04-18 22:03:45 -06:00
|
|
|
Button,
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
ButtonGroup,
|
|
|
|
|
CardGroup,
|
2025-12-25 16:03:09 -07:00
|
|
|
Confirm,
|
2023-04-18 22:03:45 -06:00
|
|
|
Header,
|
|
|
|
|
Icon,
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
IconButton,
|
|
|
|
|
IconStack,
|
|
|
|
|
Label,
|
|
|
|
|
Loading,
|
2023-04-18 22:03:45 -06:00
|
|
|
Menu,
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
Message,
|
2023-04-18 22:03:45 -06:00
|
|
|
Modal,
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
Pagination,
|
|
|
|
|
Panel,
|
|
|
|
|
SearchBox,
|
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
|
|
|
Statistic,
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
TabBar,
|
|
|
|
|
tabClassName,
|
|
|
|
|
TextInput,
|
|
|
|
|
Toggle as UIToggle,
|
|
|
|
|
Tooltip,
|
|
|
|
|
} from "./ui";
|
|
|
|
|
import {useBluetooth, useDesktop, useHotspot, useSearchDirectories, useSearchOrder, useThrottle, useVnc, useWROLMode} from "../hooks/customHooks";
|
|
|
|
|
import {Media, SettingsContext, StatusContext, ThemeContext} from "../contexts/contexts";
|
|
|
|
|
import {themeChoices} from "./Theme";
|
2023-02-15 20:58:07 -07:00
|
|
|
import {FilePreviewContext} from "./FilePreview";
|
2023-03-29 13:46:39 -06:00
|
|
|
import _ from "lodash";
|
2026-03-06 15:15:36 -07:00
|
|
|
import {killDownloads, startDownloads, unlockCookies} from "../api";
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
import {allFrequencyOptions, HELP_VIEWER_URI, NAME, validUrlRegex} from "./Vars";
|
2024-06-12 18:44:59 -06:00
|
|
|
|
2022-08-06 05:22:07 +00:00
|
|
|
export function Paginator({activePage, onPageChange, totalPages, showFirstAndLast, size = 'mini'}) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
// Fewer page numbers on a phone: the strip has to fit without wrapping.
|
|
|
|
|
const pager = (siblingRange) => <Pagination
|
|
|
|
|
activePage={activePage}
|
|
|
|
|
totalPages={totalPages}
|
|
|
|
|
onPageChange={onPageChange}
|
|
|
|
|
siblingRange={siblingRange}
|
|
|
|
|
showFirstAndLast={showFirstAndLast}
|
|
|
|
|
/>;
|
2022-02-02 08:24:34 -07:00
|
|
|
|
2023-04-01 11:52:41 -06:00
|
|
|
return <>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
<Media at='mobile'>{pager(1)}</Media>
|
|
|
|
|
<Media greaterThanOrEqual='tablet'>{pager(3)}</Media>
|
2023-04-01 11:52:41 -06:00
|
|
|
</>
|
2022-02-02 08:24:34 -07:00
|
|
|
}
|
|
|
|
|
|
2022-09-28 09:38:05 -06:00
|
|
|
export function divmod(x, y) {
|
|
|
|
|
return [Math.floor(x / y), x % y];
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-02 15:14:02 -06:00
|
|
|
export function secondsToHumanElapsed(seconds, short = true) {
|
2022-09-28 09:38:05 -06:00
|
|
|
// Convert the provided seconds into a human-readable string of the time elapsed between the provided timestamp
|
|
|
|
|
// and now.
|
|
|
|
|
if (!seconds || seconds < 0) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-03 08:53:00 -07:00
|
|
|
// Get seconds elapsed between now and `seconds` which is a UTC epoch.
|
2024-08-20 13:13:21 -06:00
|
|
|
const localNow = (new Date()).getTime() / 1000;
|
2023-01-03 08:53:00 -07:00
|
|
|
|
2022-09-28 09:38:05 -06:00
|
|
|
let years;
|
|
|
|
|
let days;
|
|
|
|
|
let hours;
|
|
|
|
|
let minutes;
|
|
|
|
|
|
2024-08-20 13:13:21 -06:00
|
|
|
seconds = Math.abs(localNow - seconds);
|
2022-09-28 09:38:05 -06:00
|
|
|
[years, seconds] = divmod(seconds, secondsToYears);
|
|
|
|
|
[days, seconds] = divmod(seconds, secondsToDays);
|
|
|
|
|
[hours, seconds] = divmod(seconds, secondsToHours);
|
|
|
|
|
[minutes, seconds] = divmod(seconds, secondsToMinutes);
|
|
|
|
|
seconds = Math.floor(seconds);
|
|
|
|
|
|
2024-08-20 13:13:21 -06:00
|
|
|
if (short) {
|
|
|
|
|
if (years > 0 && days > 30) {
|
|
|
|
|
return `${years}y${days}d`;
|
|
|
|
|
} else if (years > 0) {
|
|
|
|
|
return `${years}y`;
|
|
|
|
|
} else if (days > 0) {
|
|
|
|
|
return `${days}d`;
|
|
|
|
|
} else if (hours > 0) {
|
|
|
|
|
return `${hours}h`;
|
|
|
|
|
} else if (minutes > 0) {
|
|
|
|
|
return `${minutes}m`;
|
|
|
|
|
}
|
|
|
|
|
return `${seconds}s`
|
|
|
|
|
} else {
|
|
|
|
|
if (years > 0 && days > 30) {
|
|
|
|
|
return `${years} years ${days} days`;
|
|
|
|
|
} else if (years > 0) {
|
|
|
|
|
return `${years} years`;
|
|
|
|
|
} else if (days > 0) {
|
|
|
|
|
return `${days} days`;
|
|
|
|
|
} else if (hours > 0) {
|
|
|
|
|
return `${hours} hours`;
|
|
|
|
|
} else if (minutes > 0) {
|
|
|
|
|
return `${minutes} minutes`;
|
|
|
|
|
}
|
|
|
|
|
return `${seconds} seconds`
|
2022-09-28 09:38:05 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function secondsToElapsedPopup(seconds) {
|
|
|
|
|
// Return a Popup which allows the user see a more detailed timestamp when hovering.
|
2024-11-02 15:14:02 -06:00
|
|
|
const elapsed = secondsToHumanElapsed(seconds);
|
2022-09-28 09:38:05 -06:00
|
|
|
if (!elapsed) {
|
|
|
|
|
return <></>;
|
|
|
|
|
}
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <Tooltip label={secondsToTimestamp(seconds)}>
|
|
|
|
|
<span>{elapsed}</span>
|
|
|
|
|
</Tooltip>
|
2022-09-28 09:38:05 -06:00
|
|
|
}
|
|
|
|
|
|
2022-12-23 16:04:09 -07:00
|
|
|
export function isoDatetimeToElapsedPopup(dt) {
|
2023-01-03 08:53:00 -07:00
|
|
|
let d = new Date(dt);
|
2022-12-23 16:04:09 -07:00
|
|
|
return secondsToElapsedPopup(d.getTime() / 1000);
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-20 13:13:21 -06:00
|
|
|
export function isoDatetimeToAgoPopup(dt, short = true) {
|
|
|
|
|
const seconds = (new Date(dt)).getTime() / 1000;
|
|
|
|
|
// Return a Popup which allows the user see a more detailed timestamp when hovering.
|
2024-11-02 15:14:02 -06:00
|
|
|
const elapsed = secondsToHumanElapsed(seconds, short);
|
2024-08-20 13:13:21 -06:00
|
|
|
if (seconds === 0 || !elapsed) {
|
|
|
|
|
return <></>;
|
|
|
|
|
}
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <Tooltip label={`${elapsed} ago`}>
|
|
|
|
|
<span>{isoDatetimeToString(dt)}</span>
|
|
|
|
|
</Tooltip>
|
2024-08-20 13:13:21 -06:00
|
|
|
}
|
|
|
|
|
|
2023-10-24 10:20:06 -06:00
|
|
|
export function secondsToHMS(totalSeconds) {
|
|
|
|
|
let hours = Math.floor(totalSeconds / 3600);
|
|
|
|
|
totalSeconds -= hours * 3600;
|
|
|
|
|
let minutes = Math.floor(totalSeconds / 60);
|
|
|
|
|
let seconds = totalSeconds - (minutes * 60);
|
2021-11-01 16:42:52 -06:00
|
|
|
|
|
|
|
|
hours = String('00' + hours).slice(-2);
|
|
|
|
|
minutes = String('00' + minutes).slice(-2);
|
|
|
|
|
seconds = String('00' + seconds).slice(-2);
|
|
|
|
|
|
2023-10-24 10:20:06 -06:00
|
|
|
return {hours, minutes, seconds};
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
|
|
|
|
|
2023-10-24 10:20:06 -06:00
|
|
|
export function Duration({totalSeconds}) {
|
|
|
|
|
const {hours, minutes, seconds} = secondsToHMS(totalSeconds);
|
2021-11-01 16:42:52 -06:00
|
|
|
|
|
|
|
|
if (hours > 0) {
|
2023-10-24 10:20:06 -06:00
|
|
|
return <div className='duration-overlay'>{hours}:{minutes}:{seconds}</div>
|
|
|
|
|
} else if (totalSeconds) {
|
|
|
|
|
return <div className='duration-overlay'>{minutes}:{seconds}</div>
|
2021-11-01 16:42:52 -06:00
|
|
|
} else {
|
|
|
|
|
return <></>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-13 10:39:06 -06:00
|
|
|
export function isoDatetimeToString(dt, time = false) {
|
2022-12-23 16:04:09 -07:00
|
|
|
// Convert a datetime to a human-readable date format.
|
2023-03-24 08:58:18 -06:00
|
|
|
let d = <React.Fragment/>;
|
2023-09-13 10:39:06 -06:00
|
|
|
if (dt && time) {
|
2022-12-29 16:10:40 -07:00
|
|
|
d = new Date(dt);
|
2023-10-20 18:53:26 -06:00
|
|
|
const hours = String(d.getHours()).padStart(2, '0');
|
|
|
|
|
const minutes = String(d.getMinutes()).padStart(2, '0');
|
|
|
|
|
const seconds = String(d.getSeconds()).padStart(2, '0');
|
|
|
|
|
d = `${d.toDateString()} ${hours}:${minutes}:${seconds}`;
|
2023-09-13 10:39:06 -06:00
|
|
|
} else if (dt) {
|
|
|
|
|
d = new Date(dt);
|
|
|
|
|
d = d.toDateString();
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
2022-12-08 13:45:46 -07:00
|
|
|
return d;
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
|
|
|
|
|
2022-08-06 05:22:07 +00:00
|
|
|
export function CardLink({to, newTab = false, ...props}) {
|
|
|
|
|
const {t} = useContext(ThemeContext);
|
|
|
|
|
props = {...props, ...t};
|
|
|
|
|
|
|
|
|
|
props = newTab === true ? {...props, target: '_blank', rel: 'noopener noreferrer'} : props;
|
|
|
|
|
return <Link to={to} className="no-link-underscore card-link" {...props}>
|
|
|
|
|
{props.children}
|
|
|
|
|
</Link>
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-02 10:07:49 -06:00
|
|
|
export function ExternalCardLink({to, children, ...props}) {
|
2022-08-06 05:22:07 +00:00
|
|
|
const {t} = useContext(ThemeContext);
|
2023-11-02 10:07:49 -06:00
|
|
|
return <a
|
|
|
|
|
href={to}
|
|
|
|
|
target='_blank'
|
|
|
|
|
rel='noopener noreferrer'
|
|
|
|
|
className='no-link-underscore card-link'
|
|
|
|
|
{...t}
|
|
|
|
|
{...props}
|
|
|
|
|
>
|
|
|
|
|
{children}
|
2022-08-06 05:22:07 +00:00
|
|
|
</a>
|
2022-01-29 16:50:22 -07:00
|
|
|
}
|
|
|
|
|
|
2023-02-15 20:58:07 -07:00
|
|
|
export function PreviewLink({file, children, className, ...props}) {
|
|
|
|
|
const {t} = useContext(ThemeContext);
|
2023-02-15 21:05:34 -07:00
|
|
|
const {setPreviewFile} = React.useContext(FilePreviewContext);
|
2023-02-15 20:58:07 -07:00
|
|
|
className = className ? `clickable ${className}` : `clickable `;
|
2023-02-15 21:05:34 -07:00
|
|
|
return <span className={className} onClick={() => setPreviewFile(file)} {...props} {...t}>
|
2023-02-15 20:58:07 -07:00
|
|
|
{children}
|
2023-02-15 21:05:34 -07:00
|
|
|
</span>
|
2023-02-15 20:58:07 -07:00
|
|
|
}
|
|
|
|
|
|
2023-08-26 20:28:34 -06:00
|
|
|
export function PreviewPath({path, mimetype, taggable = true, ...props}) {
|
|
|
|
|
return <PreviewLink file={{path, mimetype, taggable}} {...props}/>
|
2023-02-17 16:30:25 -07:00
|
|
|
}
|
|
|
|
|
|
2026-03-28 14:19:09 -06:00
|
|
|
export function DirectoryLink({path}) {
|
|
|
|
|
if (!path) return <span>Unknown</span>;
|
|
|
|
|
const href = `/media/${encodeMediaPath(path)}/`;
|
|
|
|
|
return <a href={href} target='_blank' rel='noopener noreferrer'
|
|
|
|
|
style={{color: 'inherit', textDecoration: 'none'}}>
|
|
|
|
|
{path}
|
|
|
|
|
</a>
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-01 16:42:52 -06:00
|
|
|
export function RequiredAsterisk() {
|
|
|
|
|
return <span style={{color: '#db2828'}}> *</span>
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-02 15:33:46 -07:00
|
|
|
/**
|
|
|
|
|
* Format a frequency value (in seconds) to a human-readable string using allFrequencyOptions.
|
|
|
|
|
* @param {number|null} frequency - Frequency in seconds
|
|
|
|
|
* @returns {string} Human-readable frequency text or '-' if null/undefined
|
|
|
|
|
*/
|
|
|
|
|
export function formatFrequency(frequency) {
|
|
|
|
|
if (frequency === null || frequency === undefined) {
|
|
|
|
|
return '-';
|
|
|
|
|
}
|
|
|
|
|
const option = allFrequencyOptions[frequency];
|
|
|
|
|
return option ? option.text : `${frequency}s`;
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const secondsToYears = 31536000;
|
|
|
|
|
const secondsToDays = 86400;
|
|
|
|
|
const secondsToHours = 3600;
|
|
|
|
|
const secondsToMinutes = 60;
|
|
|
|
|
|
2022-09-28 09:38:05 -06:00
|
|
|
export function secondsToFullDuration(seconds) {
|
2023-11-04 15:57:13 -06:00
|
|
|
let duration = '';
|
2021-11-01 16:42:52 -06:00
|
|
|
|
2022-09-28 09:38:05 -06:00
|
|
|
let years, days, hours, minutes;
|
|
|
|
|
[years, seconds] = divmod(seconds, secondsToYears);
|
|
|
|
|
[days, seconds] = divmod(seconds, secondsToDays);
|
|
|
|
|
[hours, seconds] = divmod(seconds, secondsToHours);
|
|
|
|
|
[minutes] = divmod(seconds, secondsToMinutes);
|
|
|
|
|
if (years > 0) {
|
2023-11-04 15:57:13 -06:00
|
|
|
duration = `${years}Y`;
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
2022-09-28 09:38:05 -06:00
|
|
|
if (days > 0) {
|
2023-11-04 15:57:13 -06:00
|
|
|
duration = `${duration} ${days}D`;
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
2022-09-28 09:38:05 -06:00
|
|
|
if (hours > 0 || minutes > 0) {
|
|
|
|
|
hours = String(hours).padStart(2, '0');
|
|
|
|
|
minutes = String(minutes).padStart(2, '0');
|
2023-11-04 15:57:13 -06:00
|
|
|
duration = `${duration} ${hours}:${minutes}`;
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
2023-11-04 15:57:13 -06:00
|
|
|
if (years === 0 && days === 0 && hours === 0 && minutes === 0) {
|
|
|
|
|
// Less than a minute.
|
|
|
|
|
seconds = String(seconds).padStart(2, '0');
|
|
|
|
|
duration = `00:00:${seconds}`;
|
|
|
|
|
}
|
|
|
|
|
return duration.trim();
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
|
|
|
|
|
2022-01-25 08:51:55 -07:00
|
|
|
export function secondsToTimestamp(seconds) {
|
2023-01-03 12:35:27 -07:00
|
|
|
let d = new Date(seconds * 1000);
|
2023-01-03 08:53:00 -07:00
|
|
|
const month = String(d.getMonth() + 1).padStart(2, '0');
|
2022-09-28 09:38:05 -06:00
|
|
|
const day = String(d.getDate()).padStart(2, '0');
|
|
|
|
|
const hours = String(d.getHours()).padStart(2, '0');
|
|
|
|
|
const minutes = String(d.getMinutes()).padStart(2, '0');
|
|
|
|
|
const sec = String(d.getSeconds()).padStart(2, '0');
|
2023-01-03 08:53:00 -07:00
|
|
|
return `${d.getFullYear()}-${month}-${day} ${hours}:${minutes}:${sec}`;
|
2022-01-25 08:51:55 -07:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 17:15:15 -06:00
|
|
|
export function humanFileSize(bytes, dp = 1) {
|
2025-10-29 22:16:33 -06:00
|
|
|
// Handle null/undefined
|
|
|
|
|
if (bytes == null) {
|
|
|
|
|
return '-';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Convert string to number if needed
|
|
|
|
|
if (typeof bytes === 'string') {
|
|
|
|
|
bytes = parseFloat(bytes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle invalid numbers
|
|
|
|
|
if (isNaN(bytes) || !isFinite(bytes)) {
|
|
|
|
|
return '-';
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-08 13:26:03 -07:00
|
|
|
const thresh = 1024;
|
2021-11-01 16:42:52 -06:00
|
|
|
|
|
|
|
|
if (Math.abs(bytes) < thresh) {
|
|
|
|
|
return bytes + ' B';
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-08 13:26:03 -07:00
|
|
|
const units = ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
2021-11-01 16:42:52 -06:00
|
|
|
let u = -1;
|
|
|
|
|
const r = 10 ** dp;
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
bytes /= thresh;
|
|
|
|
|
++u;
|
|
|
|
|
} while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
|
|
|
|
|
|
|
|
|
|
return bytes.toFixed(dp) + ' ' + units[u];
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-29 16:36:39 -06:00
|
|
|
export function humanBandwidth(bytes) {
|
2022-10-26 11:19:50 -06:00
|
|
|
// Convert bytes to MBps and return a string.
|
|
|
|
|
const thresh = 1024;
|
|
|
|
|
|
|
|
|
|
if (Math.abs(bytes) < thresh) {
|
|
|
|
|
return bytes + ' Bps';
|
2022-09-29 16:36:39 -06:00
|
|
|
}
|
2022-10-26 11:19:50 -06:00
|
|
|
|
|
|
|
|
const units = ['KBps', 'MBps', 'GBps', 'TBps', 'PBps', 'EBps', 'ZBps', 'YBps'];
|
|
|
|
|
let u = -1;
|
|
|
|
|
const r = 10;
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
bytes /= thresh;
|
|
|
|
|
++u;
|
|
|
|
|
} while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
|
|
|
|
|
|
|
|
|
|
return bytes.toFixed(0) + ' ' + units[u];
|
2022-09-29 16:36:39 -06:00
|
|
|
}
|
|
|
|
|
|
2021-12-20 16:08:13 -07:00
|
|
|
export function humanNumber(num, dp = 1) {
|
2022-09-29 16:36:39 -06:00
|
|
|
// Convert large numbers to a more human-readable format.
|
2021-12-20 16:08:13 -07:00
|
|
|
// >> humanNumber(1000)
|
|
|
|
|
// 1.0k
|
|
|
|
|
// >> humanNumber(1500000)
|
|
|
|
|
// 1.5m
|
|
|
|
|
const divisor = 1000;
|
|
|
|
|
if (Math.abs(num) < divisor) {
|
|
|
|
|
return num;
|
|
|
|
|
}
|
|
|
|
|
const units = ['k', 'm', 'b'];
|
|
|
|
|
let i = -1;
|
|
|
|
|
const r = 10 ** dp;
|
|
|
|
|
do {
|
|
|
|
|
num /= divisor;
|
|
|
|
|
++i;
|
|
|
|
|
} while (Math.round(Math.abs(num) * r) / r >= divisor && i < units.length - 1);
|
|
|
|
|
|
|
|
|
|
return num.toFixed(dp) + units[i];
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-01 16:42:52 -06:00
|
|
|
export function replaceNullValues(obj, newValue) {
|
|
|
|
|
newValue = newValue === undefined ? '' : newValue;
|
|
|
|
|
let keys = Object.keys(obj);
|
|
|
|
|
for (let i = 0; i < keys.length; i++) {
|
|
|
|
|
let key = keys[i];
|
|
|
|
|
obj[key] = obj[key] === null ? newValue : obj[key];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function enumerate(array) {
|
|
|
|
|
let newArray = [];
|
|
|
|
|
for (let i = 0; i < array.length; i++) {
|
|
|
|
|
newArray = newArray.concat([[i, array[i]]]);
|
|
|
|
|
}
|
|
|
|
|
return newArray;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function arraysEqual(a, b) {
|
|
|
|
|
if (a === b) return true;
|
|
|
|
|
if (a == null || b == null) return false;
|
|
|
|
|
if (a.length !== b.length) return false;
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < a.length; ++i) {
|
|
|
|
|
if (a[i] !== b[i]) return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function scrollToTop() {
|
|
|
|
|
window.scrollTo({
|
2022-08-06 05:22:07 +00:00
|
|
|
top: 0, behavior: "auto"
|
2021-11-01 16:42:52 -06:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-29 18:04:03 -06:00
|
|
|
export function scrollToTopOfElement(element, smooth = true) {
|
2023-05-03 09:01:25 -06:00
|
|
|
element.scroll({
|
|
|
|
|
top: 0,
|
|
|
|
|
behavior: smooth ? 'smooth' : 'auto',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
/**
|
|
|
|
|
* Shared behaviour for the search inputs: keep a local value so typing is not
|
|
|
|
|
* throttled by the parent, but follow `searchStr` when it changes underneath.
|
|
|
|
|
*/
|
|
|
|
|
const useSearchValue = (searchStr, onChange) => {
|
2023-11-02 15:24:07 -06:00
|
|
|
const [value, setValue] = useState(searchStr || '');
|
2022-01-03 15:13:02 -07:00
|
|
|
|
2024-02-17 13:46:28 -07:00
|
|
|
React.useEffect(() => {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
// `searchStr` is the source of truth from the parent (often an async URL query
|
|
|
|
|
// param). Depend ONLY on `searchStr` -- never on `value` -- otherwise a transient
|
|
|
|
|
// render where the local `value` has advanced ("ex") but `searchStr` still trails
|
|
|
|
|
// ("e") fires this effect and reverts `value`, garbling fast typing.
|
2026-05-31 13:09:20 -06:00
|
|
|
if ((searchStr || '') !== value) {
|
|
|
|
|
setValue(searchStr || '');
|
2024-02-17 13:46:28 -07:00
|
|
|
}
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
2026-05-31 13:09:20 -06:00
|
|
|
}, [searchStr]);
|
2024-02-17 13:46:28 -07:00
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
const handleChange = (newValue) => {
|
|
|
|
|
setValue(newValue);
|
2023-11-02 10:45:35 -06:00
|
|
|
if (onChange) {
|
|
|
|
|
// Try to call the remote function, don't let its failure break this.
|
|
|
|
|
try {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
onChange(newValue);
|
2023-11-02 10:45:35 -06:00
|
|
|
} catch (e) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
console.error('Call to onChange failed', e);
|
2023-11-02 10:45:35 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return {value, setValue, handleChange};
|
2023-11-21 13:01:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function SearchInput({
|
|
|
|
|
searchStr,
|
|
|
|
|
onSubmit,
|
|
|
|
|
onChange,
|
|
|
|
|
onClear,
|
|
|
|
|
placeholder = 'Search...',
|
2026-02-23 17:29:09 -07:00
|
|
|
inputRef = null,
|
2023-11-21 13:10:12 -07:00
|
|
|
...props
|
2023-11-21 13:01:52 -07:00
|
|
|
}) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
const {value, setValue, handleChange} = useSearchValue(searchStr, onChange);
|
2023-11-21 13:01:52 -07:00
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
const handleClear = () => {
|
|
|
|
|
setValue('');
|
|
|
|
|
if (onClear) {
|
|
|
|
|
onClear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return <div className='search-container' {...props}>
|
|
|
|
|
<SearchBox
|
|
|
|
|
value={value}
|
|
|
|
|
onChange={handleChange}
|
|
|
|
|
onSubmit={onSubmit}
|
|
|
|
|
onClear={handleClear}
|
|
|
|
|
placeholder={placeholder}
|
|
|
|
|
inputRef={inputRef}
|
|
|
|
|
clearable
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2023-11-21 13:01:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function SearchResultsInput({
|
|
|
|
|
searchStr,
|
|
|
|
|
onSubmit,
|
|
|
|
|
onClear = null,
|
|
|
|
|
onChange = null,
|
|
|
|
|
placeholder = 'Search...',
|
|
|
|
|
clearable = false,
|
2024-05-25 10:48:08 -06:00
|
|
|
clearDisabled = null,
|
2023-11-21 13:01:52 -07:00
|
|
|
results = undefined,
|
|
|
|
|
handleResultSelect = null,
|
ui: fix search suggestion selection, rendering, and clipping
Three findings from review and CI on the Common.js migration, all real.
Selecting a suggestion navigated nowhere. Semantic handed its callers
`{result}` and every caller destructures that shape, so passing the bare result
left `result.location` undefined -- the search suggestions and the Ctrl+K modal
both stopped navigating. The shape stays until the call sites can change
together. (Greptile P1.)
Suggestions lost their custom markup. Callers pass `resultRenderer` to draw a
tag as a chip rather than a line of text, and the migrated wrapper forwarded it
into a div's props instead of to SearchBox, so every suggestion fell back to the
generic title and description. SearchBox takes it now. (Greptile P2.)
The suggestion list clipped its last group. A cypress spec caught it: with
directories, channels and domains all present, the content runs past the 320px
cap and the final row was cut off. Eight grouped suggestions is an ordinary
result set, so the cap was simply too low; it is viewport-relative now and
still bounded.
Both regressions are pinned by tests -- one asserting the callback shape a
caller actually destructures, one asserting the custom renderer replaces the
default markup rather than wrapping it.
2026-07-30 11:28:17 -06:00
|
|
|
resultRenderer = undefined,
|
2023-11-21 21:15:24 -07:00
|
|
|
loading = false,
|
2025-01-18 10:08:11 -07:00
|
|
|
inputRef = null,
|
2023-11-21 13:01:52 -07:00
|
|
|
...props
|
|
|
|
|
}) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
const {value, setValue, handleChange} = useSearchValue(searchStr, onChange);
|
|
|
|
|
|
|
|
|
|
const handleClear = () => {
|
|
|
|
|
setValue('');
|
|
|
|
|
if (onClear) {
|
|
|
|
|
onClear();
|
2023-11-20 11:01:46 -07:00
|
|
|
}
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const localHandleResultSelect = (result) => {
|
2023-11-20 11:29:14 -07:00
|
|
|
if (handleResultSelect) {
|
ui: fix search suggestion selection, rendering, and clipping
Three findings from review and CI on the Common.js migration, all real.
Selecting a suggestion navigated nowhere. Semantic handed its callers
`{result}` and every caller destructures that shape, so passing the bare result
left `result.location` undefined -- the search suggestions and the Ctrl+K modal
both stopped navigating. The shape stays until the call sites can change
together. (Greptile P1.)
Suggestions lost their custom markup. Callers pass `resultRenderer` to draw a
tag as a chip rather than a line of text, and the migrated wrapper forwarded it
into a div's props instead of to SearchBox, so every suggestion fell back to the
generic title and description. SearchBox takes it now. (Greptile P2.)
The suggestion list clipped its last group. A cypress spec caught it: with
directories, channels and domains all present, the content runs past the 320px
cap and the final row was cut off. Eight grouped suggestions is an ordinary
result set, so the cap was simply too low; it is viewport-relative now and
still bounded.
Both regressions are pinned by tests -- one asserting the callback shape a
caller actually destructures, one asserting the custom renderer replaces the
default markup rather than wrapping it.
2026-07-30 11:28:17 -06:00
|
|
|
// Semantic handed its callers `{result}`, and they destructure it -- passing the
|
|
|
|
|
// bare result silently broke navigation from the search suggestions. The shape
|
|
|
|
|
// stays until the call sites are ready to change together.
|
|
|
|
|
handleResultSelect({result});
|
2023-11-21 13:01:52 -07:00
|
|
|
} else {
|
|
|
|
|
console.error('No handleResultSelect defined!');
|
2023-11-20 11:01:46 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <div className='search-container' {...props}>
|
|
|
|
|
<SearchBox
|
|
|
|
|
value={value}
|
|
|
|
|
onChange={handleChange}
|
|
|
|
|
onSubmit={onSubmit}
|
|
|
|
|
onResultSelect={localHandleResultSelect}
|
|
|
|
|
onClear={handleClear}
|
|
|
|
|
results={results}
|
ui: fix search suggestion selection, rendering, and clipping
Three findings from review and CI on the Common.js migration, all real.
Selecting a suggestion navigated nowhere. Semantic handed its callers
`{result}` and every caller destructures that shape, so passing the bare result
left `result.location` undefined -- the search suggestions and the Ctrl+K modal
both stopped navigating. The shape stays until the call sites can change
together. (Greptile P1.)
Suggestions lost their custom markup. Callers pass `resultRenderer` to draw a
tag as a chip rather than a line of text, and the migrated wrapper forwarded it
into a div's props instead of to SearchBox, so every suggestion fell back to the
generic title and description. SearchBox takes it now. (Greptile P2.)
The suggestion list clipped its last group. A cypress spec caught it: with
directories, channels and domains all present, the content runs past the 320px
cap and the final row was cut off. Eight grouped suggestions is an ordinary
result set, so the cap was simply too low; it is viewport-relative now and
still bounded.
Both regressions are pinned by tests -- one asserting the callback shape a
caller actually destructures, one asserting the custom renderer replaces the
default markup rather than wrapping it.
2026-07-30 11:28:17 -06:00
|
|
|
resultRenderer={resultRenderer}
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
loading={loading}
|
|
|
|
|
placeholder={placeholder}
|
|
|
|
|
clearable={clearable}
|
|
|
|
|
clearDisabled={clearDisabled}
|
|
|
|
|
inputRef={inputRef}
|
2022-08-06 05:22:07 +00:00
|
|
|
/>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
</div>
|
2022-01-03 15:13:02 -07:00
|
|
|
}
|
2022-01-12 09:38:21 -07:00
|
|
|
|
|
|
|
|
export function WROLModeMessage({content}) {
|
2023-07-21 15:14:09 -06:00
|
|
|
const wrolModeEnabled = useWROLMode();
|
2022-08-06 05:22:07 +00:00
|
|
|
|
2023-07-21 15:14:09 -06:00
|
|
|
if (wrolModeEnabled) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <Message kind='warning' icon='lock' title='WROL Mode Enabled'>{content}</Message>
|
2022-01-12 09:38:21 -07:00
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2022-01-14 16:27:16 -07:00
|
|
|
|
2026-03-12 20:10:57 -06:00
|
|
|
export function DownloadWindowMessage() {
|
|
|
|
|
const {status} = React.useContext(StatusContext);
|
|
|
|
|
const downloads = status ? status.downloads : null;
|
|
|
|
|
|
|
|
|
|
if (downloads && downloads.outside_download_window) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <Message kind='info' icon='history' title='Outside Download Window'>
|
|
|
|
|
Downloads are paused because the current time is outside the configured download window.
|
|
|
|
|
</Message>
|
2026-03-12 20:10:57 -06:00
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-29 14:40:58 -06:00
|
|
|
export function DailyLimitMessage() {
|
|
|
|
|
const {status} = React.useContext(StatusContext);
|
|
|
|
|
const downloads = status ? status.downloads : null;
|
|
|
|
|
|
|
|
|
|
if (downloads && downloads.daily_limit_reached && !downloads.disabled && !downloads.stopped) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <Message kind='info' icon='stop' title='Max Daily Downloads Reached'>
|
|
|
|
|
Downloads are paused because the daily download limit has been reached. Downloads will
|
|
|
|
|
resume tomorrow.
|
|
|
|
|
</Message>
|
2026-07-29 14:40:58 -06:00
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-06 15:15:36 -07:00
|
|
|
export function CookiesUnlockModal({open, onClose, onSuccess}) {
|
|
|
|
|
const [password, setPassword] = useState('');
|
|
|
|
|
const [submitting, setSubmitting] = useState(false);
|
|
|
|
|
const passwordRef = React.useRef(null);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (open) {
|
|
|
|
|
const timer = setTimeout(() => {
|
|
|
|
|
if (passwordRef.current) {
|
|
|
|
|
passwordRef.current.focus();
|
|
|
|
|
}
|
|
|
|
|
}, 100);
|
|
|
|
|
return () => clearTimeout(timer);
|
|
|
|
|
}
|
|
|
|
|
}, [open]);
|
|
|
|
|
|
|
|
|
|
const handleUnlock = async () => {
|
|
|
|
|
setSubmitting(true);
|
|
|
|
|
const result = await unlockCookies(password);
|
|
|
|
|
setSubmitting(false);
|
|
|
|
|
if (result.success) {
|
|
|
|
|
setPassword('');
|
|
|
|
|
if (onSuccess) onSuccess();
|
|
|
|
|
onClose();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return <Modal open={open} onClose={onClose} size='tiny'>
|
|
|
|
|
<Modal.Header>Unlock Cookies</Modal.Header>
|
|
|
|
|
<Modal.Content>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
<TextInput
|
|
|
|
|
ref={passwordRef}
|
|
|
|
|
label='Password'
|
|
|
|
|
type='password'
|
|
|
|
|
placeholder='Enter your encryption password'
|
|
|
|
|
value={password}
|
|
|
|
|
onChange={(e) => setPassword(e.currentTarget.value)}
|
|
|
|
|
onKeyDown={(e) => e.key === 'Enter' && handleUnlock()}
|
|
|
|
|
/>
|
2026-03-06 15:15:36 -07:00
|
|
|
</Modal.Content>
|
|
|
|
|
<Modal.Actions>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
<Button role='cancel' onClick={onClose}>Cancel</Button>
|
2026-03-06 15:15:36 -07:00
|
|
|
<Button
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
role='save'
|
|
|
|
|
icon='unlock'
|
2026-03-06 15:15:36 -07:00
|
|
|
onClick={handleUnlock}
|
|
|
|
|
loading={submitting}
|
|
|
|
|
disabled={!password || submitting}
|
|
|
|
|
>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
Unlock
|
2026-03-06 15:15:36 -07:00
|
|
|
</Button>
|
|
|
|
|
</Modal.Actions>
|
|
|
|
|
</Modal>;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-20 14:37:58 -07:00
|
|
|
export function CookiesLockedMessage() {
|
|
|
|
|
const {settings} = React.useContext(SettingsContext);
|
|
|
|
|
const {status} = React.useContext(StatusContext);
|
|
|
|
|
const flags = status?.flags || {};
|
|
|
|
|
|
2026-03-06 15:15:36 -07:00
|
|
|
const [modalOpen, setModalOpen] = useState(false);
|
|
|
|
|
|
2026-02-20 14:37:58 -07:00
|
|
|
if (!flags.cookies_exist || flags.cookies_unlocked || settings?.wrol_mode) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-06 15:15:36 -07:00
|
|
|
return <>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
<Message kind='warning' icon='lock' title='Cookies Locked'>
|
|
|
|
|
You have encrypted cookies stored, but they are currently locked.
|
|
|
|
|
<Button role='cancel' icon='unlock' size='xs' style={{marginLeft: '0.7em'}}
|
|
|
|
|
onClick={() => setModalOpen(true)}>
|
|
|
|
|
Unlock Cookies
|
|
|
|
|
</Button>
|
2026-03-06 15:15:36 -07:00
|
|
|
</Message>
|
|
|
|
|
|
|
|
|
|
<CookiesUnlockModal open={modalOpen} onClose={() => setModalOpen(false)}/>
|
|
|
|
|
</>;
|
2026-02-20 14:37:58 -07:00
|
|
|
}
|
|
|
|
|
|
2022-01-14 16:27:16 -07:00
|
|
|
// Thanks https://www.npmjs.com/package/text-ellipsis
|
2022-08-06 05:22:07 +00:00
|
|
|
export function textEllipsis(str, maxLength = 100, {side = "end", ellipsis = "..."} = {}) {
|
|
|
|
|
if (str && str.length > maxLength) {
|
2022-01-25 08:51:55 -07:00
|
|
|
switch (side) {
|
|
|
|
|
case "start":
|
|
|
|
|
return ellipsis + str.slice(-(maxLength - ellipsis.length));
|
|
|
|
|
case "end":
|
|
|
|
|
default:
|
|
|
|
|
return str.slice(0, maxLength - ellipsis.length) + ellipsis;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return str;
|
2022-01-14 16:27:16 -07:00
|
|
|
}
|
2022-01-29 21:24:39 -07:00
|
|
|
|
Consolidate search options into a single Filter modal (#497)
* Consolidate search options into a single Filter modal
Reworks the file-search UI on the Dashboard, Videos, Archives, and Docs
pages. The crowded row of controls (sort, tags, limit, file-type filter,
date selector) is replaced with a single "Filter" button that opens one
comprehensive modal.
- Add SearchFilterModal + SearchFilterButton (violet + count badge when
active). Sections (Sort, File Type, Tags, Results Per Page, Published
Date) are shown per-page via props; layout uses a Semantic Grid.
- Selections are drafted locally and applied in a single updateQuery only
on close/Done, so the search isn't re-run on every field change.
- Results Per Page and Sort use buttons (fewer clicks, no clipped dropdown).
- Extract shared SearchControlBar (view toggle + input + Filter) for the
three results pages; move the global-search view toggle onto the tab row.
- Rework the Dashboard search line into one adaptive flex row; clear button
only shows when there's an active search.
- Remove now-dead FilesView limit/tag returns and SearchLimitDropdown.
* Address review: reset limit on Clear All; use replace over replaceAll
- handleClearAll now resets Results Per Page to the default page size
(DEFAULT_SEARCH_LIMIT = 24) so "Clear All" actually clears every setting.
- Replace start-anchored replaceAll(/^-/g) with replace(/^-/) for the sort key.
- Add a test covering the Clear All limit reset.
* Remove now-unused Media import from Files.js
The FilesSearchView refactor dropped the last <Media> usage in this file,
leaving an unused import (a build warning). Remove it.
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 19:49:15 -06:00
|
|
|
export function TabLinks({links, right}) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <TabBar right={right}>
|
2022-08-06 05:22:07 +00:00
|
|
|
{links.map((link) => <NavLink
|
2026-03-17 18:35:57 -06:00
|
|
|
to={link.to}
|
2022-08-06 05:22:07 +00:00
|
|
|
key={link.to}
|
|
|
|
|
end={link.end === true ? true : null}
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
className={({isActive}) => tabClassName(link.isActive ? link.isActive() : isActive)}
|
2022-08-06 05:22:07 +00:00
|
|
|
>
|
|
|
|
|
{link.text}
|
|
|
|
|
</NavLink>)}
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
</TabBar>
|
2022-01-29 21:24:39 -07:00
|
|
|
}
|
2022-01-31 09:32:06 -07:00
|
|
|
|
|
|
|
|
export function PageContainer(props) {
|
2023-01-07 18:31:39 -07:00
|
|
|
return <>
|
|
|
|
|
<Media at='mobile'>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
<div style={{marginTop: '1em', padding: 0}}>{props.children}</div>
|
2023-01-07 18:31:39 -07:00
|
|
|
</Media>
|
|
|
|
|
<Media greaterThanOrEqual='tablet'>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
<div style={{marginTop: '1em', padding: '1em'}}>{props.children}</div>
|
2023-01-07 18:31:39 -07:00
|
|
|
</Media>
|
|
|
|
|
</>;
|
2022-01-31 09:32:06 -07:00
|
|
|
}
|
2022-01-31 09:53:17 -07:00
|
|
|
|
|
|
|
|
export function CardGroupCentered(props) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
// One responsive grid; it centres what it cannot fill, so the two viewports no
|
|
|
|
|
// longer need separate markup.
|
2023-02-17 16:09:24 -07:00
|
|
|
return <div style={{marginTop: '1em'}}>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
<CardGroup>{props.children}</CardGroup>
|
2023-02-17 16:09:24 -07:00
|
|
|
</div>
|
2022-01-31 09:53:17 -07:00
|
|
|
}
|
2022-02-04 13:55:13 -07:00
|
|
|
|
2025-12-24 12:30:04 -07:00
|
|
|
/**
|
|
|
|
|
* Resolve a filename-only path to a full relative path using the file's directory.
|
|
|
|
|
* Paths in FileGroup.data are stored as filenames only for performance (fast moves/renames).
|
|
|
|
|
* This function resolves them to full relative paths suitable for /media/ URLs.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} path - The path to resolve (may be filename-only or already a full path)
|
|
|
|
|
* @param {string} directory - The directory to prepend if path is filename-only
|
|
|
|
|
* @returns {string|null} - The resolved path, or null if path is falsy
|
|
|
|
|
*/
|
|
|
|
|
export function resolveDataPath(path, directory) {
|
|
|
|
|
if (!path) return null;
|
|
|
|
|
if (path.includes('/')) return path; // Already a full relative path
|
|
|
|
|
return directory ? `${directory}/${path}` : path;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-29 13:46:39 -06:00
|
|
|
export function findPosterPath(file) {
|
|
|
|
|
if (!file) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-12-24 12:30:04 -07:00
|
|
|
const {files, poster_path, cover_path, screenshot_path, video, directory} = file;
|
|
|
|
|
|
2023-03-29 13:46:39 -06:00
|
|
|
if (poster_path) {
|
|
|
|
|
return poster_path;
|
|
|
|
|
}
|
|
|
|
|
if (cover_path) {
|
|
|
|
|
return cover_path;
|
|
|
|
|
}
|
|
|
|
|
if (screenshot_path) {
|
|
|
|
|
return screenshot_path;
|
|
|
|
|
}
|
2025-12-24 12:30:04 -07:00
|
|
|
// video.poster_path is already a full relative path (from Video.__json__)
|
|
|
|
|
if (video && video['poster_path']) {
|
|
|
|
|
return video['poster_path'];
|
|
|
|
|
}
|
|
|
|
|
// data paths are filename-only, need to resolve with directory
|
2023-04-03 11:17:14 -06:00
|
|
|
if (file['data'] && file['data']['cover_path']) {
|
|
|
|
|
// Ebook.
|
2025-12-24 12:30:04 -07:00
|
|
|
return resolveDataPath(file['data']['cover_path'], directory);
|
2023-04-03 11:17:14 -06:00
|
|
|
}
|
2025-12-22 16:55:15 -07:00
|
|
|
if (file['data'] && file['data']['poster_path']) {
|
2025-12-24 12:30:04 -07:00
|
|
|
// PDF or Video (cached).
|
|
|
|
|
return resolveDataPath(file['data']['poster_path'], directory);
|
2025-12-22 16:55:15 -07:00
|
|
|
}
|
2025-12-24 12:30:04 -07:00
|
|
|
if (file['data'] && file['data']['screenshot_path']) {
|
|
|
|
|
// Archive.
|
|
|
|
|
return resolveDataPath(file['data']['screenshot_path'], directory);
|
2023-03-29 13:46:39 -06:00
|
|
|
}
|
2025-12-24 12:30:04 -07:00
|
|
|
// files[].path is already resolved by my_files() on the backend
|
2023-03-29 13:46:39 -06:00
|
|
|
if (!_.isEmpty(files)) {
|
|
|
|
|
for (let i = 0; i < files.length; i++) {
|
|
|
|
|
const file = files[i];
|
|
|
|
|
if (file['mimetype'] && file['mimetype'].startsWith('image/')) {
|
|
|
|
|
// Found an image file, use that as the poster.
|
|
|
|
|
return file['path'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function CardPoster({to, file}) {
|
|
|
|
|
// Used to center posters in CardIcon.
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
const style = {display: 'flex', justifyContent: 'center'};
|
2023-07-27 15:53:47 -06:00
|
|
|
const navigate = useNavigate();
|
2023-03-29 13:46:39 -06:00
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
// Marks a tagged file, pinned to the poster's corner.
|
|
|
|
|
const cardTagIcon = <div className='wrolpi-card-tag'><Icon name='tag' size={14} label='Tagged'/></div>;
|
2023-03-29 13:46:39 -06:00
|
|
|
let imageLabel = !_.isEmpty(file.tags) ? cardTagIcon : null;
|
|
|
|
|
|
|
|
|
|
let posterPath = findPosterPath(file);
|
|
|
|
|
|
2023-08-04 11:32:47 -06:00
|
|
|
if (posterPath) {
|
|
|
|
|
// FileGroup has a poster (screenshot/thumbnail) file.
|
|
|
|
|
posterPath = `/media/${encodeMediaPath(posterPath)}`;
|
|
|
|
|
|
|
|
|
|
const image = <>
|
|
|
|
|
{/* Replicate <Image label/> but with maxHeight applied to image */}
|
|
|
|
|
{imageLabel}
|
2024-01-01 17:11:09 -07:00
|
|
|
<img alt='poster' src={posterPath} style={{maxHeight: '163px', maxWidth: '290px', width: 'auto'}}/>
|
2023-08-04 11:32:47 -06:00
|
|
|
</>;
|
|
|
|
|
|
|
|
|
|
if (to) {
|
|
|
|
|
// Link within this App.
|
|
|
|
|
return <Link to={to} style={style}>
|
2023-03-29 13:46:39 -06:00
|
|
|
{image}
|
2023-08-04 11:32:47 -06:00
|
|
|
</Link>
|
|
|
|
|
} else {
|
|
|
|
|
// Preview the file.
|
|
|
|
|
return <div style={style}>
|
|
|
|
|
<PreviewLink file={file}>
|
|
|
|
|
{image}
|
|
|
|
|
</PreviewLink>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// FileGroup has no poster.
|
|
|
|
|
if (!to || (to.startsWith('/media/') || to.startsWith('/download/'))) {
|
|
|
|
|
// "to" is a downloadable file outside the app, preview the file.
|
|
|
|
|
return <PreviewLink file={file}>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
<div className='wrolpi-card-icon'>
|
2023-08-04 11:32:47 -06:00
|
|
|
{imageLabel}
|
|
|
|
|
<FileIcon file={file}/>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
</div>
|
2023-03-29 13:46:39 -06:00
|
|
|
</PreviewLink>
|
2023-08-04 11:32:47 -06:00
|
|
|
} else if (!posterPath && to) {
|
|
|
|
|
// Link to the full page in this App.
|
|
|
|
|
return <Link to={to}>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
<div className='wrolpi-card-icon' onClick={() => navigate(to)}>
|
2023-08-04 11:32:47 -06:00
|
|
|
{imageLabel}
|
|
|
|
|
<FileIcon file={file}/>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
</div>
|
2023-08-04 11:32:47 -06:00
|
|
|
</Link>
|
|
|
|
|
}
|
2022-12-09 11:22:20 -07:00
|
|
|
}
|
2022-11-08 22:42:00 -07:00
|
|
|
}
|
|
|
|
|
|
2025-01-24 14:28:04 -07:00
|
|
|
export function InfoPopup({
|
2025-01-23 17:47:11 -07:00
|
|
|
icon = 'info circle',
|
2025-01-19 11:58:43 -07:00
|
|
|
size = null,
|
|
|
|
|
content,
|
|
|
|
|
position = 'left center',
|
2025-01-23 17:47:11 -07:00
|
|
|
iconSize = null,
|
2025-01-22 17:48:44 -07:00
|
|
|
header = '',
|
2026-01-23 19:51:02 -07:00
|
|
|
iconStyle = { margin: '0.5em'},
|
2025-12-24 15:45:53 -07:00
|
|
|
...props
|
2025-01-19 11:58:43 -07:00
|
|
|
}) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <Tooltip label={header ? <><strong>{header}</strong><br/>{content}</> : content}
|
|
|
|
|
multiline w={260} {...props}>
|
|
|
|
|
<span style={iconStyle}><Icon name={icon} size={iconSize || 'small'}/></span>
|
|
|
|
|
</Tooltip>
|
2022-05-18 19:43:25 -06:00
|
|
|
}
|
|
|
|
|
|
2025-01-24 14:28:04 -07:00
|
|
|
export function InfoHeader({
|
2024-07-30 19:28:53 -06:00
|
|
|
icon,
|
|
|
|
|
headerSize = 'h2',
|
|
|
|
|
iconSize,
|
|
|
|
|
headerContent,
|
|
|
|
|
popupContent,
|
2024-11-02 15:14:02 -06:00
|
|
|
popupPosition = null,
|
2025-12-22 17:56:35 -07:00
|
|
|
popupProps = {},
|
2024-11-02 15:14:02 -06:00
|
|
|
for_ = null,
|
|
|
|
|
required = false,
|
2025-01-22 17:48:44 -07:00
|
|
|
...props
|
2024-07-30 19:28:53 -06:00
|
|
|
}) {
|
2025-01-22 17:48:44 -07:00
|
|
|
return <div className='inline-header' {...props}>
|
2025-01-11 12:04:22 -07:00
|
|
|
<label htmlFor={for_}>
|
2024-11-02 15:14:02 -06:00
|
|
|
<Header as={headerSize}>{headerContent} {required && <RequiredAsterisk/>}</Header>
|
|
|
|
|
</label>
|
2022-08-06 05:22:07 +00:00
|
|
|
<span>
|
2025-12-22 17:56:35 -07:00
|
|
|
<InfoPopup content={popupContent} iconSize={iconSize} icon={icon} position={popupPosition} {...popupProps}/>
|
2024-06-25 22:12:13 -06:00
|
|
|
</span>
|
2023-02-17 16:09:24 -07:00
|
|
|
</div>
|
2022-05-18 19:43:25 -06:00
|
|
|
}
|
|
|
|
|
|
2026-03-11 15:42:52 -06:00
|
|
|
export function HelpModal({
|
|
|
|
|
icon = 'help circle',
|
|
|
|
|
iconSize = null,
|
|
|
|
|
iconStyle = {margin: '0.5em'},
|
|
|
|
|
helpPath,
|
|
|
|
|
title = null,
|
|
|
|
|
modalSize = 'fullscreen',
|
|
|
|
|
}) {
|
|
|
|
|
const [open, setOpen] = useState(false);
|
|
|
|
|
const src = `${HELP_VIEWER_URI}${helpPath}`;
|
|
|
|
|
const style = {position: 'relative', height: '75vh', width: '100%', border: 'none'};
|
|
|
|
|
|
|
|
|
|
return <>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
<IconButton icon={icon} label={title || 'Help'} variant='subtle'
|
|
|
|
|
style={iconStyle} onClick={() => setOpen(true)}/>
|
2026-03-11 15:42:52 -06:00
|
|
|
<Modal open={open} onClose={() => setOpen(false)} size={modalSize} closeIcon>
|
|
|
|
|
{title && <Modal.Header>{title}</Modal.Header>}
|
|
|
|
|
<Modal.Content>
|
|
|
|
|
<IframeViewer title={title} src={src} style={style}/>
|
|
|
|
|
</Modal.Content>
|
|
|
|
|
</Modal>
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function HelpHeader({
|
|
|
|
|
icon,
|
|
|
|
|
headerSize = 'h2',
|
|
|
|
|
iconSize,
|
|
|
|
|
headerContent,
|
|
|
|
|
helpPath,
|
|
|
|
|
helpTitle,
|
|
|
|
|
helpModalProps = {},
|
|
|
|
|
for_ = null,
|
|
|
|
|
required = false,
|
|
|
|
|
...props
|
|
|
|
|
}) {
|
|
|
|
|
return <div className='inline-header' {...props}>
|
|
|
|
|
<label htmlFor={for_}>
|
|
|
|
|
<Header as={headerSize}>{headerContent} {required && <RequiredAsterisk/>}</Header>
|
|
|
|
|
</label>
|
|
|
|
|
<span>
|
|
|
|
|
<HelpModal helpPath={helpPath} iconSize={iconSize} icon={icon} title={helpTitle} {...helpModalProps}/>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-29 18:21:03 -06:00
|
|
|
// All the hardware toggles share this shape: a Toggle whose state comes from a
|
|
|
|
|
// subsystem hook, disabled when the status is unknown, with an InfoPopup explaining
|
|
|
|
|
// why it cannot be used. `confirmStop` asks before switching off.
|
|
|
|
|
function SubsystemToggle({label, on, onChange, unsupportedMessage, info = null, disabled = null, confirmStop = null}) {
|
2026-07-29 14:57:28 -06:00
|
|
|
const [confirmOpen, setConfirmOpen] = React.useState(false);
|
2026-07-29 18:21:03 -06:00
|
|
|
const unsupported = on === null;
|
2026-07-29 14:57:28 -06:00
|
|
|
|
|
|
|
|
const handleChange = (checked) => {
|
2026-07-29 18:21:03 -06:00
|
|
|
if (!checked && confirmStop) {
|
2026-07-29 14:57:28 -06:00
|
|
|
setConfirmOpen(true);
|
2026-07-29 18:21:03 -06:00
|
|
|
} else {
|
|
|
|
|
onChange(checked);
|
2026-07-29 14:57:28 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-29 18:21:03 -06:00
|
|
|
const handleConfirm = (e) => {
|
2026-07-29 14:57:28 -06:00
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
}
|
|
|
|
|
setConfirmOpen(false);
|
2026-07-29 18:21:03 -06:00
|
|
|
onChange(false);
|
2026-07-29 14:57:28 -06:00
|
|
|
}
|
|
|
|
|
|
2026-07-29 18:21:03 -06:00
|
|
|
const popup = unsupported ? unsupportedMessage : info;
|
|
|
|
|
|
2026-07-29 14:57:28 -06:00
|
|
|
return <div style={{margin: '0.5em'}}>
|
2026-07-29 18:21:03 -06:00
|
|
|
{confirmStop && <Confirm
|
2026-07-29 14:57:28 -06:00
|
|
|
open={confirmOpen}
|
|
|
|
|
onCancel={() => setConfirmOpen(false)}
|
2026-07-29 18:21:03 -06:00
|
|
|
onConfirm={handleConfirm}
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
title={confirmStop.header}
|
|
|
|
|
confirmLabel={confirmStop.button}
|
|
|
|
|
destructive
|
|
|
|
|
>
|
|
|
|
|
{confirmStop.content}
|
|
|
|
|
</Confirm>}
|
2026-07-29 14:57:28 -06:00
|
|
|
<Toggle
|
2026-07-29 18:21:03 -06:00
|
|
|
label={label}
|
|
|
|
|
disabled={disabled === null ? unsupported : disabled}
|
2026-07-29 14:57:28 -06:00
|
|
|
checked={on === true}
|
|
|
|
|
onChange={handleChange}
|
|
|
|
|
/>
|
2026-07-29 18:21:03 -06:00
|
|
|
{popup && <InfoPopup content={popup}/>}
|
2026-07-29 14:57:28 -06:00
|
|
|
</div>;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-29 18:21:03 -06:00
|
|
|
export function HotspotToggle() {
|
|
|
|
|
const {on, setHotspot} = useHotspot();
|
|
|
|
|
return <SubsystemToggle
|
|
|
|
|
label='WiFi Hotspot'
|
|
|
|
|
on={on}
|
|
|
|
|
onChange={setHotspot}
|
|
|
|
|
unsupportedMessage='Hotspot is not supported on this server'
|
|
|
|
|
/>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function ThrottleToggle() {
|
|
|
|
|
const {on, setThrottle} = useThrottle();
|
|
|
|
|
return <SubsystemToggle
|
|
|
|
|
label='CPU Power-save'
|
|
|
|
|
on={on}
|
|
|
|
|
onChange={setThrottle}
|
|
|
|
|
unsupportedMessage='CPU Power-save is not supported on this server'
|
|
|
|
|
/>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function BluetoothToggle() {
|
|
|
|
|
const {on, setBluetooth} = useBluetooth();
|
|
|
|
|
return <SubsystemToggle
|
|
|
|
|
label='Bluetooth'
|
|
|
|
|
on={on}
|
|
|
|
|
onChange={setBluetooth}
|
|
|
|
|
unsupportedMessage='Bluetooth is not supported on this server'
|
|
|
|
|
/>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function DesktopToggle() {
|
|
|
|
|
const {on, setDesktop} = useDesktop();
|
|
|
|
|
return <SubsystemToggle
|
|
|
|
|
label='Desktop'
|
|
|
|
|
on={on}
|
|
|
|
|
onChange={setDesktop}
|
|
|
|
|
unsupportedMessage='The Desktop is not supported on this server'
|
|
|
|
|
// Stopping the desktop kills any session on this WROLPi's own screen.
|
|
|
|
|
confirmStop={{
|
|
|
|
|
header: 'Stop the desktop',
|
|
|
|
|
content: "Anyone using this WROLPi's own screen will lose their session and the display will"
|
|
|
|
|
+ ' drop to a terminal. The desktop will return on the next reboot. Are you sure?',
|
|
|
|
|
button: 'Stop',
|
|
|
|
|
}}
|
|
|
|
|
/>;
|
|
|
|
|
}
|
|
|
|
|
|
controller: VNC toggle, gated on the Desktop running
Add a VNC toggle to the Controller (both UIs) that starts/stops whichever VNC
backend is installed: wayvnc for Wayland (Raspberry Pi OS), RealVNC for X11.
Runtime-only, like the Desktop toggle: the unit is never enabled, so VNC does
not return after a reboot. Users who want it permanently on can enable it with
raspi-config.
VNC serves the desktop session, so starting it without a desktop gives clients
a blank screen. The gate lives in the backend, not just the UI, so curl callers
get it too (409, distinct from a systemctl failure). Stopping is never gated so
a running VNC server can't be stranded on with no way to turn it off.
Backend selection deliberately avoids raspi-config's live-compositor probe
(pgrep labwc), which reports X11 — and would pick the wrong backend — whenever
the desktop is stopped. wayvnc also requires its config to exist; that is
checked directly rather than via the unit's ConditionResult, which reports 'no'
for any unit that has never been started.
Extracts _unit_properties()/_systemctl_unit() so Desktop and VNC share one
systemd probe and start/stop path.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 16:53:45 -06:00
|
|
|
export function VncToggle() {
|
2026-07-29 18:21:03 -06:00
|
|
|
const {on, desktopRunning, setVnc} = useVnc();
|
controller: VNC toggle, gated on the Desktop running
Add a VNC toggle to the Controller (both UIs) that starts/stops whichever VNC
backend is installed: wayvnc for Wayland (Raspberry Pi OS), RealVNC for X11.
Runtime-only, like the Desktop toggle: the unit is never enabled, so VNC does
not return after a reboot. Users who want it permanently on can enable it with
raspi-config.
VNC serves the desktop session, so starting it without a desktop gives clients
a blank screen. The gate lives in the backend, not just the UI, so curl callers
get it too (409, distinct from a systemctl failure). Stopping is never gated so
a running VNC server can't be stranded on with no way to turn it off.
Backend selection deliberately avoids raspi-config's live-compositor probe
(pgrep labwc), which reports X11 — and would pick the wrong backend — whenever
the desktop is stopped. wayvnc also requires its config to exist; that is
checked directly rather than via the unit's ConditionResult, which reports 'no'
for any unit that has never been started.
Extracts _unit_properties()/_systemctl_unit() so Desktop and VNC share one
systemd probe and start/stop path.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 16:53:45 -06:00
|
|
|
const unsupported = on === null;
|
|
|
|
|
// VNC serves the desktop session; it cannot be started without one. Stopping
|
|
|
|
|
// stays available so a running VNC server is never stranded on.
|
|
|
|
|
const blockedByDesktop = !desktopRunning && on !== true;
|
|
|
|
|
|
|
|
|
|
let info = null;
|
2026-07-29 18:21:03 -06:00
|
|
|
if (blockedByDesktop) {
|
controller: VNC toggle, gated on the Desktop running
Add a VNC toggle to the Controller (both UIs) that starts/stops whichever VNC
backend is installed: wayvnc for Wayland (Raspberry Pi OS), RealVNC for X11.
Runtime-only, like the Desktop toggle: the unit is never enabled, so VNC does
not return after a reboot. Users who want it permanently on can enable it with
raspi-config.
VNC serves the desktop session, so starting it without a desktop gives clients
a blank screen. The gate lives in the backend, not just the UI, so curl callers
get it too (409, distinct from a systemctl failure). Stopping is never gated so
a running VNC server can't be stranded on with no way to turn it off.
Backend selection deliberately avoids raspi-config's live-compositor probe
(pgrep labwc), which reports X11 — and would pick the wrong backend — whenever
the desktop is stopped. wayvnc also requires its config to exist; that is
checked directly rather than via the unit's ConditionResult, which reports 'no'
for any unit that has never been started.
Extracts _unit_properties()/_systemctl_unit() so Desktop and VNC share one
systemd probe and start/stop path.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 16:53:45 -06:00
|
|
|
info = 'Start the Desktop before starting VNC';
|
|
|
|
|
} else if (on === true && !desktopRunning) {
|
|
|
|
|
info = 'The Desktop is stopped, so VNC clients will see nothing';
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-29 18:21:03 -06:00
|
|
|
return <SubsystemToggle
|
|
|
|
|
label='VNC'
|
|
|
|
|
on={on}
|
|
|
|
|
onChange={setVnc}
|
|
|
|
|
unsupportedMessage='VNC is not supported on this server'
|
|
|
|
|
info={info}
|
|
|
|
|
disabled={unsupported || blockedByDesktop}
|
|
|
|
|
/>;
|
controller: VNC toggle, gated on the Desktop running
Add a VNC toggle to the Controller (both UIs) that starts/stops whichever VNC
backend is installed: wayvnc for Wayland (Raspberry Pi OS), RealVNC for X11.
Runtime-only, like the Desktop toggle: the unit is never enabled, so VNC does
not return after a reboot. Users who want it permanently on can enable it with
raspi-config.
VNC serves the desktop session, so starting it without a desktop gives clients
a blank screen. The gate lives in the backend, not just the UI, so curl callers
get it too (409, distinct from a systemctl failure). Stopping is never gated so
a running VNC server can't be stranded on with no way to turn it off.
Backend selection deliberately avoids raspi-config's live-compositor probe
(pgrep labwc), which reports X11 — and would pick the wrong backend — whenever
the desktop is stopped. wayvnc also requires its config to exist; that is
checked directly rather than via the unit's ConditionResult, which reports 'no'
for any unit that has never been started.
Extracts _unit_properties()/_systemctl_unit() so Desktop and VNC share one
systemd probe and start/stop path.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 16:53:45 -06:00
|
|
|
}
|
|
|
|
|
|
2026-01-31 12:54:27 -07:00
|
|
|
export function Toggle({label, checked, disabled, onChange, icon, popupContent = null, info = null}) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
// Keeps this call signature -- `onChange` receives the new boolean, not an event --
|
|
|
|
|
// because a dozen call sites are written against it.
|
|
|
|
|
const body = <span style={{display: 'inline-flex', alignItems: 'center', gap: 6}}>
|
|
|
|
|
<UIToggle
|
|
|
|
|
label={<span style={{display: 'inline-flex', alignItems: 'center', gap: 6}}>
|
|
|
|
|
{icon && <Icon name={icon}/>}
|
|
|
|
|
{label}
|
|
|
|
|
</span>}
|
|
|
|
|
checked={checked === true}
|
|
|
|
|
disabled={disabled === true}
|
|
|
|
|
onChange={(e) => onChange && onChange(e.currentTarget.checked)}
|
|
|
|
|
data-testid='toggle'
|
|
|
|
|
/>
|
|
|
|
|
{info && <InfoPopup content={info}/>}
|
|
|
|
|
</span>;
|
2025-02-02 10:16:11 -07:00
|
|
|
|
|
|
|
|
if (popupContent) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <Tooltip label={popupContent}>{body}</Tooltip>
|
2025-02-02 10:16:11 -07:00
|
|
|
}
|
|
|
|
|
return body
|
2022-02-07 13:37:58 -07:00
|
|
|
}
|
|
|
|
|
|
2022-02-04 13:55:13 -07:00
|
|
|
export function DisableDownloadsToggle() {
|
2023-04-02 14:55:02 -06:00
|
|
|
const [pending, setPending] = React.useState(false);
|
2023-04-01 11:52:41 -06:00
|
|
|
const {status, fetchStatus} = React.useContext(StatusContext);
|
2023-04-02 14:55:02 -06:00
|
|
|
|
|
|
|
|
const {downloads} = status ? status : {downloads: null};
|
2023-07-21 15:14:09 -06:00
|
|
|
const wrolModeEnabled = useWROLMode();
|
2023-04-01 11:52:41 -06:00
|
|
|
|
|
|
|
|
const setDownloads = async (enable) => {
|
2023-04-02 14:55:02 -06:00
|
|
|
setPending(true);
|
|
|
|
|
if (enable) {
|
|
|
|
|
await startDownloads();
|
|
|
|
|
} else {
|
|
|
|
|
await killDownloads();
|
|
|
|
|
}
|
|
|
|
|
await fetchStatus();
|
|
|
|
|
setPending(false);
|
2023-04-01 11:52:41 -06:00
|
|
|
}
|
|
|
|
|
|
2023-04-02 14:55:02 -06:00
|
|
|
const on = downloads && downloads['disabled'] === false && downloads['stopped'] === false;
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <Toggle
|
|
|
|
|
label={on === true ? 'Downloading Enabled' : 'Downloading Disabled'}
|
|
|
|
|
disabled={wrolModeEnabled || pending || downloads === null}
|
|
|
|
|
checked={on === true}
|
|
|
|
|
onChange={setDownloads}
|
|
|
|
|
/>;
|
2022-02-04 13:55:13 -07:00
|
|
|
}
|
2022-02-16 21:57:27 -07:00
|
|
|
|
|
|
|
|
export function emptyToNull(obj) {
|
|
|
|
|
const keys = Object.keys(obj);
|
|
|
|
|
for (let i = 0; i < keys.length; i++) {
|
|
|
|
|
const key = keys[i];
|
|
|
|
|
if (obj[key] === '') {
|
|
|
|
|
obj[key] = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
2022-03-08 13:26:03 -07:00
|
|
|
|
2026-03-17 18:35:57 -06:00
|
|
|
export function mimetypeColor(mimetype, path = '') {
|
2023-01-31 18:08:07 -07:00
|
|
|
if (!mimetype) {
|
|
|
|
|
return 'grey';
|
|
|
|
|
}
|
2022-08-06 05:22:07 +00:00
|
|
|
try {
|
2026-03-17 18:35:57 -06:00
|
|
|
const lowerPath = path.toLowerCase();
|
2022-08-06 05:22:07 +00:00
|
|
|
if (mimetype === 'application/pdf') {
|
|
|
|
|
return 'red'
|
2023-01-31 18:08:07 -07:00
|
|
|
} else if (mimetype.startsWith('video/')) {
|
2022-08-06 05:22:07 +00:00
|
|
|
return 'blue'
|
2023-01-31 18:08:07 -07:00
|
|
|
} else if (mimetype.startsWith('image/')) {
|
2022-08-06 05:22:07 +00:00
|
|
|
return 'pink'
|
2023-01-31 18:08:07 -07:00
|
|
|
} else if (mimetype.startsWith('text/html')) {
|
2022-08-06 05:22:07 +00:00
|
|
|
return 'green'
|
2023-08-17 17:53:29 -06:00
|
|
|
} else if (mimetype.startsWith('application/epub')) {
|
2022-12-09 11:22:20 -07:00
|
|
|
return 'yellow'
|
2026-03-17 18:35:57 -06:00
|
|
|
} else if (mimetype.includes('cbz') || mimetype.includes('cbr')
|
|
|
|
|
|| mimetype.includes('comicbook')
|
|
|
|
|
|| lowerPath.endsWith('.cbz') || lowerPath.endsWith('.cbr')
|
|
|
|
|
|| lowerPath.endsWith('.cbt') || lowerPath.endsWith('.cb7')) {
|
|
|
|
|
return 'yellow'
|
2023-02-22 12:41:41 -07:00
|
|
|
} else if (mimetype.startsWith('audio/')) {
|
|
|
|
|
return 'violet'
|
2026-04-15 13:58:50 -06:00
|
|
|
} else if (mimetype.startsWith('model/') || mimetype.startsWith('application/x-openscad') || mimetype.startsWith('application/sla')
|
|
|
|
|
|| lowerPath.endsWith('.stl') || lowerPath.endsWith('.3mf') || lowerPath.endsWith('.obj') || lowerPath.endsWith('.scad')) {
|
|
|
|
|
return 'teal'
|
2023-08-17 17:53:29 -06:00
|
|
|
} else if (isZipMimetype(mimetype)) {
|
|
|
|
|
return 'purple'
|
2022-08-06 05:22:07 +00:00
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error(e);
|
|
|
|
|
console.error('Unable to choose mimetype color');
|
|
|
|
|
}
|
|
|
|
|
return 'grey'
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-15 21:20:23 -07:00
|
|
|
export function isZipMimetype(mimetype) {
|
2023-02-15 21:35:29 -07:00
|
|
|
return mimetype.startsWith('application/zip') || mimetype.startsWith('application/zlib') || mimetype.startsWith('application/x-7z-compressed') || mimetype.startsWith('application/x-bzip2') || mimetype.startsWith('application/x-xz') || mimetype.startsWith('application/gzip') || mimetype.startsWith('application/x-rar');
|
2023-02-15 21:20:23 -07:00
|
|
|
}
|
|
|
|
|
|
2026-03-15 12:58:40 -06:00
|
|
|
export function isSupportedArchive(mimetype, lowerPath) {
|
|
|
|
|
// Zip is always supported.
|
|
|
|
|
if (mimetype.startsWith('application/zip') || mimetype.startsWith('application/zlib')) return true;
|
|
|
|
|
if (mimetype.startsWith('application/x-tar')) return true;
|
|
|
|
|
// Suffix-based detection for tar variants whose mimetype may be the compression type.
|
|
|
|
|
if (lowerPath.endsWith('.tar') || lowerPath.endsWith('.tar.gz') || lowerPath.endsWith('.tgz') || lowerPath.endsWith('.tar.bz2') || lowerPath.endsWith('.tar.xz')) return true;
|
2026-03-31 12:34:42 -06:00
|
|
|
// 7z and RAR archives.
|
|
|
|
|
if (mimetype.startsWith('application/x-7z-compressed')) return true;
|
|
|
|
|
if (mimetype.startsWith('application/x-rar') || mimetype.startsWith('application/vnd.rar')) return true;
|
|
|
|
|
if (lowerPath.endsWith('.7z') || lowerPath.endsWith('.rar')) return true;
|
2026-03-15 12:58:40 -06:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-18 22:03:45 -06:00
|
|
|
export function mimetypeIconName(mimetype, lowerPath = '') {
|
2022-08-06 05:22:07 +00:00
|
|
|
if (mimetype) {
|
2023-02-16 08:39:34 -07:00
|
|
|
if (mimetype.startsWith('text/html') || mimetype.startsWith('application/json') || mimetype.startsWith('text/yaml') || mimetype.startsWith('text/xml')) {
|
2023-04-18 22:03:45 -06:00
|
|
|
return 'file code';
|
2022-08-06 05:22:07 +00:00
|
|
|
} else if (mimetype.startsWith('application/pdf')) {
|
2023-04-18 22:03:45 -06:00
|
|
|
return 'file pdf';
|
2022-08-06 05:22:07 +00:00
|
|
|
} else if (mimetype.startsWith('text/plain')) {
|
2023-04-18 22:03:45 -06:00
|
|
|
return 'file text';
|
2022-08-06 05:22:07 +00:00
|
|
|
} else if (mimetype.startsWith('image/')) {
|
2023-04-18 22:03:45 -06:00
|
|
|
return 'image';
|
2022-08-06 05:22:07 +00:00
|
|
|
} else if (mimetype.startsWith('video/')) {
|
2023-04-18 22:03:45 -06:00
|
|
|
return 'film';
|
2023-02-15 21:20:23 -07:00
|
|
|
} else if (mimetype.startsWith('message/rfc822')) {
|
2023-04-18 22:03:45 -06:00
|
|
|
return 'mail';
|
2026-04-15 13:58:50 -06:00
|
|
|
} else if (mimetype.startsWith('application/x-openscad') || mimetype.startsWith('model/')
|
|
|
|
|
|| lowerPath.endsWith('.stl') || lowerPath.endsWith('.3mf') || lowerPath.endsWith('.obj') || lowerPath.endsWith('.scad')) {
|
|
|
|
|
return 'cube';
|
2023-02-15 21:20:23 -07:00
|
|
|
} else if (isZipMimetype(mimetype)) {
|
2023-04-18 22:03:45 -06:00
|
|
|
return 'file archive';
|
|
|
|
|
} else if (mimetype.startsWith('application/x-iso9660-image') || mimetype.startsWith('application/x-raw-disk-image') || mimetype.startsWith('application/x-cd-image')) {
|
|
|
|
|
return 'dot circle';
|
2026-03-17 18:35:57 -06:00
|
|
|
} else if (mimetype.startsWith('application/epub') || mimetype.startsWith('application/x-mobipocket-ebook') || mimetype.startsWith('application/vnd.amazon.mobi8-ebook')
|
|
|
|
|
|| mimetype.startsWith('application/vnd.comicbook') || mimetype.startsWith('application/x-cbz') || mimetype.startsWith('application/x-cbr')) {
|
2023-04-18 22:03:45 -06:00
|
|
|
return 'book';
|
2023-01-31 18:08:07 -07:00
|
|
|
} else if (mimetype.startsWith('text/vtt') || mimetype.startsWith('text/srt')) {
|
2023-04-18 22:03:45 -06:00
|
|
|
return 'closed captioning';
|
2023-09-20 12:17:07 -06:00
|
|
|
} else if (mimetype.startsWith('application/x-dosexec') || mimetype.startsWith('application/x-msi') || mimetype.startsWith('application/vnd.microsoft.portable-executable')) {
|
|
|
|
|
return 'windows';
|
2023-02-22 11:48:25 -07:00
|
|
|
} else if (mimetype.startsWith('audio/')) {
|
2023-04-18 22:03:45 -06:00
|
|
|
return 'file audio';
|
|
|
|
|
} else if (mimetype.startsWith('application/vnd.openxmlformats-officedocument.wordprocessingml.document')) {
|
|
|
|
|
return 'file word';
|
|
|
|
|
} else if (mimetype.startsWith('application/x-x509-ca-cert')) {
|
|
|
|
|
return 'certificate';
|
2025-03-21 17:15:05 -06:00
|
|
|
} else if (mimetype.startsWith('application/x-pie-executable')) {
|
|
|
|
|
return 'linux';
|
2023-02-16 08:39:34 -07:00
|
|
|
} else if (mimetype.startsWith('application/octet-stream')) {
|
2023-02-22 12:41:41 -07:00
|
|
|
if (lowerPath.endsWith('.mp3')) {
|
2023-04-18 22:03:45 -06:00
|
|
|
return 'file audio';
|
2023-02-22 12:41:41 -07:00
|
|
|
} else if (lowerPath.endsWith('.stl')) {
|
2023-04-18 22:03:45 -06:00
|
|
|
return 'cube';
|
2023-02-16 08:39:34 -07:00
|
|
|
} else if (lowerPath.endsWith('.blend')) {
|
2023-04-18 22:03:45 -06:00
|
|
|
return 'cube';
|
2023-02-16 08:39:34 -07:00
|
|
|
} else if (lowerPath.endsWith('.dmg')) {
|
2023-04-18 22:03:45 -06:00
|
|
|
return 'apple';
|
2023-02-16 08:39:34 -07:00
|
|
|
} else if (lowerPath.endsWith('.azw3')) {
|
2023-04-18 22:03:45 -06:00
|
|
|
return 'book';
|
2023-09-20 12:17:07 -06:00
|
|
|
} else if (lowerPath.endsWith('.exe')) {
|
|
|
|
|
return 'windows';
|
2023-02-16 08:39:34 -07:00
|
|
|
}
|
2023-05-29 18:04:03 -06:00
|
|
|
} else if (mimetype.startsWith('application/vnd.openxmlformats-officedocument.spreadsheetml.') || mimetype.startsWith('application/vnd.ms-excel') || mimetype.startsWith('application/vnd.oasis.opendocument.spreadsheet')) {
|
|
|
|
|
return 'file excel'
|
|
|
|
|
} else if (mimetype.startsWith('application/vnd.openxmlformats-officedocument.wordprocessingml.') || mimetype.startsWith('application/msword') || mimetype.startsWith('application/vnd.oasis.opendocument.text')) {
|
|
|
|
|
return 'file word'
|
|
|
|
|
} else if (mimetype.startsWith('application/vnd.openxmlformats-officedocument.presentationml.') || mimetype.startsWith('application/vnd.ms-powerpoint') || mimetype.startsWith('application/vnd.oasis.opendocument.presentation')) {
|
|
|
|
|
return 'file powerpoint'
|
2023-09-15 12:02:33 -06:00
|
|
|
} else if (mimetype.startsWith('font/') || mimetype.startsWith('application/font-sfnt') || mimetype.startsWith('application/vnd.ms-fontobject')) {
|
|
|
|
|
return 'font'
|
2022-08-06 05:22:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
2023-04-18 22:03:45 -06:00
|
|
|
if (lowerPath.endsWith('.pem')) {
|
|
|
|
|
return 'certificate';
|
|
|
|
|
}
|
|
|
|
|
return 'file';
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-15 12:58:40 -06:00
|
|
|
const SUFFIX_ICON_MAP = {
|
|
|
|
|
// Code
|
|
|
|
|
html: 'file code', htm: 'file code', json: 'file code', xml: 'file code',
|
|
|
|
|
yaml: 'file code', yml: 'file code', js: 'file code', css: 'file code',
|
|
|
|
|
py: 'file code', sh: 'file code', c: 'file code', cpp: 'file code',
|
|
|
|
|
h: 'file code', java: 'file code', rs: 'file code', go: 'file code',
|
|
|
|
|
ts: 'file code', tsx: 'file code', jsx: 'file code',
|
|
|
|
|
// Documents
|
|
|
|
|
pdf: 'file pdf',
|
|
|
|
|
txt: 'file text', md: 'file text', csv: 'file text', log: 'file text', rst: 'file text',
|
|
|
|
|
doc: 'file word', docx: 'file word', odt: 'file word',
|
|
|
|
|
xls: 'file excel', xlsx: 'file excel', ods: 'file excel',
|
|
|
|
|
ppt: 'file powerpoint', pptx: 'file powerpoint', odp: 'file powerpoint',
|
|
|
|
|
// Media
|
|
|
|
|
jpg: 'image', jpeg: 'image', png: 'image', gif: 'image', svg: 'image',
|
|
|
|
|
bmp: 'image', webp: 'image', ico: 'image', tiff: 'image',
|
|
|
|
|
mp4: 'film', mkv: 'film', avi: 'film', mov: 'film', wmv: 'film', webm: 'film', flv: 'film',
|
|
|
|
|
mp3: 'file audio', wav: 'file audio', flac: 'file audio', ogg: 'file audio',
|
|
|
|
|
aac: 'file audio', wma: 'file audio', m4a: 'file audio',
|
|
|
|
|
vtt: 'closed captioning', srt: 'closed captioning',
|
|
|
|
|
// Archives
|
|
|
|
|
zip: 'file archive', tar: 'file archive', gz: 'file archive', bz2: 'file archive',
|
|
|
|
|
xz: 'file archive', '7z': 'file archive', rar: 'file archive', tgz: 'file archive',
|
|
|
|
|
// Books
|
|
|
|
|
epub: 'book', mobi: 'book', azw3: 'book',
|
|
|
|
|
// 3D
|
|
|
|
|
stl: 'cube', blend: 'cube', scad: 'cube',
|
|
|
|
|
// Platform
|
|
|
|
|
exe: 'windows', msi: 'windows',
|
|
|
|
|
dmg: 'apple',
|
|
|
|
|
iso: 'dot circle', img: 'dot circle',
|
|
|
|
|
// Certs
|
|
|
|
|
pem: 'certificate', crt: 'certificate', cer: 'certificate',
|
|
|
|
|
// Email
|
|
|
|
|
eml: 'mail',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function fileSuffixIconName(filename) {
|
|
|
|
|
const dot = filename.lastIndexOf('.');
|
|
|
|
|
if (dot >= 0) {
|
|
|
|
|
const ext = filename.substring(dot + 1).toLowerCase();
|
|
|
|
|
return SUFFIX_ICON_MAP[ext] || 'file';
|
|
|
|
|
}
|
|
|
|
|
return 'file';
|
|
|
|
|
}
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
export function FileIcon({file, disabled = true, size = 48, ...props}) {
|
2023-04-18 22:03:45 -06:00
|
|
|
const {mimetype, path, primary_path} = file;
|
|
|
|
|
// `file` may be a file_group or a file.
|
|
|
|
|
const lowerPath = primary_path ? primary_path.toLocaleString() : path.toLowerCase();
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
const name = mimetypeIconName(mimetype, lowerPath);
|
|
|
|
|
// The mimetype picks a hue; the token picks what that hue is in this theme.
|
|
|
|
|
const color = mimetypeColor(mimetype, lowerPath);
|
|
|
|
|
return <Icon
|
|
|
|
|
name={name}
|
|
|
|
|
size={size}
|
|
|
|
|
style={{color: `var(--${color})`, opacity: disabled ? 0.75 : 1}}
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
2022-08-06 05:22:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function LoadStatistic({label, value, cores, ...props}) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
// Load is a warning above half the cores, and a problem above three quarters.
|
2022-08-06 05:22:07 +00:00
|
|
|
const quarter = cores / 4;
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
let color;
|
2022-08-06 05:22:07 +00:00
|
|
|
if (cores && value >= (quarter * 3)) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
color = 'red';
|
2022-08-06 05:22:07 +00:00
|
|
|
} else if (cores && value >= (quarter * 2)) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
color = 'orange';
|
2022-08-06 05:22:07 +00:00
|
|
|
}
|
2022-09-28 14:56:06 -06:00
|
|
|
return <Statistic
|
|
|
|
|
label={label}
|
|
|
|
|
value={value ? parseFloat(value).toFixed(1) : '?'}
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
color={color}
|
2022-09-28 14:56:06 -06:00
|
|
|
{...props}/>;
|
2022-08-06 05:22:07 +00: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
|
|
|
export function DarkModeToggle() {
|
|
|
|
|
const {savedTheme, setTheme} = useContext(ThemeContext);
|
|
|
|
|
const active = themeChoices.find(i => i.value === savedTheme) || themeChoices[0];
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <Menu position='bottom-end' withinPortal>
|
|
|
|
|
<Menu.Target>
|
|
|
|
|
<IconButton
|
|
|
|
|
icon={active.icon}
|
|
|
|
|
label={`Theme: ${active.text}`}
|
|
|
|
|
variant='subtle'
|
|
|
|
|
style={{marginRight: '0.8em'}}
|
|
|
|
|
/>
|
|
|
|
|
</Menu.Target>
|
|
|
|
|
<Menu.Dropdown>
|
|
|
|
|
<Menu.Label>Theme</Menu.Label>
|
|
|
|
|
{themeChoices.map(choice => <Menu.Item
|
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
|
|
|
key={choice.value}
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
leftSection={<Icon name={choice.icon}/>}
|
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
|
|
|
onClick={() => setTheme(choice.value)}
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
// The chosen theme is marked by weight as well as color, so the mark
|
|
|
|
|
// survives in the monochrome themes.
|
|
|
|
|
style={choice.value === active.value ? {fontWeight: 700} : undefined}
|
|
|
|
|
>
|
|
|
|
|
{choice.text}
|
|
|
|
|
</Menu.Item>)}
|
|
|
|
|
</Menu.Dropdown>
|
|
|
|
|
</Menu>
|
2022-08-06 05:22:07 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-22 14:27:18 -06:00
|
|
|
|
|
|
|
|
export function UnsupportedModal(header, message, icon) {
|
|
|
|
|
const [open, setOpen] = useState(false);
|
|
|
|
|
const onOpen = () => setOpen(true);
|
|
|
|
|
const onClose = () => setOpen(false);
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
const modal = <Modal open={open} onClose={onClose} size='tiny'>
|
|
|
|
|
<Modal.Header>
|
|
|
|
|
<span style={{display: 'inline-flex', alignItems: 'center', gap: 8}}>
|
|
|
|
|
<Icon name={icon || 'exclamation triangle'}/>
|
|
|
|
|
{header || 'Unsupported'}
|
|
|
|
|
</span>
|
|
|
|
|
</Modal.Header>
|
|
|
|
|
<Modal.Content>{message}</Modal.Content>
|
2025-12-07 11:32:07 -07:00
|
|
|
<Modal.Actions>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
<Button role='cancel' onClick={onClose}>Ok</Button>
|
2025-12-07 11:32:07 -07:00
|
|
|
</Modal.Actions>
|
2022-10-22 14:27:18 -06:00
|
|
|
</Modal>;
|
|
|
|
|
|
|
|
|
|
return {modal, doClose: onClose, doOpen: onOpen};
|
|
|
|
|
}
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
/**
|
|
|
|
|
* The hotspot glyph in the nav bar: a wifi icon with a corner mark for the state.
|
|
|
|
|
* A button, not an anchor -- every one of these opens a dialog or toggles the
|
|
|
|
|
* hotspot, and `<a href='#'>` was neither keyboard-honest nor navigable.
|
|
|
|
|
*/
|
|
|
|
|
function HotspotButton({label, corner, on, onClick}) {
|
|
|
|
|
const wifi = <Icon name='wifi' size='large' style={{opacity: on ? 1 : 0.55}}/>;
|
|
|
|
|
return <IconButton label={label} variant='subtle' onClick={onClick} icon={() =>
|
|
|
|
|
corner
|
|
|
|
|
? <IconStack corner={<Icon name={corner} size={12}/>} label={label}>{wifi}</IconStack>
|
|
|
|
|
: wifi
|
|
|
|
|
}/>
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-19 09:18:53 -06:00
|
|
|
export function HotspotStatusIcon() {
|
2024-07-31 12:41:53 -06:00
|
|
|
const {on, inUse, setHotspot, dockerized, hotspotSsid} = useHotspot();
|
|
|
|
|
const {modal: unsupportedModal, doOpen: openUnsupportedModal} =
|
|
|
|
|
UnsupportedModal('Unsupported', 'You cannot toggle the hotspot on this machine.');
|
2026-07-29 14:57:28 -06:00
|
|
|
const [stopHotspotOpen, setStopHotspotOpen] = React.useState(false);
|
2024-07-31 12:41:53 -06:00
|
|
|
const [inUseOpen, setInUseOpen] = React.useState(false);
|
2022-10-22 14:27:18 -06:00
|
|
|
|
2026-07-29 14:57:28 -06:00
|
|
|
const handleConfirmStop = (e) => {
|
2023-09-24 20:10:09 -06:00
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault()
|
2022-10-19 09:18:53 -06:00
|
|
|
}
|
2026-07-29 14:57:28 -06:00
|
|
|
setStopHotspotOpen(false);
|
2023-09-24 20:10:09 -06:00
|
|
|
setHotspot(false);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-31 12:41:53 -06:00
|
|
|
const handleConfirmInUse = (e) => {
|
|
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
}
|
|
|
|
|
setInUseOpen(false);
|
|
|
|
|
setHotspot(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (inUse === true) {
|
2026-07-29 14:57:28 -06:00
|
|
|
const content = hotspotSsid ? `Wifi device is in use for ${hotspotSsid}. Disconnect and start hotspot?`
|
|
|
|
|
: 'Wifi device is in use. Disconnect and start hotspot?'
|
2024-07-31 12:41:53 -06:00
|
|
|
return <>
|
|
|
|
|
<Confirm open={inUseOpen}
|
|
|
|
|
onCancel={() => setInUseOpen(false)}
|
|
|
|
|
onConfirm={handleConfirmInUse}
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
title='Wifi is in-use'
|
|
|
|
|
confirmLabel='Start Hotspot'
|
|
|
|
|
>
|
|
|
|
|
{content}
|
|
|
|
|
</Confirm>
|
|
|
|
|
<HotspotButton label='Wifi is in use; start the hotspot' corner='exclamation'
|
|
|
|
|
onClick={() => setInUseOpen(true)}/>
|
2024-07-31 12:41:53 -06:00
|
|
|
</>
|
|
|
|
|
} else if (dockerized === false && on === true) {
|
2023-09-24 20:10:09 -06:00
|
|
|
return <>
|
|
|
|
|
<Confirm
|
2026-07-29 14:57:28 -06:00
|
|
|
open={stopHotspotOpen}
|
|
|
|
|
onCancel={() => setStopHotspotOpen(false)}
|
|
|
|
|
onConfirm={handleConfirmStop}
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
title='Stop the hotspot'
|
|
|
|
|
confirmLabel='Stop'
|
|
|
|
|
destructive
|
|
|
|
|
>
|
|
|
|
|
You will be disconnected when using the hotspot. Are you sure?
|
|
|
|
|
</Confirm>
|
|
|
|
|
<HotspotButton label='Hotspot is on; stop it' on
|
|
|
|
|
onClick={() => setStopHotspotOpen(true)}/>
|
2023-09-24 20:10:09 -06:00
|
|
|
</>
|
|
|
|
|
} else if (dockerized === false && on === false) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <HotspotButton label='Hotspot is off; start it' corner='x'
|
|
|
|
|
onClick={() => setHotspot(true)}/>
|
2022-10-19 09:18:53 -06:00
|
|
|
}
|
|
|
|
|
|
2023-09-24 20:10:09 -06:00
|
|
|
// Hotspot is not available, or, status has not yet been fetched.
|
2022-10-22 14:27:18 -06:00
|
|
|
return <>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
<HotspotButton label='Hotspot status is unknown' corner='question'
|
|
|
|
|
onClick={openUnsupportedModal}/>
|
2024-07-31 12:41:53 -06:00
|
|
|
{unsupportedModal}
|
2022-10-22 14:27:18 -06:00
|
|
|
</>
|
2022-10-19 09:18:53 -06:00
|
|
|
}
|
|
|
|
|
|
2026-03-08 09:22:50 -06:00
|
|
|
export function useMediaSession(title, artist, artworkUrl) {
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if ('mediaSession' in navigator && title) {
|
|
|
|
|
const artwork = [];
|
|
|
|
|
if (artworkUrl) {
|
|
|
|
|
artwork.push({src: artworkUrl, type: 'image/jpeg'});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
navigator.mediaSession.metadata = new MediaMetadata({
|
|
|
|
|
title: title,
|
|
|
|
|
artist: artist || '',
|
|
|
|
|
artwork: artwork,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, [title, artist, artworkUrl]);
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-06 05:22:07 +00:00
|
|
|
export function useTitle(title) {
|
|
|
|
|
const documentDefined = typeof document !== 'undefined';
|
|
|
|
|
const originalTitle = React.useRef(documentDefined ? document.title : null);
|
2022-10-25 15:57:44 -06:00
|
|
|
const name = NAME ? `${NAME} WROLPi` : `WROLPi`;
|
2022-08-06 05:22:07 +00:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!documentDefined) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-25 15:57:44 -06:00
|
|
|
const newTitle = `${title} - ${name}`
|
2022-08-06 05:22:07 +00:00
|
|
|
if (title && document.title !== newTitle) {
|
|
|
|
|
document.title = newTitle;
|
|
|
|
|
}
|
|
|
|
|
return () => {
|
|
|
|
|
document.title = originalTitle.current;
|
|
|
|
|
}
|
2022-10-25 15:57:44 -06:00
|
|
|
}, [title]);
|
2022-03-08 13:26:03 -07:00
|
|
|
}
|
2022-11-09 08:33:55 -07:00
|
|
|
|
2024-11-02 15:14:02 -06:00
|
|
|
export function DirectorySearch({onSelect, value, disabled, required, ...props}) {
|
2023-04-18 22:03:45 -06:00
|
|
|
const {
|
|
|
|
|
directoryName,
|
|
|
|
|
setDirectoryName,
|
|
|
|
|
directories,
|
|
|
|
|
channelDirectories,
|
|
|
|
|
domainDirectories,
|
2024-10-02 21:59:33 -06:00
|
|
|
isDir,
|
2023-04-18 22:03:45 -06:00
|
|
|
loading,
|
|
|
|
|
} = useSearchDirectories(value);
|
2025-12-05 18:26:36 -07:00
|
|
|
const [results, setResults] = useState({});
|
2023-04-18 22:03:45 -06:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
2024-10-02 21:59:33 -06:00
|
|
|
if (directories && directories.length >= 0) {
|
|
|
|
|
const newDirectory = isDir ? {} : {
|
|
|
|
|
newDirectory: {
|
|
|
|
|
name: 'New Directory',
|
2026-06-24 15:23:32 -06:00
|
|
|
results: [{title: directoryName || ''}],
|
2024-10-02 21:59:33 -06:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const newResults = {
|
|
|
|
|
...newDirectory,
|
2023-04-18 22:03:45 -06:00
|
|
|
directories: {
|
|
|
|
|
name: 'Directories',
|
|
|
|
|
results: directories.map(i => {
|
|
|
|
|
return {title: i['path']}
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
channel_directories: {
|
|
|
|
|
name: 'Channels',
|
|
|
|
|
results: channelDirectories.map(i => {
|
|
|
|
|
return {title: i['path'], description: i['name']};
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
domain_directories: {
|
|
|
|
|
name: 'Domains',
|
|
|
|
|
results: domainDirectories.map(i => {
|
|
|
|
|
return {title: i['path'], description: i['domain']};
|
|
|
|
|
}),
|
2024-10-02 21:59:33 -06:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
setResults(newResults);
|
2023-04-18 22:03:45 -06:00
|
|
|
}
|
|
|
|
|
}, [
|
|
|
|
|
JSON.stringify(directories),
|
|
|
|
|
JSON.stringify(channelDirectories),
|
|
|
|
|
JSON.stringify(domainDirectories),
|
|
|
|
|
loading,
|
|
|
|
|
]);
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
const handleSearchChange = (value) => {
|
|
|
|
|
setDirectoryName(value);
|
2023-04-18 22:03:45 -06:00
|
|
|
}
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
const handleResultSelect = (result) => {
|
|
|
|
|
setDirectoryName(result.title);
|
2023-04-18 22:03:45 -06:00
|
|
|
// title is the relative path.
|
|
|
|
|
if (onSelect) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
onSelect(result.title);
|
2023-04-18 22:03:45 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-29 22:16:33 -06:00
|
|
|
const handleBlur = (e) => {
|
|
|
|
|
// When user leaves the field, commit the typed value to the form
|
|
|
|
|
if (onSelect && directoryName !== value) {
|
|
|
|
|
onSelect(directoryName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <SearchBox
|
|
|
|
|
placeholder='Search directory names...'
|
|
|
|
|
onChange={handleSearchChange}
|
|
|
|
|
onResultSelect={handleResultSelect}
|
|
|
|
|
onBlur={handleBlur}
|
|
|
|
|
loading={loading}
|
|
|
|
|
value={directoryName || ''}
|
|
|
|
|
results={results}
|
|
|
|
|
disabled={disabled}
|
|
|
|
|
required={required}
|
|
|
|
|
{...props}
|
2024-10-02 21:59:33 -06:00
|
|
|
/>
|
2022-11-09 08:33:55 -07:00
|
|
|
}
|
2022-11-30 19:31:18 -07:00
|
|
|
|
2024-05-31 23:53:30 -06:00
|
|
|
export const BackButton = ({...props}) => {
|
2022-11-30 19:31:18 -07:00
|
|
|
const navigate = useNavigate();
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <Button role='cancel' icon='arrow left' onClick={() => navigate(-1)} {...props}>Back</Button>;
|
2022-11-30 19:31:18 -07:00
|
|
|
}
|
2022-11-30 20:13:54 -07:00
|
|
|
|
2022-12-09 11:22:20 -07:00
|
|
|
export const filterToMimetypes = (filter) => {
|
2023-11-02 15:31:13 -06:00
|
|
|
const zipMimetypes = ['application/zip', 'application/zlib', 'application/x-bzip2', 'application/x-xz', 'application/x-bzip', 'application/x-bzip2', 'application/gzip', 'application/vnd.rar', 'application/x-tar', 'application/x-7z-compressed'];
|
|
|
|
|
const softwareMimetypes = [...zipMimetypes, 'application/x-iso9660-image', 'application/x-executable', 'application/x-dosexec'];
|
|
|
|
|
|
2022-12-09 11:22:20 -07:00
|
|
|
if (filter === 'video') {
|
|
|
|
|
return ['video'];
|
|
|
|
|
} else if (filter === 'archive') {
|
|
|
|
|
return ['text/html'];
|
|
|
|
|
} else if (filter === 'pdf') {
|
|
|
|
|
return ['application/pdf'];
|
2023-02-22 12:41:41 -07:00
|
|
|
} else if (filter === 'audio') {
|
|
|
|
|
return ['audio'];
|
2022-12-09 11:22:20 -07:00
|
|
|
} else if (filter === 'ebook') {
|
|
|
|
|
return ['application/epub+zip', 'application/x-mobipocket-ebook'];
|
2026-03-17 18:35:57 -06:00
|
|
|
} else if (filter === 'doc') {
|
|
|
|
|
return ['application/epub+zip', 'application/x-mobipocket-ebook', 'application/pdf',
|
|
|
|
|
'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
|
|
|
'application/vnd.oasis.opendocument.text', 'application/x-cbz', 'application/x-cbr'];
|
2022-12-09 11:22:20 -07:00
|
|
|
} else if (filter === 'image') {
|
|
|
|
|
return ['image'];
|
|
|
|
|
} else if (filter === 'zip') {
|
2023-11-02 15:31:13 -06:00
|
|
|
return zipMimetypes;
|
2023-04-09 14:13:36 -06:00
|
|
|
} else if (filter === 'model') {
|
2026-04-15 13:58:50 -06:00
|
|
|
return ['application/x-openscad', 'model/stl', 'application/sla', 'model/obj', 'model/3mf'];
|
2023-10-29 21:26:35 -06:00
|
|
|
} else if (filter === 'software') {
|
2023-11-02 15:31:13 -06:00
|
|
|
return softwareMimetypes;
|
2022-12-09 11:22:20 -07:00
|
|
|
}
|
|
|
|
|
}
|
2022-12-15 13:50:58 -07:00
|
|
|
|
|
|
|
|
export const toLocaleString = (num, locale = 'en-US') => {
|
|
|
|
|
return num.toLocaleString(locale);
|
|
|
|
|
}
|
2022-12-19 10:58:45 -07:00
|
|
|
|
2023-03-24 08:58:18 -06:00
|
|
|
function luma(color) {
|
|
|
|
|
let rgb = (typeof color === 'string') ? hexToRGBArray(color) : color;
|
|
|
|
|
return (0.2126 * rgb[0]) + (0.7152 * rgb[1]) + (0.0722 * rgb[2]); // SMPTE C, Rec. 709 weightings
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function hexToRGBArray(color) {
|
|
|
|
|
if (color.length === 7) {
|
|
|
|
|
color = color.slice(1);
|
|
|
|
|
}
|
|
|
|
|
if (color.length !== 6) {
|
|
|
|
|
console.error('Invalid hex color: ' + color);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let rgb = [];
|
|
|
|
|
for (let i = 0; i <= 2; i++) rgb[i] = parseInt(color.substr(i * 2, 2), 16);
|
|
|
|
|
return rgb;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function contrastingColor(color) {
|
|
|
|
|
return (luma(color) >= 120) ? '#000000' : '#dddddd';
|
|
|
|
|
}
|
2023-03-29 13:46:39 -06:00
|
|
|
|
|
|
|
|
export const encodeMediaPath = (path) => {
|
|
|
|
|
// Replace % first to avoid replacing the other replacements.
|
|
|
|
|
path = path.replaceAll('%', '%25');
|
|
|
|
|
|
2023-08-20 16:06:16 -06:00
|
|
|
path = path.replaceAll('&', '%26');
|
2023-08-20 18:50:30 -06:00
|
|
|
path = path.replaceAll('=', '%3d');
|
2023-03-29 13:46:39 -06:00
|
|
|
path = path.replaceAll('#', '%23');
|
|
|
|
|
path = path.replaceAll(' ', '%20');
|
|
|
|
|
return path
|
|
|
|
|
}
|
2023-04-09 14:13:36 -06:00
|
|
|
|
|
|
|
|
export function SortButton({sorts = []}) {
|
|
|
|
|
const {sort, setSort} = useSearchOrder();
|
|
|
|
|
|
|
|
|
|
if (!sorts || (sorts && sorts.length === 0)) {
|
|
|
|
|
console.error('No sorts have been defined!');
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-12 16:09:09 -06:00
|
|
|
const [localSort, setLocalSort] = useState(sort ? sort.replaceAll(/^-/g, '') : null);
|
|
|
|
|
const [desc, setDesc] = useState(sort ? sort.startsWith('-') : true);
|
2023-04-09 14:13:36 -06:00
|
|
|
const [open, setOpen] = useState(false);
|
2023-04-12 16:09:09 -06:00
|
|
|
|
|
|
|
|
// Remove the - from the front of the query sort, it will be added when toggling direction.
|
|
|
|
|
const sortKey = localSort ? localSort.replaceAll(/^-/g, '') : sorts[0]['value'];
|
|
|
|
|
const selectedSort = sorts.find(i => i['value'] === sortKey);
|
2023-04-09 14:13:36 -06:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (localSort) {
|
|
|
|
|
const newSort = desc ? `-${localSort}` : localSort;
|
|
|
|
|
console.debug(`Setting new sort: ${newSort}`)
|
|
|
|
|
setSort(newSort);
|
|
|
|
|
}
|
|
|
|
|
}, [localSort, desc]);
|
|
|
|
|
|
|
|
|
|
const handleSortButton = (o) => {
|
|
|
|
|
setLocalSort(o);
|
|
|
|
|
setOpen(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const toggleDesc = () => {
|
|
|
|
|
setDesc(!desc);
|
2023-04-12 16:09:09 -06:00
|
|
|
if (!localSort) {
|
|
|
|
|
// No sort in URL, use the first.
|
|
|
|
|
setLocalSort(sorts[0]['value']);
|
|
|
|
|
}
|
2023-04-09 14:13:36 -06:00
|
|
|
setOpen(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let sortFields;
|
|
|
|
|
if (sorts && sorts.length) {
|
|
|
|
|
sortFields = sorts.map((i) => {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <Button key={i['value']} role='cancel' fullWidth
|
|
|
|
|
onClick={() => handleSortButton(i['value'])}>{i['text']}</Button>
|
2023-04-09 14:13:36 -06:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return <>
|
|
|
|
|
<Modal closeIcon
|
|
|
|
|
open={open}
|
|
|
|
|
onClose={() => setOpen(false)}
|
|
|
|
|
>
|
2025-12-07 11:32:07 -07:00
|
|
|
<Modal.Header>Sort By</Modal.Header>
|
|
|
|
|
<Modal.Content>
|
2023-04-09 14:13:36 -06:00
|
|
|
{sortFields}
|
2025-12-07 11:32:07 -07:00
|
|
|
</Modal.Content>
|
2023-04-09 14:13:36 -06:00
|
|
|
</Modal>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
<ButtonGroup>
|
|
|
|
|
<IconButton
|
|
|
|
|
icon={desc ? 'arrow down' : 'arrow up'}
|
|
|
|
|
label={desc ? 'Sort descending' : 'Sort ascending'}
|
|
|
|
|
onClick={() => toggleDesc()}
|
|
|
|
|
/>
|
|
|
|
|
<Button role='cancel' onClick={() => setOpen(true)}>
|
|
|
|
|
{selectedSort['short'] || selectedSort['text']}
|
|
|
|
|
</Button>
|
2023-04-09 14:13:36 -06:00
|
|
|
</ButtonGroup>
|
|
|
|
|
</>
|
2023-05-29 18:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function TagIcon() {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <Label color='green' icon='tag' className='wrolpi-tag-icon'/>
|
2023-05-29 18:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function normalizeEstimate(estimate) {
|
2024-01-01 15:16:03 -07:00
|
|
|
if (Number.isInteger(estimate)) {
|
|
|
|
|
return estimate > 999 ? '>999' : estimate.toString();
|
|
|
|
|
}
|
|
|
|
|
return '?';
|
2023-07-21 15:14:09 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function useAPIButton(
|
|
|
|
|
color = 'violet',
|
|
|
|
|
size = 'medium',
|
|
|
|
|
floated,
|
|
|
|
|
onClick,
|
|
|
|
|
disabled,
|
|
|
|
|
confirmContent,
|
|
|
|
|
confirmButton,
|
2024-10-05 14:06:13 -06:00
|
|
|
confirmHeader,
|
2023-07-21 15:14:09 -06:00
|
|
|
themed = true,
|
|
|
|
|
obeyWROLMode = false,
|
|
|
|
|
icon = null,
|
2024-11-02 15:14:02 -06:00
|
|
|
type = 'button',
|
|
|
|
|
id = null,
|
2023-07-21 15:14:09 -06:00
|
|
|
props
|
|
|
|
|
) {
|
|
|
|
|
props = props || {};
|
|
|
|
|
const ref = React.useRef();
|
|
|
|
|
|
|
|
|
|
const [confirmOpen, setConfirmOpen] = React.useState(false);
|
2024-11-02 15:14:02 -06:00
|
|
|
const [loading, setLoading] = React.useState(false);
|
2023-07-21 15:14:09 -06:00
|
|
|
const [showSuccess, setShowSuccess] = React.useState(false);
|
|
|
|
|
const [showFailure, setShowFailure] = React.useState(false);
|
|
|
|
|
|
|
|
|
|
const wrolModeEnabled = useWROLMode();
|
|
|
|
|
|
|
|
|
|
// Disable when API call is pending, or button is disabled.
|
2024-11-02 15:14:02 -06:00
|
|
|
disabled = loading || disabled;
|
2023-07-21 15:14:09 -06:00
|
|
|
// Disable when WROL Mode is enabled, otherwise normal disabled.
|
|
|
|
|
disabled = obeyWROLMode ? wrolModeEnabled || disabled : disabled;
|
|
|
|
|
|
|
|
|
|
const reset = () => {
|
|
|
|
|
setShowSuccess(false);
|
|
|
|
|
setShowFailure(false);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const setSuccess = () => {
|
|
|
|
|
setShowSuccess(true);
|
|
|
|
|
setTimeout(reset, 2000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const setFailure = () => {
|
|
|
|
|
setShowFailure(true);
|
|
|
|
|
setTimeout(reset, 2000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleAPICall = async () => {
|
|
|
|
|
// Handle when user clicks button, or clicks confirm.
|
2024-11-02 15:14:02 -06:00
|
|
|
setLoading(true);
|
2023-07-21 15:14:09 -06:00
|
|
|
try {
|
|
|
|
|
await onClick();
|
|
|
|
|
setSuccess();
|
|
|
|
|
} catch (e) {
|
2023-09-13 10:39:06 -06:00
|
|
|
console.error(e);
|
2023-07-21 15:14:09 -06:00
|
|
|
setFailure();
|
2024-11-02 15:14:02 -06:00
|
|
|
} finally {
|
|
|
|
|
setLoading(false);
|
2023-07-21 15:14:09 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const localOnClick = async (e) => {
|
|
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (confirmContent) {
|
|
|
|
|
// Clicking button opens confirm.
|
|
|
|
|
setConfirmOpen(true);
|
|
|
|
|
} else if (onClick) {
|
|
|
|
|
// No <Confirm/> send the API request.
|
|
|
|
|
await handleAPICall();
|
|
|
|
|
} else {
|
|
|
|
|
throw Error('No onClick defined!');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const localOnConfirm = async () => {
|
|
|
|
|
// User clicked the "OK" button in the <Confirm/>.
|
|
|
|
|
setConfirmOpen(false);
|
|
|
|
|
|
|
|
|
|
if (onClick) {
|
|
|
|
|
await handleAPICall();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
// `color` was a Semantic color name; a role carries the meaning instead, and a
|
|
|
|
|
// caller that really wants a color can still pass one through `props`.
|
2024-11-02 15:14:02 -06:00
|
|
|
const buttonArgs = {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
onClick: localOnClick, disabled, loading, type,
|
|
|
|
|
...props,
|
2024-11-02 15:14:02 -06:00
|
|
|
};
|
|
|
|
|
if (id) {
|
|
|
|
|
buttonArgs['id'] = id;
|
|
|
|
|
}
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
if (!props.color && !props.role) {
|
|
|
|
|
buttonArgs['role'] = 'primary';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The result is shown as the icon rather than an animation: the outcome should be
|
|
|
|
|
// legible at a glance, and in night mode a moving element is the last thing wanted.
|
|
|
|
|
const outcomeIcon = showSuccess ? 'check' : showFailure ? 'close' : null;
|
|
|
|
|
const outcomeColor = showSuccess ? 'green' : showFailure ? 'red' : undefined;
|
|
|
|
|
if (outcomeColor) {
|
|
|
|
|
buttonArgs['color'] = outcomeColor;
|
|
|
|
|
}
|
2023-07-21 15:14:09 -06:00
|
|
|
|
2023-07-21 21:23:15 -06:00
|
|
|
let buttonContent = props.children || null;
|
2023-07-21 15:14:09 -06:00
|
|
|
if (icon) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
// Icon-only: swap the glyph for the outcome.
|
|
|
|
|
buttonArgs['icon'] = outcomeIcon || icon;
|
|
|
|
|
} else if (outcomeIcon) {
|
|
|
|
|
buttonArgs['icon'] = outcomeIcon;
|
2023-07-21 15:14:09 -06:00
|
|
|
}
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
let button = <Button ref={ref} {...buttonArgs}>{buttonContent}</Button>;
|
2023-07-21 15:14:09 -06:00
|
|
|
|
|
|
|
|
if (confirmContent) {
|
|
|
|
|
// Wrap button with <Confirm/>
|
|
|
|
|
button = <>
|
|
|
|
|
{button}
|
|
|
|
|
<Confirm open={confirmOpen}
|
|
|
|
|
onCancel={() => setConfirmOpen(false)}
|
|
|
|
|
onConfirm={localOnConfirm}
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
confirmLabel={confirmButton}
|
|
|
|
|
title={confirmHeader}
|
|
|
|
|
destructive
|
|
|
|
|
>
|
|
|
|
|
{confirmContent}
|
|
|
|
|
</Confirm>
|
2023-07-21 15:14:09 -06:00
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {button, ref}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function APIButton({
|
|
|
|
|
color,
|
|
|
|
|
size,
|
|
|
|
|
floated,
|
|
|
|
|
onClick,
|
|
|
|
|
disabled,
|
|
|
|
|
confirmContent,
|
|
|
|
|
confirmButton,
|
2024-10-05 14:06:13 -06:00
|
|
|
confirmHeader,
|
2023-07-21 15:14:09 -06:00
|
|
|
themed,
|
|
|
|
|
obeyWROLMode,
|
|
|
|
|
icon,
|
2024-11-02 15:14:02 -06:00
|
|
|
type = 'button',
|
|
|
|
|
id = null,
|
2023-07-21 15:14:09 -06:00
|
|
|
...props
|
|
|
|
|
}) {
|
|
|
|
|
const {button} = useAPIButton(
|
|
|
|
|
color,
|
|
|
|
|
size,
|
|
|
|
|
floated,
|
|
|
|
|
onClick,
|
|
|
|
|
disabled,
|
|
|
|
|
confirmContent,
|
|
|
|
|
confirmButton,
|
2024-10-05 14:06:13 -06:00
|
|
|
confirmHeader,
|
2023-07-21 15:14:09 -06:00
|
|
|
themed,
|
|
|
|
|
obeyWROLMode,
|
|
|
|
|
icon,
|
2024-11-02 15:14:02 -06:00
|
|
|
type,
|
|
|
|
|
id,
|
2023-07-21 15:14:09 -06:00
|
|
|
props
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return button;
|
2023-08-23 20:14:23 -06:00
|
|
|
}
|
|
|
|
|
|
2025-01-22 18:58:18 -07:00
|
|
|
export const useMessageDismissal = (messageName) => {
|
|
|
|
|
const [dismissed, setDismissed] = useLocalStorage('dismissed_hints', {});
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
dismissed: dismissed[messageName] || false, // true or false
|
2025-01-23 17:47:11 -07:00
|
|
|
setDismissed: (value) => setDismissed({...dismissed, [messageName]: !!value}), // force true/false
|
2025-01-22 18:58:18 -07:00
|
|
|
clearAll: () => setDismissed({}),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
/** A dismissible note. `storageName` makes the dismissal stick across reloads. */
|
|
|
|
|
function DismissibleMessage({kind, icon, children, storageName}) {
|
2025-01-22 18:58:18 -07:00
|
|
|
const {dismissed, setDismissed} = useMessageDismissal(storageName);
|
|
|
|
|
|
|
|
|
|
if (dismissed) {
|
|
|
|
|
return <React.Fragment/>
|
|
|
|
|
}
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <Message
|
|
|
|
|
kind={kind}
|
|
|
|
|
icon={icon}
|
|
|
|
|
onDismiss={storageName ? () => setDismissed(true) : undefined}
|
|
|
|
|
>
|
|
|
|
|
{children}
|
2023-08-23 20:14:23 -06:00
|
|
|
</Message>
|
2023-09-07 20:13:36 -06:00
|
|
|
}
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
export function InfoMessage({children, size = null, storageName = null, icon = 'warning circle'}) {
|
|
|
|
|
return <DismissibleMessage kind='info' icon={icon} storageName={storageName}>
|
|
|
|
|
{children}
|
|
|
|
|
</DismissibleMessage>
|
|
|
|
|
}
|
2025-01-22 18:58:18 -07:00
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
export function HandPointMessage({children, size = null, storageName = null}) {
|
|
|
|
|
return <DismissibleMessage kind='info' icon='hand point right' storageName={storageName}>
|
|
|
|
|
{children}
|
|
|
|
|
</DismissibleMessage>
|
2024-04-17 11:25:26 -06:00
|
|
|
}
|
|
|
|
|
|
2025-01-22 18:58:18 -07:00
|
|
|
export function WarningMessage({children, size = null, icon = 'exclamation', storageName = null}) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <DismissibleMessage kind='warning' icon={icon} storageName={storageName}>
|
|
|
|
|
{children}
|
|
|
|
|
</DismissibleMessage>
|
2023-09-07 20:13:36 -06:00
|
|
|
}
|
|
|
|
|
|
2025-01-22 18:58:18 -07:00
|
|
|
export function ErrorMessage({children, size = null, icon = 'exclamation', storageName = null}) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <DismissibleMessage kind='error' icon={icon} storageName={storageName}>
|
|
|
|
|
{children}
|
|
|
|
|
</DismissibleMessage>
|
2023-09-07 20:13:36 -06:00
|
|
|
}
|
2023-11-21 13:01:52 -07:00
|
|
|
|
|
|
|
|
function levenshteinDistance(a, b) {
|
|
|
|
|
const matrix = [];
|
|
|
|
|
|
|
|
|
|
// Initialize the matrix
|
|
|
|
|
for (let i = 0; i <= b.length; i++) {
|
|
|
|
|
matrix[i] = [i];
|
|
|
|
|
}
|
|
|
|
|
for (let j = 0; j <= a.length; j++) {
|
|
|
|
|
matrix[0][j] = j;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Populate the matrix
|
|
|
|
|
for (let i = 1; i <= b.length; i++) {
|
|
|
|
|
for (let j = 1; j <= a.length; j++) {
|
|
|
|
|
if (b.charAt(i - 1) === a.charAt(j - 1)) {
|
|
|
|
|
matrix[i][j] = matrix[i - 1][j - 1];
|
|
|
|
|
} else {
|
|
|
|
|
matrix[i][j] = Math.min(matrix[i - 1][j - 1], matrix[i][j - 1], matrix[i - 1][j]) + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return matrix[b.length][a.length];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function fuzzyMatch(a, b, threshold = 3) {
|
|
|
|
|
return levenshteinDistance(a, b) <= threshold;
|
|
|
|
|
}
|
2024-02-19 13:45:41 -07:00
|
|
|
|
|
|
|
|
export function useIsIgnoredDirectory(directory) {
|
|
|
|
|
const {settings} = React.useContext(SettingsContext);
|
|
|
|
|
|
2024-02-20 09:49:53 -07:00
|
|
|
if (!settings || _.isEmpty(settings)) {
|
|
|
|
|
// Settings have not yet been fetched.
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-19 13:45:41 -07:00
|
|
|
let ignoredDirectories = settings['ignored_directories'];
|
|
|
|
|
if (directory.endsWith('/')) {
|
|
|
|
|
ignoredDirectories = ignoredDirectories.map(i => `${i}/`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ignoredDirectories.indexOf(directory) >= 0;
|
|
|
|
|
}
|
2024-02-20 13:47:12 -07:00
|
|
|
|
|
|
|
|
export function getParentDirectory(filePath) {
|
|
|
|
|
// Remove trailing slashes for consistency
|
|
|
|
|
const normalizedPath = filePath.endsWith('/') ? filePath.slice(0, -1) : filePath;
|
|
|
|
|
|
|
|
|
|
// Find the last occurrence of "/" and extract the substring up to it
|
|
|
|
|
const parentDirectory = normalizedPath.substring(0, normalizedPath.lastIndexOf('/'));
|
|
|
|
|
|
|
|
|
|
return parentDirectory;
|
|
|
|
|
}
|
2024-02-27 18:54:14 -07:00
|
|
|
|
|
|
|
|
export function MultilineText({text, ...props}) {
|
|
|
|
|
return <div {...props}>
|
|
|
|
|
{text.split('\n').map((line, index, array) =>
|
2024-03-06 17:41:04 -07:00
|
|
|
index === array.length - 1 ? line : <p key={index}>{line}</p>
|
2024-02-27 18:54:14 -07:00
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
}
|
2024-03-06 17:41:04 -07:00
|
|
|
|
|
|
|
|
export const monthNames = [
|
|
|
|
|
'January',
|
|
|
|
|
'February',
|
|
|
|
|
'March',
|
|
|
|
|
'April',
|
|
|
|
|
'May',
|
|
|
|
|
'June',
|
|
|
|
|
'July',
|
|
|
|
|
'August',
|
|
|
|
|
'September',
|
|
|
|
|
'October',
|
|
|
|
|
'November',
|
|
|
|
|
'December',
|
|
|
|
|
];
|
2024-04-16 10:34:05 -06:00
|
|
|
|
2024-06-17 14:49:04 -06:00
|
|
|
export function IframeViewer({title, src, fallback, style, timeout = 5000}) {
|
|
|
|
|
// This function checks that an iframe can be fetched before displaying it. Otherwise, it will display the fallback
|
|
|
|
|
// element which should help the maintainer to fix the issue.
|
2024-06-17 10:40:30 -06:00
|
|
|
const [contentAvailable, setContentAvailable] = useState(false);
|
|
|
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
fallback = fallback || <pre>Frame could not load.</pre>;
|
2024-06-17 10:40:30 -06:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const controller = new AbortController(); // To manage fetch timeout
|
|
|
|
|
const timeoutId = setTimeout(() => {
|
|
|
|
|
controller.abort(); // Abort the fetch after 5 seconds
|
|
|
|
|
}, timeout);
|
|
|
|
|
|
|
|
|
|
fetch(src, {signal: controller.signal})
|
|
|
|
|
.then(response => {
|
2024-06-17 14:49:04 -06:00
|
|
|
// Only display content if it can be fetched.
|
|
|
|
|
setContentAvailable(response.ok);
|
2024-06-17 10:40:30 -06:00
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
setContentAvailable(false); // Handle fetch errors (including aborts)
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
setLoading(false); // Update loading state regardless of result
|
|
|
|
|
clearTimeout(timeoutId); // Clear the timeout
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return () => clearTimeout(timeoutId); // Cleanup timeout on unmount
|
|
|
|
|
}, [src]);
|
|
|
|
|
|
2024-06-17 14:49:04 -06:00
|
|
|
// Mobile needs less height, otherwise it hides the content below the screen.
|
|
|
|
|
let mobileStyle = {
|
|
|
|
|
position: 'fixed',
|
|
|
|
|
height: '80%',
|
|
|
|
|
width: '100%',
|
|
|
|
|
border: 'none',
|
|
|
|
|
padding: 0,
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
backgroundColor: 'var(--panel)',
|
2024-06-17 14:49:04 -06:00
|
|
|
};
|
|
|
|
|
// Allow provided `style` to overwrite.
|
|
|
|
|
mobileStyle = style ? {...mobileStyle, ...style} : mobileStyle;
|
|
|
|
|
let tabletStyle = {...mobileStyle, height: '93%'};
|
|
|
|
|
tabletStyle = style ? {...tabletStyle, ...style} : tabletStyle;
|
|
|
|
|
|
2024-06-17 10:40:30 -06:00
|
|
|
const iframeMedia = <>
|
2024-04-16 10:34:05 -06:00
|
|
|
<Media at='mobile'>
|
2026-03-29 18:58:31 -06:00
|
|
|
<iframe title={title} src={src} style={mobileStyle} allow="geolocation"/>
|
2024-04-16 10:34:05 -06:00
|
|
|
</Media>
|
|
|
|
|
<Media greaterThan='mobile'>
|
2026-03-29 18:58:31 -06:00
|
|
|
<iframe title={title} src={src} style={tabletStyle} allow="geolocation"/>
|
2024-04-16 10:34:05 -06:00
|
|
|
</Media>
|
2024-06-17 10:40:30 -06:00
|
|
|
</>;
|
|
|
|
|
|
|
|
|
|
return <>
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
{loading ? <Panel><Loading/></Panel>
|
2024-06-17 10:40:30 -06:00
|
|
|
: contentAvailable ? iframeMedia
|
|
|
|
|
: fallback
|
|
|
|
|
}
|
2024-04-16 10:34:05 -06:00
|
|
|
</>
|
2024-05-31 23:53:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function roundDigits(value, decimals = 2) {
|
|
|
|
|
return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals);
|
|
|
|
|
}
|
2024-06-25 17:05:41 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
export function Breadcrumbs({crumbs, size = undefined}) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
function getSection(crumb, index) {
|
2024-06-25 17:05:41 -06:00
|
|
|
const {text, link, icon} = crumb;
|
|
|
|
|
if (link) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <Link key={index} to={link} style={{display: 'inline-flex', alignItems: 'center', gap: 4}}>
|
2024-06-25 17:05:41 -06:00
|
|
|
{icon && <Icon name={icon}/>}
|
|
|
|
|
{text}
|
|
|
|
|
</Link>;
|
|
|
|
|
}
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <span key={index}>{text}</span>
|
2024-06-25 17:05:41 -06:00
|
|
|
}
|
|
|
|
|
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
// The separator is a chevron rather than Semantic's slash, matching the icon set.
|
|
|
|
|
return <UIBreadcrumbs separator={<Icon name='chevron right' size={14}/>}>
|
|
|
|
|
{crumbs.map(getSection)}
|
|
|
|
|
</UIBreadcrumbs>
|
2024-06-25 17:05:41 -06:00
|
|
|
}
|
2024-06-25 22:12:13 -06:00
|
|
|
|
|
|
|
|
export function validURL(url) {
|
|
|
|
|
return !(url && !validUrlRegex.test(url));
|
2024-10-05 14:06:13 -06:00
|
|
|
}
|
|
|
|
|
|
2024-11-02 15:14:02 -06:00
|
|
|
export function validURLs(urls) {
|
|
|
|
|
if (!!!urls) {
|
|
|
|
|
// Invalid while empty.
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
urls = urls.split(/\r?\n/);
|
|
|
|
|
for (let i = 0; i < urls.length; i++) {
|
|
|
|
|
if (!validURL(urls[i])) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-05 14:06:13 -06:00
|
|
|
export function useLocalStorage(key, initialValue, decode = JSON.parse, encode = JSON.stringify) {
|
|
|
|
|
// Use localstorage to store some JSON encode-able.
|
|
|
|
|
|
|
|
|
|
// Initialize state with the value from localStorage or initial value
|
|
|
|
|
const [value, setValue] = useState(() => {
|
2024-10-08 17:15:48 -06:00
|
|
|
let item;
|
2024-10-05 14:06:13 -06:00
|
|
|
try {
|
2024-12-18 17:31:50 -07:00
|
|
|
const item = window.localStorage.getItem(key);
|
2024-10-05 14:06:13 -06:00
|
|
|
// Parse the stored item (integer, bool, etc.). Use the initial value if empty.
|
|
|
|
|
return item ? decode(item) : initialValue;
|
|
|
|
|
} catch (error) {
|
2024-10-08 17:15:48 -06:00
|
|
|
console.error('useLocalStorage', key, item, initialValue);
|
2024-10-05 14:06:13 -06:00
|
|
|
console.error('Error reading localStorage:', error);
|
|
|
|
|
return initialValue;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Save to localStorage when the value changes
|
|
|
|
|
useEffect(() => {
|
2025-01-22 18:58:18 -07:00
|
|
|
if (key === null || key === undefined) {
|
|
|
|
|
// key was not defined, do not add this to storage.
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-10-05 14:06:13 -06:00
|
|
|
try {
|
2024-12-18 17:31:50 -07:00
|
|
|
decode(value);
|
|
|
|
|
window.localStorage.setItem(key, value);
|
2024-10-05 14:06:13 -06:00
|
|
|
} catch (error) {
|
2024-12-18 17:31:50 -07:00
|
|
|
window.localStorage.setItem(key, encode(value));
|
2024-10-05 14:06:13 -06:00
|
|
|
}
|
|
|
|
|
}, [key, value, encode]);
|
|
|
|
|
|
|
|
|
|
// Return the stored value and a function to update it
|
|
|
|
|
return [value, setValue];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function useLocalStorageInt(key, initialValue) {
|
|
|
|
|
// Use localStorage to store an integer.
|
|
|
|
|
const [storedValue, setStoredValue] = useLocalStorage(key, initialValue, parseInt, (num) => num.toString());
|
|
|
|
|
return [storedValue, setStoredValue];
|
|
|
|
|
}
|
2024-11-02 15:14:02 -06:00
|
|
|
|
|
|
|
|
export function SimpleAccordion({title = 'Advanced', ...props}) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
return <Accordion chevronPosition='left'>
|
|
|
|
|
<Accordion.Item value='content'>
|
|
|
|
|
<Accordion.Control>{title}</Accordion.Control>
|
|
|
|
|
<Accordion.Panel>{props.children}</Accordion.Panel>
|
|
|
|
|
</Accordion.Item>
|
2024-11-02 15:14:02 -06:00
|
|
|
</Accordion>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function mergeDeep(target, source) {
|
|
|
|
|
if (_.isEmpty(source)) {
|
|
|
|
|
return target;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Initialize the result as target
|
|
|
|
|
let result = Object.assign({}, target);
|
|
|
|
|
|
|
|
|
|
for (let key of Object.keys(source)) {
|
|
|
|
|
if (Array.isArray(source[key])) {
|
|
|
|
|
// source overwrites target if it is a list with values.
|
|
|
|
|
result[key] = source[key] || target[key];
|
2024-12-03 12:44:38 -07:00
|
|
|
} else if (typeof source[key] === 'object' && typeof target[key] === 'object' && source[key] !== null) {
|
2024-11-02 15:14:02 -06:00
|
|
|
result[key] = mergeDeep(target[key] || {}, source[key]);
|
|
|
|
|
} else {
|
|
|
|
|
result[key] = source[key] !== undefined ? source[key] : target[key];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-19 12:13:52 -07:00
|
|
|
export function getDistinctColor(hexColors) {
|
|
|
|
|
function hexToHSL(hex) {
|
2025-03-28 10:26:54 -06:00
|
|
|
if (!hex) {
|
|
|
|
|
return {h: 0, s: 0, l: 0};
|
|
|
|
|
}
|
2024-12-19 12:13:52 -07:00
|
|
|
let r = parseInt(hex.slice(1, 3), 16) / 255;
|
|
|
|
|
let g = parseInt(hex.slice(3, 5), 16) / 255;
|
|
|
|
|
let b = parseInt(hex.slice(5, 7), 16) / 255;
|
|
|
|
|
|
|
|
|
|
let cmax = Math.max(r, g, b), cmin = Math.min(r, g, b);
|
|
|
|
|
let delta = cmax - cmin;
|
|
|
|
|
let h, s, l = (cmax + cmin) / 2;
|
|
|
|
|
|
|
|
|
|
if (delta === 0) h = 0;
|
|
|
|
|
else if (cmax === r) h = ((g - b) / delta) % 6;
|
|
|
|
|
else if (cmax === g) h = (b - r) / delta + 2;
|
|
|
|
|
else h = (r - g) / delta + 4;
|
|
|
|
|
|
|
|
|
|
h = Math.round(h * 60);
|
|
|
|
|
if (h < 0) h += 360;
|
|
|
|
|
|
|
|
|
|
s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
|
|
|
|
|
|
|
|
|
|
return {h: h, s: s, l: l};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function hslToHex(h, s, l) {
|
|
|
|
|
l /= 100;
|
|
|
|
|
const a = s * Math.min(l, 1 - l) / 100;
|
|
|
|
|
const f = n => {
|
|
|
|
|
const k = (n + h / 30) % 12;
|
|
|
|
|
const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
|
|
|
return Math.round(255 * color).toString(16).padStart(2, '0');
|
|
|
|
|
};
|
|
|
|
|
return `#${f(0)}${f(8)}${f(4)}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function generateRandomHSL() {
|
|
|
|
|
return {
|
|
|
|
|
h: Math.random() * 360,
|
|
|
|
|
s: Math.random() * 100,
|
|
|
|
|
l: Math.random() * 100
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isDistinct(newColor, existingColors, threshold) {
|
|
|
|
|
const hslNew = newColor;
|
2025-01-06 16:46:53 -07:00
|
|
|
for (const color of existingColors) {
|
|
|
|
|
const hslColor = hexToHSL(color);
|
|
|
|
|
const h = Math.abs(hslNew.h - hslColor.h);
|
|
|
|
|
const s = Math.abs(hslNew.s * 100 - hslColor.s * 100);
|
|
|
|
|
const l = Math.abs(hslNew.l - hslColor.l * 100);
|
|
|
|
|
if (h < threshold && s < threshold && l < threshold) {
|
|
|
|
|
console.debug(`trying distinct color h=${h} s=${s} l=${l} with threshold=${threshold}`);
|
2024-12-19 12:13:52 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let newColor, attempt = 0;
|
|
|
|
|
const maxAttempts = 1000; // Max attempts before returning any color
|
|
|
|
|
const baseThreshold = 30; // Starting threshold
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
newColor = generateRandomHSL();
|
|
|
|
|
// Decreasing threshold as attempts increase, but never below 10 for distinctiveness
|
|
|
|
|
let threshold = Math.max(baseThreshold - (attempt / 10), 10);
|
|
|
|
|
if (isDistinct(newColor, hexColors, threshold)) {
|
|
|
|
|
return hslToHex(newColor.h, newColor.s, newColor.l);
|
|
|
|
|
}
|
|
|
|
|
attempt++;
|
|
|
|
|
} while (attempt < maxAttempts);
|
|
|
|
|
|
|
|
|
|
// If we've tried maxAttempts times, return the last generated color regardless
|
|
|
|
|
return hslToHex(newColor.h, newColor.s, newColor.l);
|
|
|
|
|
}
|
2025-01-10 11:33:21 -07:00
|
|
|
|
2025-01-26 12:44:16 -07:00
|
|
|
export const RefreshHeader = ({header, headerSize = 'h2', onRefresh, popupContents}) => {
|
|
|
|
|
const refreshButton = <APIButton icon='refresh' onClick={onRefresh}/>;
|
|
|
|
|
let popup;
|
|
|
|
|
if (popupContents) {
|
ui: Common.js and thirteen more files off Semantic
Phase 2, part 3. Baseline 63 -> 50.
Common.js is the one that mattered: 51 files import it, so its Semantic usage
was propping up the rest of the migration. Everything in it now comes from the
library -- Paginator, the two search inputs, DirectorySearch, TabLinks, the
toggles, the messages, APIButton, Breadcrumbs, SimpleAccordion, IframeViewer,
CardPoster, FileIcon, LoadStatistic, the theme menu, and the hotspot icons.
Also migrated: Placeholder, Apps, ArchivePreview, CbzViewer, AddToPlaylist,
TaggedDeleteConfirmModal, the collection edit/tag forms, and four inventory
components.
New in the library, all in the gallery and tested:
SearchBox Semantic's `<Search category>` with its grouped results shape
kept, because four call sites already build it. A real
combobox rather than a div that listens for clicks.
Pagination Semantic's prop names; onPageChange gets the page number.
TabBar the strip only -- routing stays with the caller.
IconStack Semantic's IconGroup, named once for assistive technology.
Table.HeaderCell sorted/onSort -- a real button carrying aria-sort.
Button/IconButton translate Semantic's size names.
That last one is defensive: unmigrated callers still pass size='tiny', and
Mantine drops a size it does not recognise without a word, so the button
quietly renders at the wrong size. Mapping here keeps the mixed state honest.
Three real bugs found and fixed on the way, none of them cosmetic:
* `fileSuffixIconName` returned fourteen icon names the map did not have, so
opening a folder with a PDF, a Word document or an archive in it logged an
error and drew a fallback glyph. All fourteen mapped, with a test that
walks the mapper's own return values, and another asserting every mapped
name resolves to a Tabler component that exists.
* `Statistic` relied on Semantic's `Statistic.Group` for its spacing, so on
the dashboard the load averages ran together into "1 MIN. LOAD5 MIN.
LOAD15 MIN. LOAD". It carries its own spacing now.
* Semantic's inverted stylesheet colors every descendant of an inverted
segment, so Toggle labels inherited #dddddd -- white pixels in night mode,
on the Settings page, which is exactly where someone adjusts their WROLPi
in the dark. Restated from tokens.
The baseline ratchet gained a third assertion: a migrated file may still lean
on Semantic's CSS classes without importing the library, which the import check
cannot see and which would collapse silently when Phase 4 deletes the
stylesheet. There is one such bridge today and it is now declared.
2026-07-30 10:00:48 -06:00
|
|
|
popup = <Tooltip label={popupContents}>{refreshButton}</Tooltip>;
|
|
|
|
|
}
|
|
|
|
|
return <div style={{
|
|
|
|
|
display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12,
|
|
|
|
|
}}>
|
|
|
|
|
<Header as={headerSize}>{header}</Header>
|
|
|
|
|
{popup || refreshButton}
|
|
|
|
|
</div>
|
2025-05-05 17:02:32 -06:00
|
|
|
}
|