|
| 1 | +import { Meta, StoryObj, moduleMetadata } from '@storybook/angular'; |
| 2 | +import { DividerComponent } from '../../../lib/components/divider/divider.component'; |
| 3 | +import { DividerWithContentComponent, WithContent as WithContentStory } from './examples/divider-with-content.component'; |
| 4 | +import { DividerWithIconComponent, WithIcon as WithIconStory } from './examples/divider-with-icon.component'; |
| 5 | +import { DividerAlignLeftComponent, AlignLeft as AlignLeftStory } from './examples/divider-align-left.component'; |
| 6 | + |
| 7 | +const meta: Meta<DividerComponent> = { |
| 8 | + title: 'Components/Panel/Divider', |
| 9 | + component: DividerComponent, |
| 10 | + tags: ['autodocs'], |
| 11 | + decorators: [ |
| 12 | + moduleMetadata({ |
| 13 | + imports: [ |
| 14 | + DividerComponent, |
| 15 | + DividerWithContentComponent, |
| 16 | + DividerWithIconComponent, |
| 17 | + DividerAlignLeftComponent, |
| 18 | + ], |
| 19 | + }), |
| 20 | + ], |
| 21 | + parameters: { |
| 22 | + docs: { |
| 23 | + description: { |
| 24 | + component: `Разделитель для визуального разделения контента. Поддерживает горизонтальную и вертикальную ориентацию, различные стили линии и выравнивание. |
| 25 | +
|
| 26 | +\`\`\`typescript |
| 27 | +import { DividerModule } from 'primeng/divider'; |
| 28 | +\`\`\``, |
| 29 | + }, |
| 30 | + }, |
| 31 | + designTokens: { prefix: '--p-divider' }, |
| 32 | + }, |
| 33 | + argTypes: { |
| 34 | + layout: { |
| 35 | + control: 'select', |
| 36 | + options: ['horizontal', 'vertical'], |
| 37 | + description: 'Ориентация разделителя', |
| 38 | + table: { |
| 39 | + category: 'Props', |
| 40 | + defaultValue: { summary: 'horizontal' }, |
| 41 | + type: { summary: "'horizontal' | 'vertical'" }, |
| 42 | + }, |
| 43 | + }, |
| 44 | + type: { |
| 45 | + control: 'select', |
| 46 | + options: ['solid', 'dashed', 'dotted'], |
| 47 | + description: 'Стиль линии разделителя', |
| 48 | + table: { |
| 49 | + category: 'Props', |
| 50 | + defaultValue: { summary: 'solid' }, |
| 51 | + type: { summary: "'solid' | 'dashed' | 'dotted'" }, |
| 52 | + }, |
| 53 | + }, |
| 54 | + align: { |
| 55 | + control: 'select', |
| 56 | + options: ['left', 'center', 'right', 'top', 'bottom'], |
| 57 | + description: 'Выравнивание контента внутри разделителя', |
| 58 | + table: { |
| 59 | + category: 'Props', |
| 60 | + defaultValue: { summary: 'center' }, |
| 61 | + type: { summary: "'left' | 'center' | 'right' | 'top' | 'bottom'" }, |
| 62 | + }, |
| 63 | + }, |
| 64 | + }, |
| 65 | +}; |
| 66 | + |
| 67 | +const commonTemplate = ` |
| 68 | +<divider |
| 69 | + [layout]="layout" |
| 70 | + [type]="type" |
| 71 | + [align]="align" |
| 72 | +></divider> |
| 73 | +`; |
| 74 | + |
| 75 | +export default meta; |
| 76 | +type Story = StoryObj<DividerComponent>; |
| 77 | + |
| 78 | +// ── Default ─────────────────────────────────────────────────────────────────── |
| 79 | + |
| 80 | +export const Default: Story = { |
| 81 | + name: 'Default', |
| 82 | + render: (args) => { |
| 83 | + const parts: string[] = []; |
| 84 | + |
| 85 | + if (args.layout && args.layout !== 'horizontal') parts.push(`layout="${args.layout}"`); |
| 86 | + if (args.type && args.type !== 'solid') parts.push(`type="${args.type}"`); |
| 87 | + if (args.align && args.align !== 'center') parts.push(`align="${args.align}"`); |
| 88 | + |
| 89 | + const template = parts.length |
| 90 | + ? `<divider\n ${parts.join('\n ')}\n></divider>` |
| 91 | + : `<divider></divider>`; |
| 92 | + |
| 93 | + return { props: args, template }; |
| 94 | + }, |
| 95 | + args: { |
| 96 | + layout: 'horizontal', |
| 97 | + type: 'solid', |
| 98 | + align: 'center', |
| 99 | + }, |
| 100 | + parameters: { |
| 101 | + docs: { |
| 102 | + description: { |
| 103 | + story: 'Базовый пример компонента. Используйте Controls для интерактивного изменения пропсов.', |
| 104 | + }, |
| 105 | + }, |
| 106 | + }, |
| 107 | +}; |
| 108 | + |
| 109 | +// ── WithContent ─────────────────────────────────────────────────────────────── |
| 110 | + |
| 111 | +export const WithContent: Story = WithContentStory; |
| 112 | + |
| 113 | +// ── WithIcon ────────────────────────────────────────────────────────────────── |
| 114 | + |
| 115 | +export const WithIcon: Story = WithIconStory; |
| 116 | + |
| 117 | +// ── Vertical ────────────────────────────────────────────────────────────────── |
| 118 | + |
| 119 | +export const Vertical: Story = { |
| 120 | + render: (args) => ({ props: args, template: commonTemplate }), |
| 121 | + args: { |
| 122 | + layout: 'vertical', |
| 123 | + type: 'solid', |
| 124 | + align: 'center', |
| 125 | + }, |
| 126 | + parameters: { |
| 127 | + docs: { |
| 128 | + description: { story: 'Вертикальный разделитель для разделения контента по горизонтали.' }, |
| 129 | + source: { |
| 130 | + code: `<divider layout="vertical"></divider>`, |
| 131 | + }, |
| 132 | + }, |
| 133 | + }, |
| 134 | +}; |
| 135 | + |
| 136 | +// ── Type ────────────────────────────────────────────────────────────────────── |
| 137 | + |
| 138 | +export const TypeDashed: Story = { |
| 139 | + name: 'Dashed', |
| 140 | + render: (args) => ({ props: args, template: commonTemplate }), |
| 141 | + args: { |
| 142 | + layout: 'horizontal', |
| 143 | + type: 'dashed', |
| 144 | + align: 'center', |
| 145 | + }, |
| 146 | + parameters: { |
| 147 | + docs: { |
| 148 | + description: { story: 'Разделитель с пунктирной линией.' }, |
| 149 | + source: { |
| 150 | + code: `<divider type="dashed"></divider>`, |
| 151 | + }, |
| 152 | + }, |
| 153 | + }, |
| 154 | +}; |
| 155 | + |
| 156 | +export const TypeDotted: Story = { |
| 157 | + name: 'Dotted', |
| 158 | + render: (args) => ({ props: args, template: commonTemplate }), |
| 159 | + args: { |
| 160 | + layout: 'horizontal', |
| 161 | + type: 'dotted', |
| 162 | + align: 'center', |
| 163 | + }, |
| 164 | + parameters: { |
| 165 | + docs: { |
| 166 | + description: { story: 'Разделитель с точечной линией.' }, |
| 167 | + source: { |
| 168 | + code: `<divider type="dotted"></divider>`, |
| 169 | + }, |
| 170 | + }, |
| 171 | + }, |
| 172 | +}; |
| 173 | + |
| 174 | +// ── Align ───────────────────────────────────────────────────────────────────── |
| 175 | + |
| 176 | +export const AlignLeft: Story = AlignLeftStory; |
0 commit comments