okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221merge f-split-ui2 baeb4533b (approved UI designs, context fix, workspace default with rename, autotune progress) into f-split-intc5755ed83

main
2.1 KiB45 linesraw
1import { tr } from '../lib/i18n';
2/** Screen chrome: a titled header pinned above a scrolling body. */
3import type { ReactNode } from 'react';
4import { cx } from '../lib/format';
5import { Icon } from './ui';
6export function Screen({ title, sub, actions, children, width = 'normal', bare, plainHeader, titleDetail, back, }: {
7    title: ReactNode;
8    sub?: ReactNode;
9    actions?: ReactNode;
10    children: ReactNode;
11    width?: 'normal' | 'tight' | 'wide' | 'full';
12    bare?: boolean;
13    plainHeader?: boolean;
14    titleDetail?: ReactNode;
15    /** A way back to the list this screen was opened from, shown before the title (as the chat's navbar shows its own title). */
16    back?: { label: string; onClick: () => void };
17}) {
18    return (<>
19      <header className={cx("st-header main__head", plainHeader && "main__head--plain")}>
20        <div className="main__titles">
21          <div className="main__title-line">{tr(back ? <button type="button" className="main__back" onClick={back.onClick}><Icon name="chevron" size={14}/>{tr(back.label)}</button> : null)}<h1 className="main__title">{tr(title)}</h1>{tr(titleDetail ? <span className="main__title-detail">{tr(titleDetail)}</span> : null)}</div>
22          {tr(sub ? <p className="main__sub">{tr(sub)}</p> : null)}
23        </div>
24        {tr(actions ? <div className="main__actions">{tr(actions)}</div> : null)}
25      </header>
26      <div className="main__body">
27        {tr(bare ? (children) : (<div className={cx('wrap', width === 'tight' && 'wrap--tight', width === 'wide' && 'wrap--wide')} style={width === 'full' ? { maxWidth: 'none' } : undefined}>
28            {tr(children)}
29          </div>))}
30      </div>
31    </>);
32}
33export function SectionHead({ title, sub, right, }: {
34    title: ReactNode;
35    sub?: ReactNode;
36    right?: ReactNode;
37}) {
38    return (<div className="section-toolbar" style={{ alignItems: 'flex-end', marginBottom: 12 }}>
39      <div>
40        <h2 className="h3">{tr(title)}</h2>
41        {tr(sub ? <div className="small muted" style={{ marginTop: 2 }}>{tr(sub)}</div> : null)}
42      </div>
43      {tr(right)}
44    </div>);
45}