summaryrefslogtreecommitdiffstats
path: root/src/components/molecules/forms/radio-group.stories.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-05-30 19:44:37 +0200
committerArmand Philippot <git@armandphilippot.com>2022-05-31 23:15:11 +0200
commit994ad1bec193b2d1a6e0d38d6ef3f3d2bd66c3ea (patch)
tree53df625928d50ef11ceca6b4d0937d433b576aec /src/components/molecules/forms/radio-group.stories.tsx
parentae384aec5084b9fb9f02166890686a37d1260ef2 (diff)
chore: add a RadioGroup component
Diffstat (limited to 'src/components/molecules/forms/radio-group.stories.tsx')
-rw-r--r--src/components/molecules/forms/radio-group.stories.tsx166
1 files changed, 166 insertions, 0 deletions
diff --git a/src/components/molecules/forms/radio-group.stories.tsx b/src/components/molecules/forms/radio-group.stories.tsx
new file mode 100644
index 0000000..b4c913a
--- /dev/null
+++ b/src/components/molecules/forms/radio-group.stories.tsx
@@ -0,0 +1,166 @@
+import { ComponentMeta, ComponentStory } from '@storybook/react';
+import RadioGroup from './radio-group';
+import { getOptions, initialChoice, legend } from './radio-group.fixture';
+
+/**
+ * RadioGroup - Storybook Meta
+ */
+export default {
+ title: 'Molecules/Forms/RadioGroup',
+ component: RadioGroup,
+ args: {
+ labelSize: 'small',
+ },
+ argTypes: {
+ className: {
+ control: {
+ type: 'text',
+ },
+ description: 'Set additional classnames to the fieldset.',
+ table: {
+ category: 'Styles',
+ },
+ type: {
+ name: 'string',
+ required: false,
+ },
+ },
+ initialChoice: {
+ control: {
+ type: 'text',
+ },
+ description: 'The default selected option id.',
+ type: {
+ name: 'string',
+ required: true,
+ },
+ },
+ labelPosition: {
+ control: {
+ type: 'select',
+ },
+ description: 'Determine the label position.',
+ options: ['left', 'right'],
+ table: {
+ category: 'Options',
+ defaultValue: { summary: 'left' },
+ },
+ type: {
+ name: 'string',
+ required: false,
+ },
+ },
+ labelSize: {
+ control: {
+ type: 'select',
+ },
+ description: 'The label size.',
+ options: ['medium', 'small'],
+ table: {
+ category: 'Options',
+ },
+ type: {
+ name: 'string',
+ required: false,
+ },
+ },
+ legend: {
+ control: {
+ type: 'text',
+ },
+ description: 'The fieldset legend.',
+ type: {
+ name: 'string',
+ required: true,
+ },
+ },
+ legendClassName: {
+ control: {
+ type: 'text',
+ },
+ description: 'Set additional classnames to the legend.',
+ table: {
+ category: 'Styles',
+ },
+ type: {
+ name: 'string',
+ required: false,
+ },
+ },
+ legendPosition: {
+ control: {
+ type: 'select',
+ },
+ description: 'Determine the legend position.',
+ options: ['inline', 'stacked'],
+ table: {
+ category: 'Options',
+ defaultValue: { summary: 'inline' },
+ },
+ type: {
+ name: 'string',
+ required: false,
+ },
+ },
+ options: {
+ description: 'An array of radio option object.',
+ type: {
+ name: 'object',
+ required: true,
+ value: {},
+ },
+ },
+ },
+} as ComponentMeta<typeof RadioGroup>;
+
+const Template: ComponentStory<typeof RadioGroup> = (args) => (
+ <RadioGroup {...args} />
+);
+
+/**
+ * Radio Group Stories - Inlined legend & left label
+ */
+export const InlinedLegendLeftLabel = Template.bind({});
+InlinedLegendLeftLabel.args = {
+ initialChoice: initialChoice,
+ labelPosition: 'left',
+ legend: legend,
+ legendPosition: 'inline',
+ options: getOptions('group1'),
+};
+
+/**
+ * Radio Group Stories - Inlined legend & left label
+ */
+export const InlinedLegendRightLabel = Template.bind({});
+InlinedLegendRightLabel.args = {
+ initialChoice: initialChoice,
+ labelPosition: 'right',
+ legend: legend,
+ legendPosition: 'inline',
+ options: getOptions('group2'),
+};
+
+/**
+ * Radio Group Stories - Stacked legend & left label
+ */
+export const StackedLegendLeftLabel = Template.bind({});
+StackedLegendLeftLabel.args = {
+ initialChoice: initialChoice,
+ labelPosition: 'left',
+ legend: legend,
+ legendPosition: 'stacked',
+ options: getOptions('group3'),
+};
+
+/**
+ * Radio Group Stories - Stacked legend & left label
+ */
+export const StackedLegendRightLabel = Template.bind({});
+StackedLegendRightLabel.args = {
+ initialChoice: initialChoice,
+ labelPosition: 'right',
+ legend: legend,
+ legendPosition: 'stacked',
+ options: getOptions('group4'),
+};