diff --git a/packages/components/src/components/navigation-item/navigation-item.stories.ts b/packages/components/src/components/navigation-item/navigation-item.stories.ts new file mode 100644 index 000000000..3acdf36d4 --- /dev/null +++ b/packages/components/src/components/navigation-item/navigation-item.stories.ts @@ -0,0 +1,411 @@ +import '../../solid-components'; +import { html } from 'lit-html'; +import { storybookDefaults, storybookHelpers, storybookTemplate } from '../../../scripts/storybook/helper'; +import { waitUntil } from '@open-wc/testing-helpers'; +import { withActions } from '@storybook/addon-actions/decorator'; +import type { ConstantDefinition } from '../../../scripts/storybook/helper'; +const { overrideArgs } = storybookHelpers('sd-navigation-item'); +const { argTypes, parameters } = storybookDefaults('sd-navigation-item'); +const { generateTemplate } = storybookTemplate('sd-navigation-item'); + +// Reusable Constants +const defaultSlotConstant: ConstantDefinition = { + type: 'slot', + name: 'default', + value: 'Navigation' +}; + +const descriptionSlotConstant: ConstantDefinition = { + type: 'slot', + name: 'description', + value: '

Lorem ipsum dolor sit amet.

' +}; + +const childrenSlotConstant: ConstantDefinition = { + type: 'slot', + name: 'children', + value: + 'Sub Navigation 1Sub Navigation 2Sub Navigation 3' +}; + +// Stories +export default { + title: 'Components/sd-navigation-item', + component: 'sd-navigation-item', + args: overrideArgs([{ type: 'slot', name: 'default', value: 'Navigation' }]), + argTypes, + parameters: { ...parameters }, + decorators: [withActions] as any +}; + +/** + * The `sd-navigation-item` in its default state as a horizontally oriented button. + */ + +export const Default = { + render: (args: any) => { + return generateTemplate({ args }); + } +}; + +/** + * The `sd-navigation-item` using bold text. + */ + +export const Bold = { + render: (args: any) => + generateTemplate({ + args, + axis: { x: { type: 'slot', name: 'default', values: ['Navigation', 'Navigation'] } } + }) +}; + +/** + * There are 3 variants determined by the `href` and `vertical` properties in addition to the `children` slot. Each variant has 3 size options to define text size. + */ + +export const Variants = { + name: 'Variant × Size', + parameters: { + controls: { + exclude: ['href', 'target', 'download', 'size', 'vertical', 'indented', 'relaxed', 'open', 'children'] + } + }, + render: (args: any) => { + return html` + ${generateTemplate({ + axis: { + x: { type: 'attribute', name: 'vertical' }, + y: { type: 'attribute', name: 'size' } + }, + args, + options: { + title: 'Button' + } + })} + ${generateTemplate({ + axis: { + x: { type: 'attribute', name: 'vertical' }, + y: { type: 'attribute', name: 'size' } + }, + args, + options: { title: 'Link (href="https://www.union-investment.de/")' }, + constants: { type: 'attribute', name: 'href', value: 'https://www.union-investment.de/' } + })} + ${generateTemplate({ + axis: { + x: { type: 'attribute', name: 'vertical', values: [true] }, + y: { type: 'attribute', name: 'size', values: ['base'] } + }, + args, + options: { + title: 'Accordion' + }, + constants: [ + childrenSlotConstant, + { type: 'attribute', name: 'vertical', value: true }, + { + type: 'slot', + name: 'default', + value: '
Navigation
' + } + ] + })} + `; + } +}; + +/** + * The navigation element when `disabled` is true. + */ + +export const Disabled = { + parameters: { + controls: { exclude: ['disabled', 'vertical', 'current'] } + }, + render: (args: any) => { + return html` + ${generateTemplate({ + axis: { + y: { type: 'attribute', name: 'current' } + }, + options: { + title: 'Horizontal' + }, + constants: [ + { type: 'attribute', name: 'disabled', value: true }, + { type: 'attribute', name: 'vertical', value: false }, + descriptionSlotConstant + ], + args + })} + ${generateTemplate({ + axis: { + x: { type: 'attribute', name: 'chevron' }, + y: { type: 'attribute', name: 'current' } + }, + options: { + title: 'Vertical' + }, + constants: [ + { type: 'attribute', name: 'disabled', value: true }, + { type: 'attribute', name: 'vertical', value: true }, + descriptionSlotConstant + ], + args + })} + `; + } +}; + +/** + * When `vertical` is false, `sd-navigation-item` will render as a `