import React from 'react'; import {Card as MCard, Tabs as MTabs, Accordion as MAccordion, Breadcrumbs} from '@mantine/core'; import {Icon} from './Icon'; import {pxToRem} from './scale'; /* * Surfaces and structure: headers, panels, cards, statistics, tabs, accordions, * breadcrumbs. Elevation is expressed with borders and background steps — * never a shadow (shadows are zeroed in the Mantine bridge). */ // ------------------------------------------------------------------- Headers export type HeaderLevel = 'h1' | 'h2' | 'h3' | 'h4' | 'h5'; export interface HeaderProps extends Omit, 'color'> { /** Heading level. Also the visual size — pick it for the outline, not the look. */ as?: HeaderLevel; /** An icon name (see Icon.tsx) or a Tabler component, shown before the text. */ icon?: string | React.ComponentType; /** Secondary line below, in muted text. */ subheader?: React.ReactNode; /** Hairline rule underneath, separating the section from what follows. */ dividing?: boolean; /** * A token color name (`green`, `red`, ...) for a heading that carries meaning — * "3 items to add" against "2 items to remove". Call sites kept reaching for an * inline style to do this, which is how a hex ends up in the markup. */ color?: string; /** * Trailing content on the heading's row — a help button, a count, a small control. * * It is a SIBLING of the heading element inside a flex row, not a child of it: a * control inside an `

` becomes part of the heading's accessible name, so screen * reader heading navigation announces "Root CA Certificate Help". The row is what * keeps the two on one line; a sibling placed after the block wrapper wraps instead, * which is what happened to every help icon in the app when these headings stopped * being a bare `

`. */ after?: React.ReactNode; } /** * A section heading: `as` picks the level, with optional `icon`, `subheader` and a * `dividing` rule underneath. * * Sizes come from ui.css, keyed on the level, rather than each call site * choosing — that is what keeps the type scale a scale. */ export function Header({ as = 'h3', icon, subheader, dividing, color, after, className, style, children, ...props }: HeaderProps) { const Tag = as; const heading = {icon && (typeof icon === 'string' ? : )} {children} ; /* * `style` lands on the WRAPPER, because every layout use of it is about the header as a * block -- `marginBottom` on Status's "Drive Bandwidth", `marginTop` on the extension * page's steps. On the inner heading those set a margin inside the wrapper and depended * on margin collapse to have any effect at all, which stops the moment the wrapper gains * padding or a border. Text properties passed this way still reach the heading: `color` * and `text-align` inherit. A `color` PROP stays on the heading, since that is about the * text rather than the box. */ return
{/* The row exists only when there is something to sit beside; without it the markup for the other 46 call sites is unchanged. */} {after ?
{heading} {after}
: heading} {subheader &&
{subheader}
}
} // -------------------------------------------------------------------- Panels export interface PanelProps extends React.HTMLAttributes { /** A danger zone: dashed red border, for destructive groupings. */ danger?: boolean; } /** A bordered surface: the panel most of the app's content sits on. */ export function Panel({danger, className, children, ...props}: PanelProps) { return
{children}
} // ---------------------------------------------------------------- Statistics export interface StatisticProps extends Omit, 'color'> { /** The number. Rendered as given, so `0` shows as a zero rather than nothing. */ value: React.ReactNode; label: React.ReactNode; /** A token color name, for a reading that carries meaning: load, temperature, IO wait. */ color?: string; } /** * One figure and its label. The rest of the props reach the outer element, because * `LoadStatistic` and the four Status wrappers all end in `{...props}` and used to have * everything past the named five silently dropped. */ export function Statistic({value, label, color, className, ...props}: StatisticProps) { return
{value}
{label}
} /** * A row of statistics separated by hairlines, sharing one outer border. The cells carry * no inline style of their own so that `.wrolpi-statistic-cell:empty` can hide the ones * whose statistic rendered nothing — Status omits the fan reading on the devices, most of * them, with no fan connector. */ export function StatisticGroup({children, className, ...props}: React.HTMLAttributes) { return
{React.Children.toArray(children).map((child, index) =>
{child}
)}
} // --------------------------------------------------------------------- Cards export interface CardProps { /** Image or poster area above the body. */ media?: React.ReactNode; title?: React.ReactNode; /** * The card's secondary line -- author, channel, domain, date. It sits directly under * the title rather than at the foot of the card: a grid stretches every card to the * tallest in its row, so a foot-anchored meta line strands the date a long way from * the title it belongs to. */ meta?: React.ReactNode; children?: React.ReactNode; /** * Controls, rendered last and pushed to the card's foot so that a row of cards lines * its buttons up regardless of how many lines each title took. */ actions?: React.ReactNode; onClick?: React.MouseEventHandler; /** * A token color name, drawn as an accent along the card's top edge. File cards use * it to carry the mimetype's color, so a grid of results is scannable by kind before * any text is read. It remaps per theme, so night gets a red accent rather than a * dozen hues. */ color?: string; className?: string; } export function Card({media, title, meta, children, actions, onClick, color, className}: CardProps) { return {media &&
{media}
} {/* Sizes live in ui.css, in rem: inline px would sit outside the interface scale. */}
{title &&
{title}
} {meta &&
{meta}
} {children} {actions &&
{actions}
}
} export interface CardGroupProps extends React.HTMLAttributes { /** * The narrowest a card may be laid out, in px at the unscaled design size. `auto-fill` * rather than `auto-fit`, so a group of two cards in a wide column keeps them card-sized * instead of stretching each to half the page. * * The default was 200 and is 250: a card wall read too dense, running five to a row at * 1280px where the pre-migration build ran four, which left a video title about two words * wide. Raising the default rather than each page is the point of it being a default -- * videos, archives, docs, files and the gallery all take it. */ minWidth?: number; } export function CardGroup({children, minWidth = 250, className, style, ...props}: CardGroupProps) { return
{children}
} export {MTabs as Tabs, MAccordion as Accordion, Breadcrumbs};