import React, { useState } from 'react'; import type { Meta, StoryObj } from '@storybook/react-vite'; import { Button } from '../Button/Button'; import { ColorField } from '../Fields/ColorField/ColorField'; import { CounterField } from '../Fields/CounterField/CounterField'; import { SingleSelectField } from '../Fields/SingleSelectField/SingleSelectField'; import { SwitchField } from '../Fields/SwitchField/SwitchField'; import { Popover } from '../Popover/Popover'; import { Strong } from '../Typography/Strong/Strong'; import { NestedNavigation } from './NestedNavigation'; const meta: Meta = { title: 'UI kit/NestedNavigation', component: NestedNavigation, subcomponents: { 'NestedNavigation.Content': NestedNavigation.Content, 'NestedNavigation.Item': NestedNavigation.Item, 'NestedNavigation.List': NestedNavigation.List, }, tags: ['autodocs'], }; export default meta; type Story = StoryObj; const STYLE_SECTIONS = [ { key: 'colors', title: 'Barvy', Group: ColorsGroup }, { key: 'fonts', title: 'Fonty a písma', Group: FontsGroup }, { key: 'buttons', title: 'Tlačítka', Group: ButtonsGroup }, { key: 'forms', title: 'Formuláře', Group: FormsGroup }, { key: 'corners', title: 'Zaoblení rohů', Group: CornersGroup }, { key: 'spacing', title: 'Mezery a rozestupy', Group: SpacingGroup }, { key: 'animations', title: 'Animace stránek', Group: AnimationsGroup }, ] as const; const FONTS_ADVANCED_TITLE = 'Pokročilé nastavení'; interface FontOption { id: string; label: string; } const FONT_OPTIONS: FontOption[] = [ { id: 'inter', label: 'Inter' }, { id: 'roboto', label: 'Roboto' }, ]; const WEIGHT_OPTIONS: FontOption[] = [ { id: 'regular', label: 'Pravidelné' }, { id: 'medium', label: 'Střední' }, { id: 'semibold', label: 'Polotučné' }, ]; const SIZE_OPTIONS: FontOption[] = [ { id: 'sm', label: 'Malá' }, { id: 'md', label: 'Střední' }, { id: 'lg', label: 'Velká' }, ]; function FontSettingsGroup({ title, ...rest }: { title: string }) { const [font, setFont] = useState('inter'); const [weight, setWeight] = useState('medium'); const [size, setSize] = useState('md'); return ( <> {title} option.id} getOptionLabel={option => option.label} value={font} onChange={setFont} justify /> option.id} getOptionLabel={option => option.label} value={weight} onChange={setWeight} justify /> option.id} getOptionLabel={option => option.label} value={size} onChange={setSize} justify /> ); } function ColorsGroup() { const [headingColor, setHeadingColor] = useState('18181B'); const [textColor, setTextColor] = useState('3F3F46'); const [buttonColor, setButtonColor] = useState('6D28D9'); return ( <> ); } interface ButtonStyleOption { id: string; label: string; } const BUTTON_STYLE_OPTIONS: ButtonStyleOption[] = [ { id: 'solid', label: 'Plné' }, { id: 'outline', label: 'Obrysové' }, { id: 'text', label: 'Textové' }, ]; function ButtonsGroup() { const [style, setStyle] = useState('solid'); const [radius, setRadius] = useState(8); const [growOnHover, setGrowOnHover] = useState(false); return ( <> option.id} getOptionLabel={option => option.label} value={style} onChange={setStyle} justify /> setRadius(value ?? 0)} min={0} max={24} justify /> ); } interface FieldStyleOption { id: string; label: string; } const FIELD_STYLE_OPTIONS: FieldStyleOption[] = [ { id: 'outlined', label: 'Ohraničené' }, { id: 'underlined', label: 'Podtržené' }, ]; function FormsGroup() { const [style, setStyle] = useState('outlined'); const [labelsAbove, setLabelsAbove] = useState(true); return ( <> option.id} getOptionLabel={option => option.label} value={style} onChange={setStyle} justify /> ); } function CornersGroup() { const [radius, setRadius] = useState(8); return ( setRadius(value ?? 0)} min={0} max={32} justify /> ); } function SpacingGroup() { const [spacing, setSpacing] = useState(16); return ( setSpacing(value ?? 0)} min={4} max={32} step={4} justify /> ); } interface AnimationSpeedOption { id: string; label: string; } const ANIMATION_SPEED_OPTIONS: AnimationSpeedOption[] = [ { id: 'slow', label: 'Pomalá' }, { id: 'medium', label: 'Střední' }, { id: 'fast', label: 'Rychlá' }, ]; function AnimationsGroup() { const [enabled, setEnabled] = useState(true); const [speed, setSpeed] = useState('medium'); return ( <> option.id} getOptionLabel={option => option.label} value={speed} onChange={setSpeed} justify /> ); } function FontsAdvancedGroup() { const [letterSpacing, setLetterSpacing] = useState(0); const [lineHeight, setLineHeight] = useState(72); return ( <> setLetterSpacing(value ?? 0)} min={-2} max={10} justify /> setLineHeight(value ?? 0)} min={16} max={120} step={4} justify /> ); } function FontsGroup(props: React.ComponentProps<'div'>) { return ( <> ); } function getStyleEditorLevels() { return ( <> {STYLE_SECTIONS.map(section => ( ))} {STYLE_SECTIONS.map(({ key, title, Group }) => ( {key === 'fonts' && ( )} ))} ); } function StyleEditorDemo() { return ( {({ props }) => } {({ state }) => ( {getStyleEditorLevels()} )} ); } export const Default: Story = { name: 'Uncontrolled (default)', render: () => , }; function ControlledStackDemo() { const [stack, setStack] = useState(['root']); return ( {({ props }) => } {({ state }) => ( {getStyleEditorLevels()} )} ); } export const ControlledStack: Story = { name: 'Controlled (remembers position across close/reopen)', render: () => , }; function StandaloneDemo() { const [isVisible, setIsVisible] = useState(true); if (!isVisible) { return ; } return ( setIsVisible(false)}> {getStyleEditorLevels()} ); } export const Standalone: Story = { name: 'Used outside a Popover', render: () => , decorators: [ Story => (
), ], }; function WrappedRootLevel() { return ( ); } function WrappedColorsLevel() { return (
); } function WrappedLevelsDemo() { return ( {}}> ); } export const WrappedLevels: Story = { name: 'Levels wrapped in user components', render: () => , decorators: [ Story => (
), ], }; const DISABLED_ITEM_SECTIONS = [ { key: 'available', title: 'Dostupná sekce', disabled: false }, { key: 'locked', title: 'Uzamčená sekce', disabled: true }, ] as const; function DisabledItemDemo() { return ( {}}> {DISABLED_ITEM_SECTIONS.map(section => ( ))} {DISABLED_ITEM_SECTIONS.map(section => ( Obsah sekce „{section.title}“. ))} ); } export const DisabledItem: Story = { name: 'With a disabled item', render: () => , decorators: [ Story => (
), ], }; function PerLevelHeadersDemo() { return ( {({ props }) => } {({ state }) => ( {/* A per-level customized header: standard controls plus extra content below. */}
Vlastní obsah hlavičky jen pro tuto úroveň
)}
); } export const PerLevelHeaders: Story = { name: 'Header composed per level', render: () => , };