okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
c5755ed83
main
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, } :{ 7title :ReactNode ; 8sub ?:ReactNode ; 9actions ?:ReactNode ; 10children :ReactNode ; 11width ?:'normal' | 'tight' | 'wide' | 'full' ; 12bare ?:boolean ; 13plainHeader ?:boolean ; 14titleDetail ?: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). */ 16back ?:{ label :string ; onClick :() => void }; 17}) { 18return (<> 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, } :{ 34title :ReactNode ; 35sub ?:ReactNode ; 36right ?:ReactNode ; 37}) { 38return (< 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}