mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-01 12:26:19 -05:00
ui: migrate the extension pages and Configs; five components they needed
Phase 2, part 1. Three files leave Semantic UI (baseline 75 -> 72), and the
components they needed join the library and the gallery:
Header Semantic's shape (as/icon/subheader/dividing). 47 files use
<Header>, and the level now picks the size, so the type scale
stays a scale instead of each call site choosing a font size.
Message gains an icon and a dismiss button.
ActionInput input and button sharing one outline, for <Input action={...}/>.
Loading centered loader with a caption, replacing the
<Loader active inline='centered'> + wrapper div in 19 places.
Modal becomes compound - Modal.Header/.Content/.Actions, plus
Semantic's open, closeIcon, and size names - because 34 files
are written against that shape.
test-utils mounts MantineProvider with ThemeProvider's exact configuration:
migrated components render Mantine internals and every one of their test files
would otherwise need its own provider.
One Semantic bleed found and fixed: semantic.min.css sets
`h1,h2,h3,h4,h5 { font-family: Lato }` and loads after Mantine's element rule,
so headings ignored the theme's body face. Only visible in amber, where the
body is mono and the headings were not. A class-level restatement outranks it;
the rule comes out when Semantic does.
Verified: 925 jest tests, clean production build, and a night-mode audit of
every painted pixel in the gallery (red-only, one known false positive). The
Configs backup and restore flow was exercised against the real API.
This commit is contained in:
parent
6ffc5b57c8
commit
00c52872fa
12 changed files with 621 additions and 202 deletions
|
|
@ -1,15 +1,19 @@
|
|||
import React, {useContext, useState} from 'react';
|
||||
import {ThemeContext} from '../contexts/contexts';
|
||||
import {
|
||||
ActionInput,
|
||||
Button,
|
||||
Card,
|
||||
CardGroup,
|
||||
Confirm,
|
||||
Header,
|
||||
Icon,
|
||||
IconButton,
|
||||
Label,
|
||||
Loader,
|
||||
Loading,
|
||||
Message,
|
||||
Modal,
|
||||
Panel,
|
||||
Placeholder,
|
||||
Progress,
|
||||
|
|
@ -52,10 +56,12 @@ const Row = ({children}) => <div style={{display: 'flex', gap: 10, flexWrap: 'wr
|
|||
</div>;
|
||||
|
||||
export function ThemeSamplePage() {
|
||||
const {theme, setTheme} = useContext(ThemeContext);
|
||||
const {theme} = useContext(ThemeContext);
|
||||
const [confirmOpen, setConfirmOpen] = useState(false);
|
||||
const [comments, setComments] = useState(true);
|
||||
const [hotspot, setHotspot] = useState(true);
|
||||
const [dismissed, setDismissed] = useState(false);
|
||||
const [modalOpen, setModalOpen] = useState(false);
|
||||
|
||||
return <div style={{maxWidth: 1060, margin: '0 auto', padding: '20px 16px 60px', color: 'var(--text)'}}>
|
||||
<h1 style={{fontSize: 21, fontWeight: 600, margin: '8px 0 4px'}}>Component gallery</h1>
|
||||
|
|
@ -74,6 +80,20 @@ export function ThemeSamplePage() {
|
|||
</Panel>
|
||||
</Section>
|
||||
|
||||
<Section label='Headers'>
|
||||
<Panel>
|
||||
<Header as='h1'>Page title (h1)</Header>
|
||||
<Header as='h2'>Section (h2)</Header>
|
||||
<Header as='h3' icon='folder' dividing>With an icon and a divider (h3)</Header>
|
||||
<Header as='h4' subheader='And a subheader below it'>Subsection (h4)</Header>
|
||||
<Header as='h5'>Smallest (h5)</Header>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginBottom: 0}}>
|
||||
The level picks the size, so the type scale stays a scale: call sites
|
||||
choose a heading level for the document outline, never a font size.
|
||||
</p>
|
||||
</Panel>
|
||||
</Section>
|
||||
|
||||
<Section label='Statistics'>
|
||||
<StatisticGroup>
|
||||
<Statistic value='1,432' label='Videos'/>
|
||||
|
|
@ -130,6 +150,12 @@ export function ThemeSamplePage() {
|
|||
<Message kind='error' title='Download failed'>
|
||||
HTTP 403 from the remote server after 3 attempts. Retry, or check the URL.
|
||||
</Message>
|
||||
<Message kind='info' icon='puzzle piece' title='With an icon, and dismissible'
|
||||
onDismiss={() => setDismissed(true)}>
|
||||
{dismissed
|
||||
? 'Dismissed — it would be gone in the real interface.'
|
||||
: 'A nudge the user can clear. Only offer dismiss when clearing it is harmless.'}
|
||||
</Message>
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
|
|
@ -200,6 +226,14 @@ export function ThemeSamplePage() {
|
|||
<div style={{marginTop: 12}}>
|
||||
<Textarea label='Notes' placeholder='Notes about this download…' minRows={2}/>
|
||||
</div>
|
||||
<div style={{marginTop: 12}}>
|
||||
<ActionInput
|
||||
label="This WROLPi's URL"
|
||||
readOnly
|
||||
value='https://wrolpi.local'
|
||||
action={<Button role='cancel' icon='copy'>Copy</Button>}
|
||||
/>
|
||||
</div>
|
||||
<div style={{marginTop: 14, display: 'flex', flexDirection: 'column', gap: 10}}>
|
||||
<Checkbox label='Download comments' checked={comments}
|
||||
onChange={e => setComments(e.currentTarget.checked)}/>
|
||||
|
|
@ -261,6 +295,34 @@ export function ThemeSamplePage() {
|
|||
|
||||
<Section label='Loading placeholders'>
|
||||
<Panel><Placeholder lines={4}/></Panel>
|
||||
<div style={{marginTop: 10}}>
|
||||
<Panel><Loading>Loading backups…</Loading></Panel>
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<Section label='Modal'>
|
||||
<Panel>
|
||||
<Row>
|
||||
<Button role='cancel' icon='eye' onClick={() => setModalOpen(true)}>Open a modal</Button>
|
||||
</Row>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginBottom: 0, marginTop: 10}}>
|
||||
Semantic's compound shape is kept — Modal.Header, Modal.Content,
|
||||
Modal.Actions — so the 34 call sites written against it migrate by import.
|
||||
</p>
|
||||
<Modal open={modalOpen} onClose={() => setModalOpen(false)} size='small'>
|
||||
<Modal.Header>Restore Backup: channels.yaml</Modal.Header>
|
||||
<Modal.Content>
|
||||
<p style={{marginTop: 0}}>
|
||||
Actions sit below the body behind a hairline, right-aligned so the
|
||||
confirming action lands where the eye finishes reading.
|
||||
</p>
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<Button role='cancel' onClick={() => setModalOpen(false)}>Close</Button>
|
||||
<Button role='save' icon='check' onClick={() => setModalOpen(false)}>Apply</Button>
|
||||
</Modal.Actions>
|
||||
</Modal>
|
||||
</Panel>
|
||||
</Section>
|
||||
|
||||
<Section label='Danger zone'>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue