Files
NODEDC_DESIGN_GUIDELINE/apps/catalog/src/MissionThemeExample.tsx
T

29 lines
2.5 KiB
TypeScript

import {useState} from 'react';
import {Button, Description, FeatureSettingsWindow, GlassSurface, Select, SettingsCard, StatusBadge, Switch, TextAreaField, TextField} from '@nodedc/ui-react';
/** Living acceptance fixture. All materials and control states come from the library. */
export function MissionThemeExample() {
const [open,setOpen]=useState(false);
const [name,setName]=useState('Mission Core');
const [enabled,setEnabled]=useState(true);
const [mode,setMode]=useState('review');
const fields=<div className="catalog-theme-fields">
<TextField label="Название" value={name} onChange={event=>setName(event.target.value)}/>
<TextAreaField label="Описание" defaultValue="Панель, группа и поле сохраняют собственные поверхности."/>
<Select label="Режим" value={mode} options={[{value:'review',label:'Просмотр'},{value:'edit',label:'Редактирование'}]} onChange={setMode}/>
<TextField label="Недоступное поле" value="Только чтение" disabled/>
</div>;
return <SettingsCard title="Фундамент Mission Core" description="Единая тёмная тема: поверхности, поля, действия и окна." actions={<Switch label="Включено" checked={enabled} onChange={setEnabled}/>}>
{fields}
<GlassSurface tone="group" padding="md" materialRim={false}>
<TextField label="Элемент коллекции" defaultValue="Дополнительная ссылка"/>
</GlassSurface>
<StatusBadge tone="success">Сохранено</StatusBadge>
<Button variant="primary" onClick={()=>setOpen(true)}>Открыть настройки</Button>
<Description>Поля лежат прямо в SettingsCard; самостоятельный элемент коллекции использует тот же серый материал через GlassSurface tone="group".</Description>
<FeatureSettingsWindow open={open} onClose={()=>setOpen(false)} title="Настройки темы" identity={{title:'Профиль',subtitle:'Mission Core',avatarLabel:'DC'}} sections={[{id:'appearance',label:'Оформление',group:'Общие'}]} activeSection="appearance" onSectionChange={()=>{}}>
<SettingsCard title="Форма в окне" description="Тот же материал полей в портальном окне.">{fields}</SettingsCard>
</FeatureSettingsWindow>
</SettingsCard>;
}