mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
ControllerPage was the final call site; Theme.tsx then had nothing left to wrap, so it drops from 861 lines to 338 -- the provider that resolves the theme, stamps `data-theme` and `data-media-filter`, persists both and hands Mantine our tokens. Everything below that was Semantic wrappers. The dark-mode compatibility props went with them. `i`, `s`, `t` and `inverted` existed so unmigrated components could borrow Semantic's dark treatment, and they carried hardcoded greys -- #1B1C1D, #dddddd, #eeeeee -- which is exactly what the token themes replaced. Three call sites in Common.js were still injecting the #eeeeee one into links. Then `semantic-ui-offline/semantic.min.css` came out of App.js. That took more with it than expected, and looking at the running app is the only reason it was caught: Every link lost its colour and gained the browser's underline and visited purple. The dashboard's load averages and section headings were underlined and purple. Links now take `--blue`, which remaps per theme, and underline only on hover -- many of them wrap cards, posters and icons. `box-sizing: border-box` disappeared, which silently changes the size of every padded element in the app. Semantic's reset had been providing it. The navigation bar overflowed a 1000px viewport with `nowrap` and cut "Admin" off the right edge -- the one link a user needs to reach the settings that fix a broken WROLPi. Semantic's menu wrapped; ours does now too. The gzipped CSS bundle is 47.5 kB, and one call site was still leaning on Semantic's grid classes -- now a flex column, since all three of its callers pass library components. The ratchet stays rather than being deleted. At zero it asserts four things: no file imports Semantic UI, none calls its toast library, none leans on its stylesheet, and no file reaches back through Theme.tsx. It can go when the packages are uninstalled. Theme.test.js is deleted, but not before porting the two behaviours it protected: that Button forwards a ref to the real DOM element (a class-component ref once crashed the Control page, because portals call `node.contains`), and that the progress percentage stays readable on every bar colour.
134 lines
6.1 KiB
JavaScript
134 lines
6.1 KiB
JavaScript
import React, {useContext} from 'react';
|
|
import './App.css';
|
|
import {NavBar} from "./components/Nav";
|
|
import {createBrowserRouter, createRoutesFromElements, Link, Outlet, Route, RouterProvider} from "react-router";
|
|
import {VideosTabLayout, VideosPage, VideosSettingsPage, VideosStatistics, VideoWrapper} from "./components/Videos";
|
|
import AdminRoute from "./components/admin/AdminRoute";
|
|
import {Box, Header} from "./components/ui";
|
|
import '@mantine/core/styles.css';
|
|
import '@mantine/notifications/styles.css';
|
|
// Theme tokens load last so they win over both component libraries.
|
|
import './themes/fonts.css';
|
|
import './themes/tokens.css';
|
|
import {MediaFilterDefs} from "./themes/MediaFilterDefs";
|
|
import {MoreRoute} from "./components/Apps";
|
|
import {InventoryRoute} from "./components/inventory/InventoryRoute";
|
|
import {ArchiveRoute} from "./components/Archive";
|
|
import {FilesRoute} from "./components/Files";
|
|
import {QueryProvider, StatusProvider} from "./hooks/customHooks";
|
|
import {FileWorkerStatusProvider} from "./contexts/FileWorkerStatusContext";
|
|
import {ChannelEditPage, ChannelNewPage, ChannelsPage} from "./components/Channels";
|
|
import {MapRoute} from "./components/Map";
|
|
import {MediaContextProvider, mediaStyles, StatusContext} from "./contexts/contexts";
|
|
import {ThemeProvider} from "./components/Theme";
|
|
import {DashboardPage} from "./DashboardPage";
|
|
import {DonatePage} from "./components/DonatePage";
|
|
import {ThemeSamplePage} from "./components/ThemeSamplePage";
|
|
import {useEventsInterval} from "./Events";
|
|
import {FilePreviewProvider} from "./components/FilePreview";
|
|
import {TagsProvider} from "./Tags";
|
|
import {ZimRoute} from "./components/Zim";
|
|
import {PlaylistsRoute} from "./components/Playlists";
|
|
import {DocsRoute} from "./components/Docs";
|
|
import {FlasherRoute} from "./components/Flasher";
|
|
import ErrorBoundary from "./components/ErrorBoundary";
|
|
import {KeyboardShortcutsProvider} from "./components/KeyboardShortcutsProvider";
|
|
|
|
function PageNotFound() {
|
|
return <Box>
|
|
<Header as='h1'>Page Not Found!</Header>
|
|
<p>The page you requested cannot be found</p>
|
|
</Box>
|
|
}
|
|
|
|
function Dot() {
|
|
return <> • </>
|
|
}
|
|
|
|
function Footer() {
|
|
const {status} = useContext(StatusContext);
|
|
let version;
|
|
try {
|
|
version = status?.version ? `v${status.version}` : null;
|
|
} catch (e) {
|
|
// Not logging because this is not that important.
|
|
}
|
|
return <Box style={{textAlign: 'center', marginTop: '1.5em', marginBottom: '1em'}}>
|
|
<span>
|
|
WROLPi {version} <Dot/>
|
|
<a href='https://wrolpi.org' target='_blank' rel='nofollow noreferrer'>WROLPi.org</a> <Dot/>
|
|
<Link to='/donate'>Donate</Link>
|
|
</span>
|
|
</Box>
|
|
}
|
|
|
|
function Root() {
|
|
return <QueryProvider>
|
|
<ThemeProvider>
|
|
<MediaFilterDefs/>
|
|
<TagsProvider>
|
|
<KeyboardShortcutsProvider>
|
|
<FilePreviewProvider>
|
|
<header>
|
|
<NavBar/>
|
|
</header>
|
|
<ErrorBoundary>
|
|
<Outlet/>
|
|
</ErrorBoundary>
|
|
<Footer/>
|
|
</FilePreviewProvider>
|
|
</KeyboardShortcutsProvider>
|
|
</TagsProvider>
|
|
</ThemeProvider>
|
|
</QueryProvider>
|
|
}
|
|
|
|
const router = createBrowserRouter(createRoutesFromElements(<Route
|
|
path='/'
|
|
element={<Root/>}
|
|
errorElement={<PageNotFound/>}
|
|
>
|
|
<Route index element={<ErrorBoundary><DashboardPage/></ErrorBoundary>}/>
|
|
<Route path='search/*' element={<ErrorBoundary><DashboardPage/></ErrorBoundary>}/>
|
|
<Route path='donate' element={<DonatePage/>}/>
|
|
{/* Component gallery: lets a user see a theme before committing to it, and lets us
|
|
review the design. Linked from Settings. */}
|
|
<Route path='theme-sample' element={<ErrorBoundary><ThemeSamplePage/></ErrorBoundary>}/>
|
|
<Route path='videos'>
|
|
<Route element={<ErrorBoundary><VideosTabLayout/></ErrorBoundary>}>
|
|
<Route index element={<ErrorBoundary><VideosPage/></ErrorBoundary>}/>
|
|
<Route path='channel' element={<ErrorBoundary><ChannelsPage/></ErrorBoundary>}/>
|
|
<Route path='channel/new' element={<ErrorBoundary><ChannelNewPage/></ErrorBoundary>}/>
|
|
<Route path='channel/:channelId/edit' element={<ErrorBoundary><ChannelEditPage/></ErrorBoundary>}/>
|
|
<Route path='channel/:channelId/video' element={<ErrorBoundary><VideosPage/></ErrorBoundary>}/>
|
|
<Route path='settings' element={<ErrorBoundary><VideosSettingsPage/></ErrorBoundary>}/>
|
|
<Route path='statistics' element={<ErrorBoundary><VideosStatistics/></ErrorBoundary>}/>
|
|
</Route>
|
|
<Route path=':fileGroupId' element={<ErrorBoundary><VideoWrapper/></ErrorBoundary>}/>
|
|
</Route>
|
|
<Route path="admin/*" element={<ErrorBoundary><AdminRoute/></ErrorBoundary>}/>
|
|
<Route path="more/*" element={<ErrorBoundary><MoreRoute/></ErrorBoundary>}/>
|
|
<Route path="inventory/*" element={<ErrorBoundary><InventoryRoute/></ErrorBoundary>}/>
|
|
<Route path='archives/*' element={<ErrorBoundary><ArchiveRoute/></ErrorBoundary>}/>
|
|
<Route path='docs/*' element={<ErrorBoundary><DocsRoute/></ErrorBoundary>}/>
|
|
<Route path='map/*' element={<ErrorBoundary><MapRoute/></ErrorBoundary>}/>
|
|
<Route path='zim/*' element={<ErrorBoundary><ZimRoute/></ErrorBoundary>}/>
|
|
<Route path='playlists/*' element={<ErrorBoundary><PlaylistsRoute/></ErrorBoundary>}/>
|
|
<Route path='files/*' element={<ErrorBoundary><FilesRoute/></ErrorBoundary>}/>
|
|
<Route path='flasher/*' element={<ErrorBoundary><FlasherRoute/></ErrorBoundary>}/>
|
|
</Route>));
|
|
|
|
export default function App() {
|
|
useEventsInterval();
|
|
|
|
return <StatusProvider>
|
|
<FileWorkerStatusProvider>
|
|
{/* Context and style to handle switching between mobile/computer. */}
|
|
<style>{mediaStyles}</style>
|
|
{/* Toasts (from components/ui) are mounted by ThemeProvider, which wraps every page. */}
|
|
<MediaContextProvider>
|
|
<RouterProvider router={router}/>
|
|
</MediaContextProvider>
|
|
</FileWorkerStatusProvider>
|
|
</StatusProvider>
|
|
}
|