import type { Meta, StoryFn } from '@storybook/react' import React from 'react' import { FaqList } from './index' type ComponentProps = React.ComponentProps const meta: Meta = { title: 'FaqList', component: FaqList, parameters: { layout: 'centered', }, } export default meta const Template: StoryFn = (args) => { return (
) } // Per-variant stories stay in Storybook for browsing/design review but are // individually covered by cells in AllStates — skip in Chromatic. const skipInChromatic = { chromatic: { disableSnapshot: true } } // Deterministic local avatar for the grid so a pravatar network flake can't // diff the whole AllStates snapshot. Individual stories keep their remote // images (they're skipped in Chromatic anyway). const LOCAL_AVATAR = '/image-thumbnail.jpg' export const Default: StoryFn = Template.bind({}) Default.args = { faqs: [ { id: '1', question: 'Book club slots', answer: 'We ship worldwide...', enabled: true, order: 1, }, { id: '2', question: 'Refunds', answer: 'You can track...', enabled: true, order: 2, }, { id: '3', question: 'Brand collabs', answer: 'Returns are accepted...', enabled: true, order: 3, }, ], onFaqClick: (id) => console.log('FAQ clicked:', id), headerText: 'Tap to send a suggested question by Brie Parson:', avatarName: 'Brie Parson', avatarImage: 'https://i.pravatar.cc/150?img=47', } Default.parameters = skipInChromatic export const WithoutHeader: StoryFn = Template.bind({}) WithoutHeader.args = { faqs: [ { id: '1', question: 'Book club slots', answer: 'We ship worldwide...', enabled: true, order: 1, }, { id: '2', question: 'Refunds', answer: 'You can track...', enabled: true, order: 2, }, ], onFaqClick: (id) => console.log('FAQ clicked:', id), } WithoutHeader.parameters = skipInChromatic export const WithDisabledFaq: StoryFn = Template.bind({}) WithDisabledFaq.args = { faqs: [ { id: '1', question: 'Enabled question', answer: 'Answer...', enabled: true, order: 1, }, { id: '2', question: 'Disabled question', answer: 'Answer...', enabled: false, order: 2, }, { id: '3', question: 'Another enabled', answer: 'Answer...', enabled: true, order: 3, }, ], onFaqClick: (id) => console.log('FAQ clicked:', id), } WithDisabledFaq.parameters = skipInChromatic export const WithLoading: StoryFn = Template.bind({}) WithLoading.args = { faqs: [ { id: '1', question: 'Book club slots', answer: 'We ship worldwide...', enabled: true, order: 1, }, { id: '2', question: 'Refunds', answer: 'You can track...', enabled: true, order: 2, }, { id: '3', question: 'Brand collabs', answer: 'Returns are accepted...', enabled: true, order: 3, }, ], onFaqClick: (id) => console.log('FAQ clicked:', id), loadingFaqId: '2', headerText: 'Tap to send a suggested question:', } WithLoading.parameters = skipInChromatic export const Empty: StoryFn = Template.bind({}) Empty.args = { faqs: [], onFaqClick: (id) => console.log('FAQ clicked:', id), } Empty.parameters = skipInChromatic export const WithAvatarOnly: StoryFn = Template.bind({}) WithAvatarOnly.args = { faqs: [ { id: '1', question: 'Book club slots', answer: 'We ship worldwide...', enabled: true, order: 1, }, { id: '2', question: 'Refunds', answer: 'You can track...', enabled: true, order: 2, }, ], onFaqClick: (id) => console.log('FAQ clicked:', id), headerText: 'Frequently Asked Questions', avatarName: 'Account Owner', } WithAvatarOnly.parameters = skipInChromatic export const WithAvatarAndImage: StoryFn = Template.bind({}) WithAvatarAndImage.args = { faqs: [ { id: '1', question: 'How do I contact support?', answer: 'You can reach us...', enabled: true, order: 1, }, { id: '2', question: 'What are your hours?', answer: 'We are available...', enabled: true, order: 2, }, ], onFaqClick: (id) => console.log('FAQ clicked:', id), headerText: 'Questions for Sarah', avatarName: 'Sarah Johnson', avatarImage: 'https://i.pravatar.cc/150?img=28', } WithAvatarAndImage.parameters = skipInChromatic export const AllStates: StoryFn = () => { const states: { label: string; props: ComponentProps }[] = [ { label: 'Default (header + avatar + image)', props: { faqs: [ { id: '1', question: 'Book club slots', answer: 'We ship worldwide...', enabled: true, order: 1, }, { id: '2', question: 'Refunds', answer: 'You can track...', enabled: true, order: 2, }, { id: '3', question: 'Brand collabs', answer: 'Returns are accepted...', enabled: true, order: 3, }, ], onFaqClick: (id) => console.log('FAQ clicked:', id), headerText: 'Tap to send a suggested question by Brie Parson:', avatarName: 'Brie Parson', avatarImage: LOCAL_AVATAR, }, }, { label: 'Without header', props: { faqs: [ { id: '1', question: 'Book club slots', answer: 'We ship worldwide...', enabled: true, order: 1, }, { id: '2', question: 'Refunds', answer: 'You can track...', enabled: true, order: 2, }, ], onFaqClick: (id) => console.log('FAQ clicked:', id), }, }, { label: 'With avatar only', props: { faqs: [ { id: '1', question: 'Book club slots', answer: 'We ship worldwide...', enabled: true, order: 1, }, { id: '2', question: 'Refunds', answer: 'You can track...', enabled: true, order: 2, }, ], onFaqClick: (id) => console.log('FAQ clicked:', id), headerText: 'Frequently Asked Questions', avatarName: 'Account Owner', }, }, { label: 'With avatar and image', props: { faqs: [ { id: '1', question: 'How do I contact support?', answer: 'You can reach us...', enabled: true, order: 1, }, { id: '2', question: 'What are your hours?', answer: 'We are available...', enabled: true, order: 2, }, ], onFaqClick: (id) => console.log('FAQ clicked:', id), headerText: 'Questions for Sarah', avatarName: 'Sarah Johnson', avatarImage: LOCAL_AVATAR, }, }, { label: 'With disabled FAQ', props: { faqs: [ { id: '1', question: 'Enabled question', answer: 'Answer...', enabled: true, order: 1, }, { id: '2', question: 'Disabled question', answer: 'Answer...', enabled: false, order: 2, }, { id: '3', question: 'Another enabled', answer: 'Answer...', enabled: true, order: 3, }, ], onFaqClick: (id) => console.log('FAQ clicked:', id), }, }, { label: 'With loading', props: { faqs: [ { id: '1', question: 'Book club slots', answer: 'We ship worldwide...', enabled: true, order: 1, }, { id: '2', question: 'Refunds', answer: 'You can track...', enabled: true, order: 2, }, { id: '3', question: 'Brand collabs', answer: 'Returns are accepted...', enabled: true, order: 3, }, ], onFaqClick: (id) => console.log('FAQ clicked:', id), loadingFaqId: '2', headerText: 'Tap to send a suggested question:', }, }, { label: 'Empty (renders nothing)', props: { faqs: [], onFaqClick: (id) => console.log('FAQ clicked:', id), }, }, ] return (
{states.map(({ label, props }) => (
{label}
))}
) }