diff --git a/src/lib/SectionMessage/SectionMessage.stories.module.css b/src/lib/SectionMessage/SectionMessage.stories.module.css new file mode 100644 index 0000000..ee4c58d --- /dev/null +++ b/src/lib/SectionMessage/SectionMessage.stories.module.css @@ -0,0 +1,10 @@ +.container { + display: flex; + flex-direction: column; + gap: 1rem; + padding: 1rem; + } + + .message { + margin-bottom: 0; + } \ No newline at end of file diff --git a/src/lib/SectionMessage/SectionMessage.stories.tsx b/src/lib/SectionMessage/SectionMessage.stories.tsx new file mode 100644 index 0000000..ebb0a27 --- /dev/null +++ b/src/lib/SectionMessage/SectionMessage.stories.tsx @@ -0,0 +1,113 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import SectionMessage from './SectionMessage'; +import { TYPE_MAP, TYPES } from '../Message/Message'; +import styles from './SectionMessage.stories.module.css'; + +// Filter out the deprecated 'warn' type +const VALID_TYPES = TYPES.filter(type => type !== 'warn'); + +const meta: Meta = { + component: SectionMessage, + argTypes: { + type: { + options: VALID_TYPES, + control: { type: 'select' }, + description: 'Message type or severity', + }, + canDismiss: { + control: 'boolean', + description: 'Whether message can be dismissed', + }, + isVisible: { + control: 'boolean', + description: 'Controls message visibility', + }, + ariaLabel: { + control: 'text', + description: 'Accessibility label for the message', + }, + dataTestid: { + control: 'text', + description: 'Test identifier', + }, + }, + parameters: { + docs: { + description: { + component: 'Show a section/page-specific event-based message to the user', + }, + }, + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Types: Story = { + render: (args) => { + return ( +
+ {VALID_TYPES.map((type) => ( + + This is a {type} message with icon "{TYPE_MAP[type].iconName}" + + ))} +
+ ); + }, + args: { + className: styles['message'], + canDismiss: true, + isVisible: true, + }, +}; + +export const WithCustomDismiss: Story = { + render: (args) => ( + { + console.log('Message dismissed!'); + }} + ariaLabel="Warning message with custom dismiss" + > + This message has a custom dismiss handler (check console) + + ), +}; + +export const NonDismissible: Story = { + render: (args) => ( + + This message cannot be dismissed as canDismiss is false + + ), +}; + +export const WithLongContent: Story = { + render: (args) => ( + + This is a message with longer content to demonstrate how the message component + handles multiple lines of text. The close button should remain properly aligned + and the icon should stay at the top of the content. + + ), +}; \ No newline at end of file