mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
ui: scale the whole interface by 10%, off the root font-size
The interface reads about 10% smaller than the pre-migration Semantic build, and the
drift is not one number. Measured on the QA Pi at 1280px, Semantic's headings were
h1 28 / h2 24 / h3 18 / h4 15 / h5 14 against our 26 / 21 / 17 / 14 / 13, and its video
card a fixed 290px with an 18px title against our 238px with a 13px one -- while our
BODY text and chrome went the other way, a 16px base against Semantic's 14 and 42px
buttons against 36. No per-component nudge reproduces what a user comparing the two
sees, which is the whole page at once.
Ten percent is not a fudge factor: our heading scale times 1.1 is 28.6 / 23.1 / 18.7 /
15.4 / 14.3, which is Semantic's scale to within a pixel at every step. Verified in
the browser -- those are the numbers it now renders.
`--ui-scale: 1.1` and `html { font-size: calc(100% * var(--ui-scale)) }`, with
everything that should grow written in rem:
- 102 lengths in ui.css, App.css and tokens.css converted, restricted by property:
font-size, padding, margin, gap, width/height, border-radius, offsets.
- Borders, outlines and shadows deliberately NOT converted. A hairline is a hairline
at any text size.
- 46 inline `fontSize` px values across 8 files. `em` values were left alone: they
already resolve against the parent.
- Ten inline-styled blocks in the library (Card's text block, Loading, Placeholder,
ColoredInput, Confirm's action row, CardGroup's gap) moved into ui.css, because an
inline px size cannot be reached by a scale or seen by a test.
- CardGroup converts its `minWidth` prop to rem, which is what returns a phone to one
card per row: as px the track ignored the scale, so a 430px screen fitted two 200px
cards where the old build fitted one 290px card.
Mantine needs nothing: its 644 size declarations are `calc(Xrem * var(--mantine-scale))`
and scale with the root. `theme.scale` must stay at 1 -- it exists to CANCEL a
customised root font-size, so setting it to 1.1 as well would leave Mantine's half of
the interface at the old size beside our larger text. A test pins that.
`zoom: 1.1` on the root was tried first and rejected. It works and it is one line, but
it scales at paint: every 1px hairline becomes 1.1px and softens on a 1x display, and
viewport units do not shrink to compensate, so `100vh` paints 110% of the screen -- a
95vw modal overflowed sideways and the CBZ viewer's fullscreen overflowed down. Rem
scales real lengths, keeps borders crisp, leaves viewport units alone, and preserves a
user's own browser font-size preference instead of overriding it.
A percentage rather than a px root size, for that last reason.
Five guards in themes/ui-scale.test.js, each planted against: the scale itself, that
every scalable declaration is rem, that borders are NOT, that no inline px font-size
survives anywhere including the gallery, and that Mantine's scale stays 1.
Also removes `.ui.modal.themed-confirm`, a dead Semantic-era rule and the source of the
one `95vw` that would have overflowed: `.ui.modal` no longer exists and nothing sets
that class.
Verified: 1141 tests / 65 suites; clean build; browser-checked at 1280px and at a 430px
phone; navbar single-row from 780 to 1800px; hairlines still 1px and no horizontal
overflow in all four themes.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
05b1c75310
commit
f4303476cf
17 changed files with 501 additions and 196 deletions
|
|
@ -36,7 +36,7 @@
|
|||
* switch to `bottom-right` should not silently inherit a top offset.
|
||||
*/
|
||||
html .mantine-Notifications-root[data-position^='top'] {
|
||||
top: calc(var(--navbar-height) + var(--mantine-spacing-md, 16px));
|
||||
top: calc(var(--navbar-height) + var(--mantine-spacing-md, 1rem));
|
||||
}
|
||||
|
||||
.wrolpi-navbar-right {
|
||||
|
|
@ -159,7 +159,7 @@ html .wrolpi-navbar .mantine-ActionIcon-root:hover {
|
|||
}
|
||||
|
||||
.channel-edit {
|
||||
border-radius: 3px;
|
||||
border-radius: 0.1875rem;
|
||||
padding: 0.75em;
|
||||
}
|
||||
|
||||
|
|
@ -186,12 +186,12 @@ pre.wrap-text {
|
|||
|
||||
.duration-overlay {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
right: 4px;
|
||||
top: 0.25rem;
|
||||
right: 0.25rem;
|
||||
color: black;
|
||||
background: #ffffff;
|
||||
padding: 0px 4px;
|
||||
border-radius: 3px;
|
||||
padding: 0px 0.25rem;
|
||||
border-radius: 0.1875rem;
|
||||
}
|
||||
|
||||
.no-link-underscore {
|
||||
|
|
@ -219,8 +219,8 @@ div.inverted {
|
|||
.toggle {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 49px;
|
||||
height: 23px;
|
||||
width: 3.0625rem;
|
||||
height: 1.4375rem;
|
||||
}
|
||||
|
||||
.toggle input {
|
||||
|
|
@ -239,14 +239,14 @@ div.inverted {
|
|||
background-color: rgb(166, 166, 166);
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
border-radius: 34px;
|
||||
border-radius: 2.125rem;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 22px;
|
||||
width: 22px;
|
||||
height: 1.375rem;
|
||||
width: 1.375rem;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
background-color: white;
|
||||
|
|
@ -316,9 +316,9 @@ input:checked + .slider:before {
|
|||
Use 100dvh so mobile browser chrome (URL bar) is accounted for. */
|
||||
.preview-fit {
|
||||
width: 100%;
|
||||
height: calc(100dvh - 300px);
|
||||
max-height: calc(100dvh - 300px);
|
||||
min-height: 240px;
|
||||
height: calc(100dvh - 18.75rem);
|
||||
max-height: calc(100dvh - 18.75rem);
|
||||
min-height: 15rem;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
display: flex;
|
||||
|
|
@ -356,12 +356,12 @@ td.file-path > svg {
|
|||
.ui-alerts {
|
||||
position: fixed;
|
||||
z-index: 2060;
|
||||
padding: 24px;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.ui-alerts.top-right {
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
top: 1.25rem;
|
||||
right: 1.25rem;
|
||||
}
|
||||
|
||||
textarea.otp {
|
||||
|
|
@ -370,9 +370,9 @@ textarea.otp {
|
|||
}
|
||||
|
||||
.card-icon {
|
||||
min-height: 163px;
|
||||
min-height: 10.1875rem;
|
||||
text-align: center;
|
||||
padding-top: 53px;
|
||||
padding-top: 3.3125rem;
|
||||
}
|
||||
|
||||
.card-icon.inverted {
|
||||
|
|
@ -426,11 +426,6 @@ textarea.otp {
|
|||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
/* Mobile-responsive Confirm modal */
|
||||
.ui.modal.themed-confirm {
|
||||
max-width: 95vw;
|
||||
}
|
||||
|
||||
.clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
@ -469,7 +464,7 @@ textarea.otp {
|
|||
}
|
||||
|
||||
.search-clear {
|
||||
margin: 10px;
|
||||
margin: 0.625rem;
|
||||
}
|
||||
|
||||
.icon.divider {
|
||||
|
|
@ -524,40 +519,40 @@ table.ratio-table td.min-width {
|
|||
}
|
||||
|
||||
.form-skeleton-label {
|
||||
height: 14px;
|
||||
width: 80px;
|
||||
margin-bottom: 8px;
|
||||
height: 0.875rem;
|
||||
width: 5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
|
||||
background-size: 200% 100%;
|
||||
animation: skeleton-shimmer 1.5s infinite;
|
||||
border-radius: 3px;
|
||||
border-radius: 0.1875rem;
|
||||
}
|
||||
|
||||
.form-skeleton-input {
|
||||
height: 38px;
|
||||
height: 2.375rem;
|
||||
width: 100%;
|
||||
background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
|
||||
background-size: 200% 100%;
|
||||
animation: skeleton-shimmer 1.5s infinite;
|
||||
border-radius: 4px;
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
|
||||
.form-skeleton-textarea {
|
||||
height: 80px;
|
||||
height: 5rem;
|
||||
width: 100%;
|
||||
background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
|
||||
background-size: 200% 100%;
|
||||
animation: skeleton-shimmer 1.5s infinite;
|
||||
border-radius: 4px;
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
|
||||
.form-skeleton-button {
|
||||
height: 42px;
|
||||
width: 100px;
|
||||
height: 2.625rem;
|
||||
width: 6.25rem;
|
||||
background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
|
||||
background-size: 200% 100%;
|
||||
animation: skeleton-shimmer 1.5s infinite;
|
||||
border-radius: 4px;
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
|
||||
@keyframes skeleton-shimmer {
|
||||
|
|
@ -741,7 +736,7 @@ tr.drag-deselecting td {
|
|||
.inventory-print th,
|
||||
.inventory-print td {
|
||||
border: 1px solid #999;
|
||||
padding: 4px 6px;
|
||||
padding: 0.25rem 0.375rem;
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -987,8 +987,8 @@ function RefreshStepItem({phase, isActive, isCompleted, isDisabled, description}
|
|||
<Icon name={phase.icon} size='large'
|
||||
style={{color: isCompleted ? 'var(--success)' : isActive ? 'var(--info)' : 'var(--neutral)'}}/>
|
||||
<div>
|
||||
<div style={{fontWeight: 600, fontSize: 13}}>{phase.title}</div>
|
||||
<div style={{fontSize: 12, color: 'var(--muted)'}}>{isActive || isCompleted ? description : ''}</div>
|
||||
<div style={{fontWeight: 600, fontSize: '0.8125rem'}}>{phase.title}</div>
|
||||
<div style={{fontSize: '0.75rem', color: 'var(--muted)'}}>{isActive || isCompleted ? description : ''}</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -835,7 +835,7 @@ export function FlasherPage() {
|
|||
<Icon name='save'/>
|
||||
<div>
|
||||
<div style={{fontWeight: 600}}>{configuration.name}</div>
|
||||
<div style={{fontSize: 12, opacity: 0.8}}>
|
||||
<div style={{fontSize: '0.75rem', opacity: 0.8}}>
|
||||
{(configuration.files || []).length} file(s)
|
||||
{configuration.erase_all ? ' — erases flash' : ''}
|
||||
</div>
|
||||
|
|
@ -968,7 +968,7 @@ export function FlasherPage() {
|
|||
<Header as='h3'>2. Connect</Header>
|
||||
<Stack gap={12} style={{maxWidth: 320}}>
|
||||
<div>
|
||||
<div style={{marginBottom: 4, fontSize: 13, fontWeight: 500}}>Baud rate</div>
|
||||
<div style={{marginBottom: 4, fontSize: '0.8125rem', fontWeight: 500}}>Baud rate</div>
|
||||
<Select
|
||||
data={BAUD_OPTIONS.map(o => ({value: String(o.value), label: o.text}))}
|
||||
value={String(baudrate)}
|
||||
|
|
|
|||
|
|
@ -577,7 +577,7 @@ function MapPins() {
|
|||
<a href="#" onClick={(e) => {e.preventDefault(); handleNavigate(pin);}}>
|
||||
{pin.label}
|
||||
</a>
|
||||
<div style={{fontSize: 11, color: 'var(--muted)'}}>{pin.lat.toFixed(4)}, {pin.lon.toFixed(4)}</div>
|
||||
<div style={{fontSize: '0.6875rem', color: 'var(--muted)'}}>{pin.lat.toFixed(4)}, {pin.lon.toFixed(4)}</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<APIButton
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ function LayerControl({map, scaleUnit, onScaleUnitChange, visibilityRef}) {
|
|||
maxHeight: "calc(100vh - 120px)",
|
||||
overflowY: "auto",
|
||||
minWidth: iconOnly ? 0 : 200,
|
||||
fontSize: 13,
|
||||
fontSize: '0.8125rem',
|
||||
};
|
||||
|
||||
const headerStyle = iconOnly
|
||||
|
|
@ -337,7 +337,7 @@ function AddPinDialog({lat, lon, onSubmit, onCancel}) {
|
|||
padding: 16, minWidth: 250,
|
||||
}}>
|
||||
<div style={{fontWeight: 600, marginBottom: 8}}>Add Pin</div>
|
||||
<div style={{fontSize: 12, color: "var(--muted)", marginBottom: 8}}>{lat.toFixed(4)}, {lon.toFixed(4)}</div>
|
||||
<div style={{fontSize: '0.75rem', color: "var(--muted)", marginBottom: 8}}>{lat.toFixed(4)}, {lon.toFixed(4)}</div>
|
||||
<TextInput
|
||||
placeholder="Label"
|
||||
value={label}
|
||||
|
|
@ -496,7 +496,7 @@ function MapSearch({map}) {
|
|||
onKeyDown={handleKeyDown}
|
||||
style={{
|
||||
width: "100%", padding: "8px 12px", border: "1px solid var(--border)",
|
||||
fontSize: 14, background: "var(--panel)", color: "var(--text)",
|
||||
fontSize: '0.875rem', background: "var(--panel)", color: "var(--text)",
|
||||
}}
|
||||
/>
|
||||
{showResults && results.length > 0 && <div style={{
|
||||
|
|
@ -511,7 +511,7 @@ function MapSearch({map}) {
|
|||
style={{padding: "8px 12px", cursor: "pointer", borderBottom: "1px solid var(--border)"}}
|
||||
>
|
||||
<div style={{fontWeight: 500}}>{r.name}</div>
|
||||
{resultSubtext(r) && <div style={{fontSize: 11, color: "var(--muted)"}}>{resultSubtext(r)}</div>}
|
||||
{resultSubtext(r) && <div style={{fontSize: '0.6875rem', color: "var(--muted)"}}>{resultSubtext(r)}</div>}
|
||||
</div>)}
|
||||
</div>}
|
||||
</div>;
|
||||
|
|
@ -936,11 +936,11 @@ export default function MapViewer() {
|
|||
borderRadius: 6,
|
||||
boxShadow: "0 2px 8px rgba(0,0,0,0.3)",
|
||||
padding: "4px 0",
|
||||
fontSize: 13,
|
||||
fontSize: '0.8125rem',
|
||||
minWidth: 180,
|
||||
}}
|
||||
>
|
||||
<div style={{padding: "6px 12px", color: "#666", fontSize: 12, borderBottom: "1px solid #eee"}}>
|
||||
<div style={{padding: "6px 12px", color: "#666", fontSize: '0.75rem', borderBottom: "1px solid #eee"}}>
|
||||
{(() => {
|
||||
const map = mapRef.current;
|
||||
const zoom = map ? map.getZoom() : 10;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ const samplePoster = (width, height) => `data:image/svg+xml,${encodeURIComponent
|
|||
|
||||
const Section = ({label, children}) => <section style={{marginBottom: 34}}>
|
||||
<p style={{
|
||||
fontSize: 11, fontWeight: 600, letterSpacing: '0.12em', textTransform: 'uppercase',
|
||||
fontSize: '0.6875rem', fontWeight: 600, letterSpacing: '0.12em', textTransform: 'uppercase',
|
||||
color: 'var(--muted)', margin: '0 0 10px',
|
||||
}}>{label}</p>
|
||||
{children}
|
||||
|
|
@ -127,7 +127,7 @@ export const NavBarSample = ({color}) => {
|
|||
</div>
|
||||
</nav>
|
||||
<div style={{
|
||||
fontSize: 11, color: short ? 'var(--danger)' : 'var(--muted)',
|
||||
fontSize: '0.6875rem', color: short ? 'var(--danger)' : 'var(--muted)',
|
||||
padding: '3px 2px 0', display: 'flex', gap: 8,
|
||||
}}>
|
||||
<strong style={{fontWeight: 600}}>{color}</strong>
|
||||
|
|
@ -157,8 +157,8 @@ export function ThemeSamplePage() {
|
|||
const [page, setPage] = useState(3);
|
||||
|
||||
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>
|
||||
<p style={{color: 'var(--muted)', fontSize: 13, marginTop: 0}}>
|
||||
<h1 style={{fontSize: '1.3125rem', fontWeight: 600, margin: '8px 0 4px'}}>Component gallery</h1>
|
||||
<p style={{color: 'var(--muted)', fontSize: '0.8125rem', marginTop: 0}}>
|
||||
Every component in the WROLPi interface library, rendered in the <strong>{theme}</strong> theme.
|
||||
Switch themes here or from the navigation bar.
|
||||
</p>
|
||||
|
|
@ -166,7 +166,7 @@ export function ThemeSamplePage() {
|
|||
<Section label='Theme picker'>
|
||||
<Panel>
|
||||
<ThemePicker/>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginBottom: 0, marginTop: 12}}>
|
||||
<p style={{fontSize: '0.75rem', color: 'var(--muted)', marginBottom: 0, marginTop: 12}}>
|
||||
The same picker the Settings page uses. The navigation bar has a compact
|
||||
version; both read the same list of themes.
|
||||
</p>
|
||||
|
|
@ -175,7 +175,7 @@ export function ThemeSamplePage() {
|
|||
|
||||
<Section label='Navigation bars'>
|
||||
<Panel>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginTop: 0}}>
|
||||
<p style={{fontSize: '0.75rem', color: 'var(--muted)', marginTop: 0}}>
|
||||
Every color the navigation bar can be set to (Settings → navbar
|
||||
color), in the <strong>{theme}</strong> theme. The text and icons are not
|
||||
a fixed color: each bar is measured, and drawn in whichever of this
|
||||
|
|
@ -199,7 +199,7 @@ export function ThemeSamplePage() {
|
|||
*/}
|
||||
<img src='/icon.svg' alt='The WROLPi logo, filtered like any other media'
|
||||
width={104} height={104}/>
|
||||
<p style={{fontSize: 11, color: 'var(--muted)', margin: '4px 0 0'}}>
|
||||
<p style={{fontSize: '0.6875rem', color: 'var(--muted)', margin: '4px 0 0'}}>
|
||||
Filtered
|
||||
</p>
|
||||
</div>
|
||||
|
|
@ -214,11 +214,11 @@ export function ThemeSamplePage() {
|
|||
alt='The WROLPi logo, unfiltered' width={104} height={104}/>
|
||||
: <Button role='cancel' icon='eye' style={{width: 104, height: 104}}
|
||||
onClick={() => setRealColors(true)}>Show</Button>}
|
||||
<p style={{fontSize: 11, color: 'var(--muted)', margin: '4px 0 0'}}>
|
||||
<p style={{fontSize: '0.6875rem', color: 'var(--muted)', margin: '4px 0 0'}}>
|
||||
Real colors
|
||||
</p>
|
||||
</div>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', margin: 0, maxWidth: 430}}>
|
||||
<p style={{fontSize: '0.75rem', color: 'var(--muted)', margin: 0, maxWidth: 430}}>
|
||||
Images, video, PDFs, embedded pages, and the map canvas cannot read theme
|
||||
tokens, so a monochrome theme remaps them with an SVG color matrix instead.
|
||||
Night filters to red unless you turn it off; amber tints to match only if
|
||||
|
|
@ -237,7 +237,7 @@ export function ThemeSamplePage() {
|
|||
*/}
|
||||
<div style={{marginTop: 14}}>
|
||||
<MediaFilterToggle/>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', margin: '8px 0 0'}}>
|
||||
<p style={{fontSize: '0.75rem', color: 'var(--muted)', margin: '8px 0 0'}}>
|
||||
<code>MediaFilterToggle</code>, the control the theme picker ends with.
|
||||
It is per theme — turning it off for night leaves amber's alone — and it
|
||||
renders nothing for a theme that offers no filter, so light and dark
|
||||
|
|
@ -262,7 +262,7 @@ export function ThemeSamplePage() {
|
|||
<Header as='h3' after={<Icon name='question' size='small'/>}>
|
||||
With a help icon beside it
|
||||
</Header>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginBottom: 0}}>
|
||||
<p style={{fontSize: '0.75rem', 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>
|
||||
|
|
@ -332,11 +332,11 @@ export function ThemeSamplePage() {
|
|||
</div>)}
|
||||
</Row>
|
||||
</div>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginBottom: 0}}>
|
||||
<p style={{fontSize: '0.75rem', color: 'var(--muted)', marginBottom: 0}}>
|
||||
In night mode Delete drops its fill for a dashed red outline; dashed means
|
||||
destructive or failed, and nothing else uses it.
|
||||
</p>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginBottom: 0}}>
|
||||
<p style={{fontSize: '0.75rem', color: 'var(--muted)', marginBottom: 0}}>
|
||||
An icon button is exactly as tall as a labelled one at every size, so a
|
||||
group of them lines up. Mantine's own scale for icon buttons is unrelated
|
||||
to its scale for buttons — <code>sm</code> is 22px against a button's 36px
|
||||
|
|
@ -415,7 +415,7 @@ export function ThemeSamplePage() {
|
|||
<Button role='danger' onClick={() => clearToasts()}>Clear all</Button>
|
||||
</Row>
|
||||
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginBottom: 0}}>
|
||||
<p style={{fontSize: '0.75rem', color: 'var(--muted)', marginBottom: 0}}>
|
||||
Top right, five at a time, five seconds each unless the caller says
|
||||
otherwise. Check each type in all four themes: night has no second hue to
|
||||
spend, so info, success, warning and error cannot be told apart by color
|
||||
|
|
@ -447,13 +447,13 @@ export function ThemeSamplePage() {
|
|||
<div style={{
|
||||
height: 34, background: `var(--${role})`, marginBottom: 6,
|
||||
}}/>
|
||||
<div style={{fontSize: 13, fontWeight: 600, color: `var(--${role})`}}>
|
||||
<div style={{fontSize: '0.8125rem', fontWeight: 600, color: `var(--${role})`}}>
|
||||
{role}
|
||||
</div>
|
||||
<div style={{fontSize: 11, color: 'var(--muted)'}}>{meaning}</div>
|
||||
<div style={{fontSize: '0.6875rem', color: 'var(--muted)'}}>{meaning}</div>
|
||||
</div>)}
|
||||
</div>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginTop: 14, marginBottom: 0}}>
|
||||
<p style={{fontSize: '0.75rem', color: 'var(--muted)', marginTop: 14, marginBottom: 0}}>
|
||||
Components ask for a <em>meaning</em> — <code>danger</code> — not a hue.
|
||||
Light and dark spend a color on each. Night and amber have only one hue,
|
||||
so a role is a step on a brightness ramp instead; that is why an error and
|
||||
|
|
@ -473,7 +473,7 @@ export function ThemeSamplePage() {
|
|||
<Status kind='pending'>pending</Status>
|
||||
<Status kind='failed'>failed</Status>
|
||||
</div>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginTop: 12, marginBottom: 0}}>
|
||||
<p style={{fontSize: '0.75rem', color: 'var(--muted)', marginTop: 12, marginBottom: 0}}>
|
||||
Four states drawn from four roles. Failure also carries weight, because
|
||||
brightness is the first thing lost on a dim screen and it is all night has.
|
||||
</p>
|
||||
|
|
@ -521,7 +521,7 @@ export function ThemeSamplePage() {
|
|||
<Progress percent={80} color='warning' label='Disk 80% full'/>
|
||||
<Progress percent={100} color='danger' label='Error: HTTP 403'/>
|
||||
</div>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginTop: 14, marginBottom: 0}}>
|
||||
<p style={{fontSize: '0.75rem', color: 'var(--muted)', marginTop: 14, marginBottom: 0}}>
|
||||
A bar is 22px so its label has room; at 16px the text filled the bar edge to
|
||||
edge. Check the mid-range ones — 37% and 62% are where the label crosses the
|
||||
boundary between fill and track, which is the case that has to work.
|
||||
|
|
@ -656,7 +656,7 @@ export function ThemeSamplePage() {
|
|||
<ColoredInput label='Ω' color='red' defaultValue='50'/>
|
||||
<ColoredInput label='gal' color='green' labelPosition='right' defaultValue='275'/>
|
||||
</div>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginTop: 8, marginBottom: 0}}>
|
||||
<p style={{fontSize: '0.75rem', color: 'var(--muted)', marginTop: 8, marginBottom: 0}}>
|
||||
ColoredInput welds a Label to one edge of a field — the calculators' unit
|
||||
markers. In night and amber the Label is an outline rather than a fill, so
|
||||
the marker reads without a block of color.
|
||||
|
|
@ -695,7 +695,7 @@ export function ThemeSamplePage() {
|
|||
clearable
|
||||
placeholder='Search directory names…'
|
||||
/>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginBottom: 0, marginTop: 12}}>
|
||||
<p style={{fontSize: '0.75rem', color: 'var(--muted)', marginBottom: 0, marginTop: 12}}>
|
||||
Focus the field to see grouped suggestions. Arrow keys move, Enter takes the
|
||||
highlighted one or submits what you typed, Escape closes the list without
|
||||
clearing the text.
|
||||
|
|
@ -714,7 +714,7 @@ export function ThemeSamplePage() {
|
|||
>{tab}</button>)}
|
||||
</TabBar>
|
||||
<Pagination activePage={page} totalPages={12} onPageChange={setPage} showFirstAndLast/>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginBottom: 0, marginTop: 12}}>
|
||||
<p style={{fontSize: '0.75rem', color: 'var(--muted)', marginBottom: 0, marginTop: 12}}>
|
||||
Night and amber mark the current page with a heavier border rather than a
|
||||
filled block, which would be a bright surface. The tab bar takes rendered
|
||||
children, so routing stays with the caller.
|
||||
|
|
@ -757,7 +757,7 @@ export function ThemeSamplePage() {
|
|||
style={{'--label-color': color, '--label-text': contrastingColor(color)}}
|
||||
>{name}</span>)}
|
||||
</Row>
|
||||
<p style={{marginTop: 14, fontSize: 13, color: 'var(--muted)'}}>
|
||||
<p style={{marginTop: 14, fontSize: '0.8125rem', color: 'var(--muted)'}}>
|
||||
Every tag must be readable in all four themes. In night and amber the
|
||||
user's color is discarded, so all tags look alike — that is the same
|
||||
trade the labels above make, and it is deliberate.
|
||||
|
|
@ -775,7 +775,7 @@ export function ThemeSamplePage() {
|
|||
<Row>
|
||||
<Loader/>
|
||||
<Icon name='circle notch' loading/>
|
||||
<span style={{fontSize: 12, color: 'var(--muted)'}}>
|
||||
<span style={{fontSize: '0.75rem', color: 'var(--muted)'}}>
|
||||
Icons inherit currentColor, so they follow every theme.
|
||||
</span>
|
||||
</Row>
|
||||
|
|
@ -798,7 +798,7 @@ export function ThemeSamplePage() {
|
|||
style={{'--icon-stack-bg': 'var(--panel)'}}>
|
||||
<Icon name='download' size='large'/>
|
||||
</IconStack>
|
||||
<span style={{fontSize: 12, color: 'var(--muted)', maxWidth: 400}}>
|
||||
<span style={{fontSize: '0.75rem', color: 'var(--muted)', maxWidth: 400}}>
|
||||
<code>IconStack</code> composes two glyphs into one symbol. The corner
|
||||
glyph paints the surface behind itself so the two sets of strokes do not
|
||||
cross, which means it has to be told what that surface is:{' '}
|
||||
|
|
@ -846,7 +846,7 @@ export function ThemeSamplePage() {
|
|||
</div>}
|
||||
/>)}
|
||||
</CardGroup>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginTop: 10}}>
|
||||
<p style={{fontSize: '0.75rem', color: 'var(--muted)', marginTop: 10}}>
|
||||
A poster is capped on both axes — the card's width, and{' '}
|
||||
<code>--card-poster-max-height</code> — and keeps its own ratio whichever
|
||||
cap bites. Capping the width alone let a square thumbnail stand as tall as
|
||||
|
|
@ -872,13 +872,13 @@ export function ThemeSamplePage() {
|
|||
</div> : undefined}
|
||||
/>)}
|
||||
</CardGroup>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginTop: 10}}>
|
||||
<p style={{fontSize: '0.75rem', color: 'var(--muted)', marginTop: 10}}>
|
||||
Titles are links but take the body color, not the link color — a grid of
|
||||
results should read as titles. The meta line sits directly under the title;
|
||||
actions are pushed to the foot, so a row lines its buttons up however many
|
||||
lines each title took. A card with no actions simply ends.
|
||||
</p>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginTop: 10}}>
|
||||
<p style={{fontSize: '0.75rem', color: 'var(--muted)', marginTop: 10}}>
|
||||
The bottom edge carries the file type's color, so a grid of results is
|
||||
scannable by kind before any title is read. It comes from a token, so night
|
||||
and amber render the accent in their own single hue rather than four.
|
||||
|
|
@ -897,7 +897,7 @@ export function ThemeSamplePage() {
|
|||
<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}}>
|
||||
<p style={{fontSize: '0.75rem', 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>
|
||||
|
|
@ -919,8 +919,8 @@ export function ThemeSamplePage() {
|
|||
|
||||
<Section label='Danger zone'>
|
||||
<Panel danger>
|
||||
<h2 style={{color: 'var(--danger)', fontSize: 14, margin: '0 0 4px'}}>Danger zone</h2>
|
||||
<p style={{color: 'var(--muted)', fontSize: 13, margin: '0 0 12px'}}>
|
||||
<h2 style={{color: 'var(--danger)', fontSize: '0.875rem', margin: '0 0 4px'}}>Danger zone</h2>
|
||||
<p style={{color: 'var(--muted)', fontSize: '0.8125rem', margin: '0 0 12px'}}>
|
||||
These actions are destructive and cannot be undone.
|
||||
</p>
|
||||
<Row>
|
||||
|
|
@ -934,7 +934,7 @@ export function ThemeSamplePage() {
|
|||
Delete tagged files
|
||||
</Button>
|
||||
</Row>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginBottom: 0, marginTop: 10}}>
|
||||
<p style={{fontSize: '0.75rem', color: 'var(--muted)', marginBottom: 0, marginTop: 10}}>
|
||||
A confirmation is 380px wide, which suits a question. One that has to show
|
||||
what it is about takes a size, in the same vocabulary as Modal.
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ export function VideosSettingsPage() {
|
|||
value={configForm.formData.sleep_requests ?? 0.75}
|
||||
onChange={(value) => configForm.setValue('sleep_requests', parseFloat(value) || 0)}
|
||||
placeholder='0.75'
|
||||
rightSection={<span style={{fontSize: 12, color: 'var(--muted)'}}>sec</span>}
|
||||
rightSection={<span style={{fontSize: '0.75rem', color: 'var(--muted)'}}>sec</span>}
|
||||
rightSectionWidth={36}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ function fmtSpeed(speed) {
|
|||
function WheelInput({hex, label, value, onChange, name, min, step}) {
|
||||
return <Group gap={0} wrap='nowrap' align='stretch' style={{marginBottom: '0.25em'}}>
|
||||
<span style={{
|
||||
display: 'flex', alignItems: 'center', padding: '0 10px', fontSize: 13, fontWeight: 500,
|
||||
display: 'flex', alignItems: 'center', padding: '0 10px', fontSize: '0.8125rem', fontWeight: 500,
|
||||
whiteSpace: 'nowrap', background: hex, color: textColorFor(hex), border: `1px solid ${hex}`,
|
||||
}}>{label}</span>
|
||||
<NumberInput name={name} value={value} onChange={onChange} min={min} step={step}
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ export function clampNonNegative(value) {
|
|||
function SwatchInput({hex, label, value, onChange, name, min, step}) {
|
||||
return <Group gap={0} wrap='nowrap' align='stretch' style={{marginBottom: '0.25em'}}>
|
||||
<span style={{
|
||||
display: 'flex', alignItems: 'center', padding: '0 10px', fontSize: 13, fontWeight: 500,
|
||||
display: 'flex', alignItems: 'center', padding: '0 10px', fontSize: '0.8125rem', fontWeight: 500,
|
||||
whiteSpace: 'nowrap', background: hex, color: textColorFor(hex), border: `1px solid ${hex}`,
|
||||
}}>{label}</span>
|
||||
<NumberInput name={name} value={value} onChange={onChange} min={min} step={step}
|
||||
|
|
|
|||
|
|
@ -211,20 +211,20 @@ export interface LoadingProps {
|
|||
* used with their own wrapper div.
|
||||
*/
|
||||
export function Loading({children, size = 'sm', padding = '2em'}: LoadingProps) {
|
||||
return <div style={{
|
||||
display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 10, padding,
|
||||
}}>
|
||||
// `padding` is the caller's, so it stays inline; the rest is in ui.css so it scales.
|
||||
return <div className='wrolpi-loading' style={{padding}}>
|
||||
<Loader size={size} label={typeof children === 'string' ? children : undefined}/>
|
||||
{children && <div style={{fontSize: 13, color: 'var(--muted)'}}>{children}</div>}
|
||||
{children && <div className='wrolpi-loading-caption'>{children}</div>}
|
||||
</div>
|
||||
}
|
||||
|
||||
/** Placeholder for content that has not arrived. Replaces Semantic's Placeholder. */
|
||||
export function Placeholder({lines = 3, height = 12}: {lines?: number; height?: number}) {
|
||||
return <div style={{display: 'flex', flexDirection: 'column', gap: 8}}>
|
||||
return <div className='wrolpi-placeholder'>
|
||||
{Array.from({length: lines}, (_, index) => <Skeleton
|
||||
key={index}
|
||||
height={height}
|
||||
// In rem so a placeholder line matches the height of the text it stands in for.
|
||||
height={`${height / 16}rem`}
|
||||
// A ragged last line reads as text rather than a block.
|
||||
width={index === lines - 1 ? '60%' : '100%'}
|
||||
radius={0}
|
||||
|
|
|
|||
|
|
@ -205,8 +205,7 @@ export function ColoredInput({
|
|||
}: ColoredInputProps) {
|
||||
const labelNode = label ? <Label color={color || 'grey'}>{label}</Label> : null;
|
||||
|
||||
return <div style={{
|
||||
display: 'flex', alignItems: 'stretch', gap: 6,
|
||||
return <div className='wrolpi-colored-input' style={{
|
||||
width: fluid ? '100%' : undefined, ...style,
|
||||
}}>
|
||||
{labelNode && labelPosition === 'left' && labelNode}
|
||||
|
|
|
|||
|
|
@ -233,7 +233,9 @@ export function Confirm({
|
|||
*/
|
||||
return <Modal opened={open} onClose={() => onCancel?.()} title={title} size={size}>
|
||||
{children}
|
||||
<div style={{display: 'flex', justifyContent: 'flex-end', gap: 10, marginTop: 18}}>
|
||||
{/* Its own class rather than `.wrolpi-modal-actions`: a confirmation's buttons sit
|
||||
under its question with no hairline, where a Modal's are a separated footer. */}
|
||||
<div className='wrolpi-confirm-actions'>
|
||||
<Button role='cancel' onClick={onCancel}>{cancelLabel}</Button>
|
||||
<Button role={destructive ? 'danger' : 'save'} loading={loading} onClick={onConfirm}>
|
||||
{confirmLabel}
|
||||
|
|
|
|||
|
|
@ -192,11 +192,12 @@ export function Card({media, title, meta, children, actions, onClick, color, cla
|
|||
}}
|
||||
>
|
||||
{media && <div style={{borderBottom: '1px solid var(--border)'}}>{media}</div>}
|
||||
<div style={{padding: '10px 12px 12px', display: 'flex', flexDirection: 'column', gap: 4, flex: 1}}>
|
||||
{title && <div style={{fontSize: 13, fontWeight: 600, lineHeight: 1.35}}>{title}</div>}
|
||||
{meta && <div className='wrolpi-card-meta' style={{fontSize: 12, color: 'var(--muted)'}}>{meta}</div>}
|
||||
{/* Sizes live in ui.css, in rem: inline px would sit outside the interface scale. */}
|
||||
<div className='wrolpi-card-body'>
|
||||
{title && <div className='wrolpi-card-title'>{title}</div>}
|
||||
{meta && <div className='wrolpi-card-meta'>{meta}</div>}
|
||||
{children}
|
||||
{actions && <div className='wrolpi-card-actions' style={{marginTop: 'auto', paddingTop: 8}}>
|
||||
{actions && <div className='wrolpi-card-actions'>
|
||||
{actions}
|
||||
</div>}
|
||||
</div>
|
||||
|
|
@ -216,9 +217,15 @@ export function CardGroup({children, minWidth = 200, className, style, ...props}
|
|||
return <div
|
||||
className={['wrolpi-card-group', className].filter(Boolean).join(' ')}
|
||||
style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: `repeat(auto-fill, minmax(${minWidth}px, 1fr))`,
|
||||
gap: 14,
|
||||
/*
|
||||
* Converted to rem so a column grows with the interface scale. As px it did not,
|
||||
* and a 430px phone fitted two 200px cards where the pre-migration build fitted
|
||||
* one 290px card -- the narrowest card in the app, on the smallest screen.
|
||||
*
|
||||
* The prop stays a px number: seven call sites pass one, and a caller thinking in
|
||||
* px is thinking about the unscaled design.
|
||||
*/
|
||||
gridTemplateColumns: `repeat(auto-fill, minmax(${minWidth / 16}rem, 1fr))`,
|
||||
...style,
|
||||
}}
|
||||
{...props}
|
||||
|
|
|
|||
|
|
@ -131,17 +131,17 @@ html .mantine-ActionIcon-root {
|
|||
|
||||
.wrolpi-theme-picker {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
|
||||
gap: 10px;
|
||||
grid-template-columns: repeat(auto-fit, minmax(14.375rem, 1fr));
|
||||
gap: 0.625rem;
|
||||
}
|
||||
|
||||
.wrolpi-theme-option {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
gap: 0.25rem;
|
||||
align-items: flex-start;
|
||||
text-align: left;
|
||||
padding: 10px 12px;
|
||||
padding: 0.625rem 0.75rem;
|
||||
background: var(--panel);
|
||||
color: var(--text);
|
||||
border: 1px solid var(--border);
|
||||
|
|
@ -157,7 +157,7 @@ html .mantine-ActionIcon-root {
|
|||
selection survives in monochrome themes. */
|
||||
.wrolpi-theme-option-active {
|
||||
border: 2px solid var(--blue);
|
||||
padding: 9px 11px;
|
||||
padding: 0.5625rem 0.6875rem;
|
||||
}
|
||||
|
||||
html[data-theme="night"] .wrolpi-theme-option-active,
|
||||
|
|
@ -173,21 +173,21 @@ html[data-theme="amber"] .wrolpi-theme-option-active {
|
|||
.wrolpi-theme-option-name {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
gap: 0.4375rem;
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
.wrolpi-theme-option-description {
|
||||
font-size: 12px;
|
||||
font-size: 0.75rem;
|
||||
color: var(--muted);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
/* Separated from the theme grid: it configures the chosen theme, it is not a choice. */
|
||||
.wrolpi-media-filter-setting {
|
||||
margin-top: 14px;
|
||||
padding-top: 12px;
|
||||
margin-top: 0.875rem;
|
||||
padding-top: 0.75rem;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
|
|
@ -247,9 +247,9 @@ html[data-theme="amber"] .wrolpi-pagination button[data-active] {
|
|||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
gap: 0.75rem;
|
||||
border-bottom: 1px solid var(--border);
|
||||
margin-bottom: 14px;
|
||||
margin-bottom: 0.875rem;
|
||||
}
|
||||
|
||||
.wrolpi-tabs-links {
|
||||
|
|
@ -258,15 +258,15 @@ html[data-theme="amber"] .wrolpi-pagination button[data-active] {
|
|||
}
|
||||
|
||||
.wrolpi-tabs-right {
|
||||
padding-bottom: 6px;
|
||||
padding-bottom: 0.375rem;
|
||||
}
|
||||
|
||||
.wrolpi-tab {
|
||||
display: inline-block;
|
||||
padding: 8px 14px;
|
||||
padding: 0.5rem 0.875rem;
|
||||
color: var(--muted);
|
||||
text-decoration: none;
|
||||
font-size: 13px;
|
||||
font-size: 0.8125rem;
|
||||
/*
|
||||
* A tab is a NavLink in the app's nav bars but a <button> on Inventory and in the
|
||||
* gallery, and a button carries the UA's own `buttonface` background -- rgb(239,239,239).
|
||||
|
|
@ -313,7 +313,7 @@ html[data-theme="amber"] .wrolpi-pagination button[data-active] {
|
|||
* stay in lockstep: changing the padding alone would have pushed the clear button past
|
||||
* the border, and changing the gap alone would have re-inset it.
|
||||
*/
|
||||
--searchbox-inset: 8px;
|
||||
--searchbox-inset: 0.5rem;
|
||||
gap: var(--searchbox-inset);
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--border);
|
||||
|
|
@ -337,13 +337,13 @@ html[data-theme="amber"] .wrolpi-searchbox-control:focus-within {
|
|||
.wrolpi-searchbox-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
padding: 8px 0;
|
||||
padding: 0.5rem 0;
|
||||
background: none;
|
||||
border: none;
|
||||
outline: none;
|
||||
color: var(--text);
|
||||
font: inherit;
|
||||
font-size: 13px;
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
.wrolpi-searchbox-input::placeholder {
|
||||
|
|
@ -402,7 +402,7 @@ html .wrolpi-searchbox-clear {
|
|||
* domains together run past 320px, and the last group was being clipped -- but
|
||||
* still capped so a long list cannot cover the page.
|
||||
*/
|
||||
max-height: min(60vh, 480px);
|
||||
max-height: min(60vh, 30rem);
|
||||
overflow-y: auto;
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--border);
|
||||
|
|
@ -422,12 +422,12 @@ html .wrolpi-searchbox-clear {
|
|||
*/
|
||||
.wrolpi-search-modal .wrolpi-searchbox-results {
|
||||
position: static;
|
||||
max-height: min(50vh, 420px);
|
||||
max-height: min(50vh, 26.25rem);
|
||||
}
|
||||
|
||||
.wrolpi-searchbox-group-name {
|
||||
padding: 6px 10px;
|
||||
font-size: 11px;
|
||||
padding: 0.375rem 0.625rem;
|
||||
font-size: 0.6875rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
|
|
@ -436,7 +436,7 @@ html .wrolpi-searchbox-clear {
|
|||
}
|
||||
|
||||
.wrolpi-searchbox-result {
|
||||
padding: 7px 10px;
|
||||
padding: 0.4375rem 0.625rem;
|
||||
cursor: pointer;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
|
@ -446,19 +446,19 @@ html .wrolpi-searchbox-clear {
|
|||
}
|
||||
|
||||
.wrolpi-searchbox-result-title {
|
||||
font-size: 13px;
|
||||
font-size: 0.8125rem;
|
||||
color: var(--text);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.wrolpi-searchbox-result-description {
|
||||
font-size: 11px;
|
||||
font-size: 0.6875rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.wrolpi-searchbox-empty {
|
||||
padding: 10px;
|
||||
font-size: 12px;
|
||||
padding: 0.625rem;
|
||||
font-size: 0.75rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
|
|
@ -472,19 +472,27 @@ html .wrolpi-searchbox-clear {
|
|||
display: flex;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
gap: 0.625rem;
|
||||
/* Bleed back out through the modal body's own padding so the rule spans the
|
||||
full width; -1 * whatever Mantine padded the body with. */
|
||||
margin: 18px calc(var(--mantine-spacing-md) * -1) calc(var(--mantine-spacing-md) * -1);
|
||||
padding: 12px var(--mantine-spacing-md);
|
||||
margin: 1.125rem calc(var(--mantine-spacing-md) * -1) calc(var(--mantine-spacing-md) * -1);
|
||||
padding: 0.75rem var(--mantine-spacing-md);
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
/* A confirmation's buttons: under the question, no separating rule. See Confirm. */
|
||||
.wrolpi-confirm-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.625rem;
|
||||
margin-top: 1.125rem;
|
||||
}
|
||||
|
||||
/* A stack of form rows, replacing Semantic's `ui stackable grid` in edit forms. */
|
||||
.wrolpi-form-rows {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
gap: 0.875rem;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- Form fields */
|
||||
|
|
@ -509,12 +517,12 @@ html .wrolpi-searchbox-clear {
|
|||
|
||||
.wrolpi-form-field input {
|
||||
width: 100%;
|
||||
padding: 7px 9px;
|
||||
padding: 0.4375rem 0.5625rem;
|
||||
background: var(--panel);
|
||||
color: var(--text);
|
||||
border: 1px solid var(--border);
|
||||
font: inherit;
|
||||
font-size: 13px;
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
.wrolpi-form-field input::placeholder {
|
||||
|
|
@ -552,8 +560,8 @@ html[data-theme="amber"] .wrolpi-form-field input:focus {
|
|||
.wrolpi-path-input-label {
|
||||
display: block;
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
margin-bottom: 4px;
|
||||
font-size: 0.8125rem;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.wrolpi-path-input-control {
|
||||
|
|
@ -598,11 +606,11 @@ html[data-theme="amber"] .wrolpi-path-input-control:focus-within {
|
|||
max-width: 50%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
padding: 0 6px 0 9px;
|
||||
padding: 0 0.375rem 0 0.5625rem;
|
||||
background: var(--head);
|
||||
border-right: 1px solid var(--border);
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
font-size: 0.75rem;
|
||||
white-space: nowrap;
|
||||
user-select: none;
|
||||
}
|
||||
|
|
@ -610,13 +618,13 @@ html[data-theme="amber"] .wrolpi-path-input-control:focus-within {
|
|||
.wrolpi-path-input-control input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
padding: 7px 9px;
|
||||
padding: 0.4375rem 0.5625rem;
|
||||
background: none;
|
||||
border: none;
|
||||
outline: none;
|
||||
color: var(--text);
|
||||
font: inherit;
|
||||
font-size: 13px;
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
.wrolpi-path-input-control input::placeholder {
|
||||
|
|
@ -628,15 +636,15 @@ html[data-theme="amber"] .wrolpi-path-input-control:focus-within {
|
|||
}
|
||||
|
||||
.wrolpi-path-input-description {
|
||||
font-size: 12px;
|
||||
font-size: 0.75rem;
|
||||
color: var(--muted);
|
||||
margin-top: 3px;
|
||||
margin-top: 0.1875rem;
|
||||
}
|
||||
|
||||
.wrolpi-path-input-error {
|
||||
font-size: 12px;
|
||||
font-size: 0.75rem;
|
||||
color: var(--danger);
|
||||
margin-top: 3px;
|
||||
margin-top: 0.1875rem;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------- Action inputs */
|
||||
|
|
@ -664,6 +672,37 @@ html[data-theme="amber"] .wrolpi-path-input-control:focus-within {
|
|||
flex: none;
|
||||
}
|
||||
|
||||
/* A colored label beside an input, unlike ActionInput's shared outline: they stay two
|
||||
controls, so the gap between them is real and scales with the type. */
|
||||
.wrolpi-colored-input {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------- Loading & placeholders */
|
||||
/*
|
||||
* A centered loader with a caption, and the skeleton stack that stands in for text.
|
||||
* Both were inline px in Feedback.tsx, which put them outside the interface scale.
|
||||
*/
|
||||
.wrolpi-loading {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
}
|
||||
|
||||
.wrolpi-loading-caption {
|
||||
font-size: 0.8125rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.wrolpi-placeholder {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------- Switches */
|
||||
/*
|
||||
* Mantine's unchecked track is a gray from its own palette, which would put a
|
||||
|
|
@ -713,9 +752,9 @@ html[data-theme="amber"] .wrolpi-path-input-control:focus-within {
|
|||
.wrolpi-label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 5px 10px;
|
||||
font-size: 12.5px;
|
||||
gap: 0.25rem;
|
||||
padding: 0.3125rem 0.625rem;
|
||||
font-size: 0.78125rem;
|
||||
font-weight: 500;
|
||||
line-height: 1.3;
|
||||
background: var(--label-color);
|
||||
|
|
@ -747,16 +786,16 @@ html[data-theme="amber"] .wrolpi-path-input-control:focus-within {
|
|||
* Room for the point, which is drawn outside the body: half its diagonal (14.1px) plus
|
||||
* the 1px it is nudged left, rounded up.
|
||||
*/
|
||||
margin-left: 16px;
|
||||
margin-left: 1rem;
|
||||
/* Tags wrap, and a wrapped row was sitting on the row above it. */
|
||||
margin-bottom: 5px;
|
||||
margin-bottom: 0.3125rem;
|
||||
/*
|
||||
* The point is centred on the left edge, so its inner half covers the body's first 10px
|
||||
* -- and a positioned pseudo-element paints above the parent's text, not behind it, so
|
||||
* without this the first letter is hidden under the point. Semantic's tag label carried
|
||||
* the same asymmetry (`padding-left: 1.5em`) for the same reason.
|
||||
*/
|
||||
padding-left: 13px;
|
||||
padding-left: 0.8125rem;
|
||||
}
|
||||
|
||||
.wrolpi-tag::before {
|
||||
|
|
@ -764,8 +803,8 @@ html[data-theme="amber"] .wrolpi-path-input-control:focus-within {
|
|||
position: absolute;
|
||||
top: 50%;
|
||||
right: 100%;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
width: 1.25rem;
|
||||
height: 1.25rem;
|
||||
/*
|
||||
* Nudged 1px left of where `right: 100%` puts it. That property positions against the
|
||||
* containing block's *padding* box, and the body carries a 1px border, so a square centred
|
||||
|
|
@ -788,8 +827,8 @@ html[data-theme="amber"] .wrolpi-path-input-control:focus-within {
|
|||
position: absolute;
|
||||
top: 50%;
|
||||
left: -7px;
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
width: 0.3125rem;
|
||||
height: 0.3125rem;
|
||||
margin-top: -2.5px;
|
||||
border-radius: 50%;
|
||||
background: currentColor;
|
||||
|
|
@ -842,7 +881,7 @@ html[data-theme="night"] .wrolpi-tag::before {
|
|||
/* ---------------------------------------------------------------- Headers */
|
||||
|
||||
.wrolpi-header {
|
||||
margin: 0 0 10px;
|
||||
margin: 0 0 0.625rem;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -855,14 +894,14 @@ html[data-theme="night"] .wrolpi-tag::before {
|
|||
* where it should be, and pushing it down would just dent the top of its own container.
|
||||
*/
|
||||
* + .wrolpi-header {
|
||||
margin-top: 22px;
|
||||
margin-top: 1.375rem;
|
||||
}
|
||||
|
||||
/* The heading and its trailing control share one row. */
|
||||
.wrolpi-header-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -880,19 +919,19 @@ html[data-theme="night"] .wrolpi-tag::before {
|
|||
display: inline-flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
font-size: 13px;
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.wrolpi-header-dividing {
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding-bottom: 6px;
|
||||
padding-bottom: 0.375rem;
|
||||
}
|
||||
|
||||
.wrolpi-header-text {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
gap: 0.5rem;
|
||||
margin: 0;
|
||||
/*
|
||||
* Stated explicitly because semantic.min.css sets `h1,h2,h3,h4,h5 { font-family:
|
||||
|
|
@ -909,30 +948,30 @@ html[data-theme="night"] .wrolpi-tag::before {
|
|||
|
||||
/* The scale lives here so no call site invents a size of its own. */
|
||||
.wrolpi-header-h1 {
|
||||
font-size: 26px;
|
||||
font-size: 1.625rem;
|
||||
}
|
||||
|
||||
.wrolpi-header-h2 {
|
||||
font-size: 21px;
|
||||
font-size: 1.3125rem;
|
||||
}
|
||||
|
||||
.wrolpi-header-h3 {
|
||||
font-size: 17px;
|
||||
font-size: 1.0625rem;
|
||||
}
|
||||
|
||||
.wrolpi-header-h4 {
|
||||
font-size: 14px;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.wrolpi-header-h5 {
|
||||
font-size: 13px;
|
||||
font-size: 0.8125rem;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.wrolpi-header-sub {
|
||||
font-size: 12px;
|
||||
font-size: 0.75rem;
|
||||
color: var(--muted);
|
||||
margin-top: 3px;
|
||||
margin-top: 0.1875rem;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1015,12 +1054,12 @@ html .mantine-Notification-closeButton:hover {
|
|||
.wrolpi-message {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
gap: 0.625rem;
|
||||
border: 1px solid var(--border);
|
||||
border-left: 3px solid var(--message-color, var(--border));
|
||||
background: var(--panel);
|
||||
padding: 10px 14px;
|
||||
font-size: 13px;
|
||||
padding: 0.625rem 0.875rem;
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
.wrolpi-message-content {
|
||||
|
|
@ -1044,7 +1083,7 @@ html .mantine-Notification-closeButton:hover {
|
|||
display: flex;
|
||||
/* Widen the tap target past the glyph without moving it. */
|
||||
margin: -6px -6px -6px 0;
|
||||
padding: 6px;
|
||||
padding: 0.375rem;
|
||||
}
|
||||
|
||||
.wrolpi-message-dismiss:hover {
|
||||
|
|
@ -1058,7 +1097,7 @@ html .mantine-Notification-closeButton:hover {
|
|||
|
||||
.wrolpi-message-title {
|
||||
font-weight: 600;
|
||||
margin-bottom: 2px;
|
||||
margin-bottom: 0.125rem;
|
||||
}
|
||||
|
||||
.wrolpi-message-body {
|
||||
|
|
@ -1088,8 +1127,8 @@ html .mantine-Notification-closeButton:hover {
|
|||
*/
|
||||
.wrolpi-progress {
|
||||
position: relative;
|
||||
height: 22px;
|
||||
min-width: 120px;
|
||||
height: 1.375rem;
|
||||
min-width: 7.5rem;
|
||||
overflow: hidden;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
|
|
@ -1105,7 +1144,7 @@ html .mantine-Notification-closeButton:hover {
|
|||
* something, so an only-child bar in a column is untouched.
|
||||
*/
|
||||
* + .wrolpi-progress {
|
||||
margin-top: 8px;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.wrolpi-progress-fill {
|
||||
|
|
@ -1155,7 +1194,7 @@ html .mantine-Notification-closeButton:hover {
|
|||
align-items: center;
|
||||
justify-content: center;
|
||||
/* 12px rather than 11: these labels carry units and device names, not just a number. */
|
||||
font-size: 12px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
color: var(--text);
|
||||
font-variant-numeric: tabular-nums;
|
||||
|
|
@ -1166,7 +1205,7 @@ html .mantine-Notification-closeButton:hover {
|
|||
* it; with a hard clip and no ellipsis, `Complete: very-long-archive-name.tar.gz`
|
||||
* ends mid-glyph and reads as broken rather than truncated.
|
||||
*/
|
||||
padding: 0 6px;
|
||||
padding: 0 0.375rem;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
|
|
@ -1204,7 +1243,7 @@ html[data-theme="amber"] .wrolpi-progress-fill {
|
|||
.wrolpi-panel {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--border);
|
||||
padding: 14px 16px;
|
||||
padding: 0.875rem 1rem;
|
||||
}
|
||||
|
||||
/* Danger zones are dashed in every theme; it doubles as a colorblind-safe cue. */
|
||||
|
|
@ -1231,7 +1270,7 @@ html[data-theme="amber"] .wrolpi-progress-fill {
|
|||
* whichever cap bites first, the other axis comes down with it and the ratio survives.
|
||||
*/
|
||||
:root {
|
||||
--card-poster-max-height: 200px;
|
||||
--card-poster-max-height: 12.5rem;
|
||||
/* How far a disabled control fades. Semantic used 0.45 and it reads correctly against
|
||||
every theme's panel; the tests read this rather than repeating the number. */
|
||||
--disabled-opacity: 0.45;
|
||||
|
|
@ -1254,6 +1293,48 @@ html[data-theme="amber"] .wrolpi-progress-fill {
|
|||
justify-content: center;
|
||||
}
|
||||
|
||||
/*
|
||||
* The card's text block.
|
||||
*
|
||||
* These lived as inline px in Card's JSX, which put them outside the interface scale --
|
||||
* `fontSize: 13` is 13px whatever the root font-size is, so a card's title would have
|
||||
* stayed put while the prose around it grew. Rules now, for the same reason every other
|
||||
* size is one: a single place to retune, and ui-scale.test.js can see them.
|
||||
*/
|
||||
.wrolpi-card-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
flex: 1;
|
||||
padding: 0.625rem 0.75rem 0.75rem;
|
||||
}
|
||||
|
||||
.wrolpi-card-title {
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.wrolpi-card-meta {
|
||||
font-size: 0.75rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
/* The foot: `auto` pushes the actions down so a row of cards lines its buttons up
|
||||
however tall the titles above them got. ui-layout.cy.js measures that. */
|
||||
.wrolpi-card-actions {
|
||||
margin-top: auto;
|
||||
padding-top: 0.5rem;
|
||||
}
|
||||
|
||||
/* A grid of cards. The track width is the caller's `minWidth`, converted to rem in
|
||||
CardGroup so a column scales with the type -- which is what returns a phone to one
|
||||
card per row, as the pre-migration build had it. */
|
||||
.wrolpi-card-group {
|
||||
display: grid;
|
||||
gap: 0.875rem;
|
||||
}
|
||||
|
||||
.wrolpi-card-poster-frame {
|
||||
position: relative;
|
||||
display: block;
|
||||
|
|
@ -1273,7 +1354,7 @@ html[data-theme="amber"] .wrolpi-progress-fill {
|
|||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 120px;
|
||||
min-height: 7.5rem;
|
||||
background: var(--head);
|
||||
}
|
||||
|
||||
|
|
@ -1282,7 +1363,7 @@ html[data-theme="amber"] .wrolpi-progress-fill {
|
|||
top: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
padding: 3px 4px;
|
||||
padding: 0.1875rem 0.25rem;
|
||||
background: var(--green);
|
||||
color: var(--btn-text);
|
||||
}
|
||||
|
|
@ -1308,7 +1389,7 @@ html[data-theme="amber"] .wrolpi-card-tag {
|
|||
.wrolpi-statistic {
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
margin: 0 26px 10px 0;
|
||||
margin: 0 1.625rem 0.625rem 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1328,8 +1409,8 @@ html[data-theme="amber"] .wrolpi-card-tag {
|
|||
*/
|
||||
.wrolpi-statistic-group {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||
gap: 18px 30px;
|
||||
grid-template-columns: repeat(auto-fit, minmax(9.375rem, 1fr));
|
||||
gap: 1.125rem 1.875rem;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1341,7 +1422,7 @@ html[data-theme="amber"] .wrolpi-card-tag {
|
|||
* while leaving the bottom where it was, so the whole panel read as lopsided.
|
||||
*/
|
||||
* + .wrolpi-statistic-group {
|
||||
margin-top: 18px;
|
||||
margin-top: 1.125rem;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1362,18 +1443,18 @@ html[data-theme="amber"] .wrolpi-card-tag {
|
|||
}
|
||||
|
||||
.wrolpi-statistic-value {
|
||||
font-size: 24px;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 1.15;
|
||||
}
|
||||
|
||||
.wrolpi-statistic-label {
|
||||
font-size: 11px;
|
||||
font-size: 0.6875rem;
|
||||
letter-spacing: 0.1em;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
margin-top: 2px;
|
||||
margin-top: 0.125rem;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- Status */
|
||||
|
|
@ -1383,11 +1464,11 @@ html[data-theme="amber"] .wrolpi-card-tag {
|
|||
* replaced the three `html[data-theme="night"]` overrides that used to live below.
|
||||
*/
|
||||
.wrolpi-status {
|
||||
font-size: 12.5px;
|
||||
font-size: 0.78125rem;
|
||||
font-weight: 500;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
gap: 0.3125rem;
|
||||
color: var(--status-color);
|
||||
}
|
||||
|
||||
|
|
@ -1451,7 +1532,7 @@ html .mantine-Table-table[data-with-table-border] {
|
|||
.wrolpi-th-sort {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
gap: 0.3125rem;
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
|
|
|
|||
|
|
@ -903,6 +903,12 @@ describe('Card', () => {
|
|||
* card read buttons-then-domain. Which slot lands where is what this asserts; that
|
||||
* the foot anchoring actually resolves is in ui-layout.cy.js, since `margin-top:
|
||||
* auto` needs a layout engine.
|
||||
*
|
||||
* That division is why there is no `margin-top: auto` assertion here any more. There
|
||||
* was one, reading the inline style, and it broke when the card's sizes moved into
|
||||
* ui.css so the interface scale could reach them -- jsdom applies no stylesheet. It
|
||||
* was asserting where the declaration was written rather than what it did, and the
|
||||
* cypress test above measures the actual foot alignment either way.
|
||||
*/
|
||||
renderUI(<Card title='Rainwater Harvesting'
|
||||
meta='engineering775.com'
|
||||
|
|
@ -914,8 +920,8 @@ describe('Card', () => {
|
|||
expect([...body.children].map(child => child.textContent)).toEqual([
|
||||
'Rainwater Harvesting', 'engineering775.com', 'body', 'Details',
|
||||
]);
|
||||
expect(body.querySelector('.wrolpi-card-actions')).toHaveStyle({marginTop: 'auto'});
|
||||
expect(body.querySelector('.wrolpi-card-meta').style.marginTop).toBe('');
|
||||
expect(body.querySelector('.wrolpi-card-actions')).not.toBeNull();
|
||||
expect(body.querySelector('.wrolpi-card-meta')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('renders no actions row when a card has no actions', () => {
|
||||
|
|
@ -940,14 +946,20 @@ describe('CardGroup', () => {
|
|||
expect(screen.getByText('Three')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('lays cards out on a track no narrower than minWidth', () => {
|
||||
// The default suits file results; a group of wide cards raises it. If the value were
|
||||
// dropped the grid would fall back to one column, which is how a card wall becomes a
|
||||
// list on a desktop.
|
||||
it('lays cards out on a track no narrower than minWidth, in rem so it scales', () => {
|
||||
/*
|
||||
* The default suits file results; a group of wide cards raises it. If the value were
|
||||
* dropped the grid would fall back to one column, which is how a card wall becomes a
|
||||
* list on a desktop.
|
||||
*
|
||||
* The px the caller names is converted to rem, which is the whole reason a phone shows
|
||||
* one card per row again: as px, the track ignored the interface scale, and a 430px
|
||||
* screen fitted two 200px cards where the pre-migration build fitted one 290px card.
|
||||
*/
|
||||
const {container} = renderUI(<CardGroup minWidth={320}><Card title='One'/></CardGroup>);
|
||||
|
||||
expect(container.querySelector('.wrolpi-card-group'))
|
||||
.toHaveStyle({gridTemplateColumns: 'repeat(auto-fill, minmax(320px, 1fr))'});
|
||||
.toHaveStyle({gridTemplateColumns: 'repeat(auto-fill, minmax(20rem, 1fr))'});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -242,8 +242,48 @@ html[data-theme="amber"] {
|
|||
* None of it belonged to Semantic; it belongs here, expressed in tokens.
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Interface scale */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/*
|
||||
* How large the interface is, overall.
|
||||
*
|
||||
* Measured against the pre-migration Semantic build at 1280px, the drift was not one
|
||||
* number: its headings were h1 28 / h2 24 / h3 18 / h4 15 / h5 14 against our
|
||||
* 26 / 21 / 17 / 14 / 13, and its video card a fixed 290px with an 18px title against
|
||||
* our 238px with a 13px one -- while our BODY text and chrome went the other way,
|
||||
* a 16px base against Semantic's 14 and 42px buttons against 36. No per-component
|
||||
* nudge reproduces what a user comparing the two sees, which is the whole page.
|
||||
*
|
||||
* Ten percent is not a fudge factor: our heading scale times 1.1 is
|
||||
* 28.6 / 23.1 / 18.7 / 15.4 / 14.3, which is Semantic's scale to within a pixel at
|
||||
* every step.
|
||||
*
|
||||
* The lever is the root font-size, and everything that should grow with it is written
|
||||
* in `rem`. That is Mantine's own mechanism -- its size declarations are
|
||||
* `calc(Xrem * var(--mantine-scale))`, and `theme.scale` exists to CANCEL a customised
|
||||
* root font-size, so it must stay at 1 here.
|
||||
*
|
||||
* A percentage rather than a px value, so a user who has set a larger default font in
|
||||
* their browser keeps it, scaled, instead of having it silently overridden.
|
||||
*
|
||||
* `zoom: 1.1` on the root was tried first and rejected. It is one line and it works,
|
||||
* but it scales at paint time: every 1px hairline becomes 1.1px and softens on a 1x
|
||||
* display, and viewport units do not shrink to compensate, so `100vh` paints 110% of
|
||||
* the screen -- a 95vw modal overflowed sideways and the CBZ viewer's fullscreen
|
||||
* overflowed downwards. Rem scales real lengths, leaves borders crisp and leaves
|
||||
* viewport units alone.
|
||||
*
|
||||
* Borders, outlines and shadows are deliberately NOT in rem. A hairline is a hairline
|
||||
* at any text size; ui-scale.test.js enforces both halves of that.
|
||||
*/
|
||||
:root {
|
||||
--ui-scale: 1.1;
|
||||
}
|
||||
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
font-size: calc(100% * var(--ui-scale));
|
||||
}
|
||||
|
||||
*,
|
||||
|
|
|
|||
169
app/src/themes/ui-scale.test.js
Normal file
169
app/src/themes/ui-scale.test.js
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
/*
|
||||
* The size of the interface.
|
||||
*
|
||||
* Measured against the pre-migration Semantic build on the QA Pi at 1280px, the drift was not
|
||||
* one number: its headings were h1 28 / h2 24 / h3 18 / h4 15 / h5 14 against our 26 / 21 / 17
|
||||
* / 14 / 13, and its video card a fixed 290px with an 18px title against our 238px with a 13px
|
||||
* one -- while our BODY text and chrome went the other way, 16px base against Semantic's 14 and
|
||||
* 42px buttons against 36. So no per-component nudge reproduces what a user comparing the two
|
||||
* actually sees, which is the whole page at once.
|
||||
*
|
||||
* Ten percent is not a fudge factor. Our heading scale multiplied by 1.1 is 28.6 / 23.1 / 18.7
|
||||
* / 15.4 / 14.3 -- Semantic's numbers, to within a pixel at every step.
|
||||
*
|
||||
* The lever is the root font-size, and everything that should grow with it is written in `rem`.
|
||||
* That is Mantine's own mechanism: its 644 size declarations are `calc(Xrem * var(--mantine-
|
||||
* scale))`, and `theme.scale` exists specifically to CANCEL a customised root font-size, which
|
||||
* is why it must stay at 1 here -- we want those sizes to grow.
|
||||
*
|
||||
* `zoom: 1.1` on the root was tried first and rejected. It works, and it is one line, but it
|
||||
* scales at paint time: every 1px hairline becomes 1.1px and softens on a 1x display, and
|
||||
* viewport units do not shrink to compensate, so `100vh` paints 110% of the screen -- a 95vw
|
||||
* modal overflowed sideways and the CBZ viewer's fullscreen overflowed down. Rem scales real
|
||||
* lengths instead, leaves borders crisp, leaves viewport units alone, and respects a user's own
|
||||
* browser font-size setting rather than overriding it.
|
||||
*/
|
||||
|
||||
const SRC = path.join(__dirname, '..');
|
||||
const tokens = fs.readFileSync(path.join(__dirname, 'tokens.css'), 'utf8');
|
||||
|
||||
/** Our own stylesheets -- the ones the scale has to reach. */
|
||||
const STYLESHEETS = ['themes/tokens.css', 'App.css', 'index.css', 'components/ui/ui.css']
|
||||
.map(file => [file, path.join(SRC, file)])
|
||||
.filter(([, full]) => fs.existsSync(full));
|
||||
|
||||
/** `source` with every comment blanked, keeping line numbers intact. */
|
||||
const stripComments = (source) => source
|
||||
.replace(/\/\*[\s\S]*?\*\//g, block => block.replace(/[^\n]/g, ' '))
|
||||
.replace(/(^|[^:])\/\/[^\n]*/g, (all, before) => before + ' '.repeat(all.length - before.length));
|
||||
|
||||
/** Every source file under src/, excluding tests. */
|
||||
const sourceFiles = (dir = SRC) => fs.readdirSync(dir, {withFileTypes: true}).flatMap(entry => {
|
||||
const full = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) return entry.name === 'node_modules' ? [] : sourceFiles(full);
|
||||
if (!/\.(js|jsx|ts|tsx|css)$/.test(entry.name)) return [];
|
||||
if (/\.(test|cy)\.(js|jsx|ts|tsx)$/.test(entry.name)) return [];
|
||||
return [full];
|
||||
});
|
||||
|
||||
describe('--ui-scale', () => {
|
||||
it('scales the interface from the root font-size', () => {
|
||||
// A percentage of the browser's own default, not a px value: a user who has set a
|
||||
// larger default font keeps it, scaled, instead of having it overridden.
|
||||
expect(tokens).toMatch(/--ui-scale:\s*1\.1;/);
|
||||
expect(tokens).toMatch(/\n\s*font-size:\s*calc\(100%\s*\*\s*var\(--ui-scale\)\)/);
|
||||
});
|
||||
|
||||
it('leaves Mantine free to grow with it', () => {
|
||||
/*
|
||||
* `theme.scale` divides Mantine's rem lengths by itself, to undo a customised root
|
||||
* font-size. Setting it to 1.1 alongside a 110% root would therefore cancel out
|
||||
* exactly, leaving Mantine's half of the interface at its original size while ours
|
||||
* grew -- buttons the old size beside 10% larger text.
|
||||
*/
|
||||
const mantine = fs.readFileSync(path.join(__dirname, 'mantine.ts'), 'utf8');
|
||||
expect(stripComments(mantine)).not.toMatch(/\bscale:\s*[\d.]/);
|
||||
});
|
||||
|
||||
it('writes every scalable length in rem, so the scale reaches it', () => {
|
||||
/*
|
||||
* A px font-size does not grow with the root, so it would shrink RELATIVE to
|
||||
* everything around it -- the failure is a 13px caption beside 14.3px prose, which
|
||||
* reads as sloppy rather than broken and so never gets reported.
|
||||
*
|
||||
* Borders are exempt and must stay px: a hairline is a hairline at any text size, and
|
||||
* scaling it is exactly what made `zoom` the wrong tool. Same for outlines, which are
|
||||
* hairlines wearing a different name.
|
||||
*/
|
||||
const SCALABLE = /^\s*(font-size|padding|padding-\w+|margin|margin-\w+|gap|row-gap|column-gap|width|min-width|max-width|height|min-height|max-height|border-radius|top|right|bottom|left)\s*:/;
|
||||
|
||||
const offenders = [];
|
||||
let scanned = 0;
|
||||
for (const [name, full] of STYLESHEETS) {
|
||||
stripComments(fs.readFileSync(full, 'utf8')).split('\n').forEach((line, index) => {
|
||||
if (!SCALABLE.test(line)) return;
|
||||
scanned += 1;
|
||||
// 0 has no unit to scale, and 1px in a scalable property is a hairline too.
|
||||
const px = [...line.matchAll(/(?<![\w.-])(\d+(?:\.\d+)?)px/g)]
|
||||
.filter(match => parseFloat(match[1]) > 1);
|
||||
if (px.length) offenders.push(`${name}:${index + 1}: ${line.trim().slice(0, 64)}`);
|
||||
});
|
||||
}
|
||||
|
||||
// The premise: a regex that matched no declarations would report no offenders.
|
||||
expect(scanned).toBeGreaterThan(100);
|
||||
expect(offenders).toEqual([]);
|
||||
});
|
||||
|
||||
it('keeps hairlines out of the scale', () => {
|
||||
/*
|
||||
* The inverse of the rule above, and the reason it is worth a test of its own: a bulk
|
||||
* px-to-rem pass that also converted the borders would leave every rule in the app
|
||||
* growing with the type, which is the defect `zoom` had. At least most borders must
|
||||
* still be px.
|
||||
*/
|
||||
/*
|
||||
* Only the properties that carry a border's THICKNESS. `border-radius` is a
|
||||
* scalable length -- a 10% larger control wants a proportionally larger corner --
|
||||
* and an earlier version of this matched it, so it failed on the correct answer.
|
||||
*/
|
||||
const THICKNESS = /^\s*(border|border-(top|right|bottom|left|inline|block)(-\w+)?|border-width|outline|outline-offset)\s*:/;
|
||||
|
||||
const borders = [];
|
||||
for (const [, full] of STYLESHEETS) {
|
||||
stripComments(fs.readFileSync(full, 'utf8')).split('\n').forEach(line => {
|
||||
if (THICKNESS.test(line) && !/radius/.test(line)) borders.push(line);
|
||||
});
|
||||
}
|
||||
const pxBorders = borders.filter(line => /\dpx/.test(line));
|
||||
const remBorders = borders.filter(line => /\drem/.test(line));
|
||||
|
||||
expect(borders.length).toBeGreaterThan(30);
|
||||
expect({rem: remBorders, someArePx: pxBorders.length > 20})
|
||||
.toEqual({rem: [], someArePx: true});
|
||||
});
|
||||
|
||||
it('writes no px font-size inline, anywhere', () => {
|
||||
/*
|
||||
* An inline size is part of the scale whether or not it looks like one: a bare number
|
||||
* in `fontSize` is px by React's own rule, so `fontSize: 12` is a 12px caption that
|
||||
* stays 12px while the prose beside it grows to 13.2. Nothing breaks -- it just reads
|
||||
* as slightly sloppy, in 46 places, which is not a bug anyone reports.
|
||||
*
|
||||
* The whole of src is scanned, the gallery included. /theme-sample is linked from
|
||||
* Settings and ships to users, so its annotations are interface text too.
|
||||
*/
|
||||
const offenders = [];
|
||||
for (const file of sourceFiles()) {
|
||||
if (file.endsWith('.css')) continue;
|
||||
stripComments(fs.readFileSync(file, 'utf8')).split('\n').forEach((line, index) => {
|
||||
/*
|
||||
* A bare number (px by React's rule) or an explicit px. Relative units are
|
||||
* fine and are not offences: `em` resolves against the parent's font-size and
|
||||
* `%` likewise, so both already grow with the scale. An earlier version
|
||||
* allowed only `rem` and reported 21 perfectly good `0.85em` captions.
|
||||
*/
|
||||
if (/fontSize:\s*(\d|['"][\d.]+px)/.test(line)) {
|
||||
offenders.push(`${path.relative(SRC, file)}:${index + 1}: ${line.trim().slice(0, 60)}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* The premise: `fontSize` in rem has to be found, or a codebase with no inline sizes
|
||||
* at all would read identically to one that had converted them.
|
||||
*
|
||||
* Occurrences rather than files. Counting files gave 8 for the 46 conversions -- 32
|
||||
* of them are in the gallery -- so a threshold set from the conversion count failed
|
||||
* against the correct answer.
|
||||
*/
|
||||
const remSizes = sourceFiles().flatMap(file =>
|
||||
[...fs.readFileSync(file, 'utf8').matchAll(/fontSize:\s*['"][\d.]+rem/g)]);
|
||||
expect(remSizes.length).toBeGreaterThan(40);
|
||||
|
||||
expect(offenders).toEqual([]);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue