import type { Meta, StoryObj } from '@storybook/react-vite';
import argTypes from '../../../.storybook/sgdsArgTypes';
import Filters from './SearchFilters';
import DatePicker from '../DatePicker';
import Checkbox from '../Checkbox';
const meta = {
title: 'Components/Search results/Filters/Filter panel',
component: Filters.Panel,
decorators: [(Story) => (
)],
argTypes: {
children: argTypes.children(),
isScrollable: {
description: 'Puts internal scrollbars around the filter fields',
control: 'boolean',
},
legend: {
description: 'Content for the (visually hidden) legend element',
type: {
name: 'string',
required: true
}
},
heading: {
description: 'Heading of the filter panel item',
type: {
name: 'string',
required: true
}
},
activeFilterCount: {
description: 'Number of active filter fields in this panel',
type: {
name: 'number'
}
}
},
args: {
heading: 'Filter',
legend: 'Select which publication types you would like to see'
}
} satisfies Meta;
export default meta;
type Story = StoryObj;
type ContentTypeType = {
label: string;
value: string;
checked?: boolean;
};
const CONTENT_TYPES = [
{
label: 'Advice and guidance',
value: 'advice-and-guidance'
},
{
label: 'Agreement',
value: 'agreement'
},
{
label: 'Consultation analysis',
value: 'consultation-analysis'
},
{
label: 'Consultation paper',
value: 'consultation-paper'
},
{
label: 'Corporate report',
value: 'corporate-report'
},
{
label: 'Correspondence',
value: 'correspondence'
},
{
label: 'FOI/EIR release',
value: 'foi-eir-release'
},
{
label: 'Factsheet',
value: 'factsheet'
},
{
label: 'Form',
value: 'form'
},
{
label: 'Impact assessment',
value: 'impact-assessment'
},
{
label: 'Independent report',
value: 'independent-report'
},
{
label: 'Map',
value: 'map'
},
{
label: 'Minutes',
value: 'minutes'
},
{
label: 'Progress report',
value: 'progress-report'
},
{
label: 'Regulation/directive/order',
value: 'regulation-directive-order'
},
{
label: 'Research and analysis',
value: 'research-and-analysis'
},
{
label: 'Speech/statement',
value: 'speech-statement'
},
{
label: 'Statistics',
value: 'statistics'
},
{
label: 'Strategy/plan',
value: 'strategy-plan'
},
{
label: 'Transparency data',
value: 'transparency-data'
}
];
const CONTENT_TYPES_WITH_SELECTED = JSON.parse(JSON.stringify(CONTENT_TYPES));
CONTENT_TYPES_WITH_SELECTED[1].checked = true;
CONTENT_TYPES_WITH_SELECTED[4].checked = true;
CONTENT_TYPES_WITH_SELECTED[7].checked = true;
export const Default: Story = {
render: () => (
)
};
export const Scrollable: Story = {
render: ({ ...args }) => (
{CONTENT_TYPES.map((type) => (
))}
)
};
export const WithActiveFilterCount: Story = {
args: {},
render: ({ ...args }) => (
item.checked).length}
heading="Content type"
isScrollable
legend="Select which publication types you would like to see"
>
{CONTENT_TYPES_WITH_SELECTED.map((type: ContentTypeType) => (
))}
)
};