summaryrefslogtreecommitdiffstats
path: root/src/components/atoms/lists/description-list-item.stories.tsx
blob: c7beb0d4f8351e72d87b6aa798ef9ffff35f2821 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { type ResponsiveImageProps } from '@components/molecules/images/responsive-image';
import { Children, FC, ReactElement } from 'react';
import styles from './gallery.module.scss';

export type GalleryColumn = 2 | 3 | 4;

export type GalleryProps = {
  /**
   * The images using ResponsiveImage component.
   */
  children: ReactElement<ResponsiveImageProps>[];
  /**
   * The columns count.
   */
  columns: GalleryColumn;
};

/**
 * Gallery component
 *
 * Render a gallery of images.
 */
const Gallery: FC<GalleryProps> = ({ children, columns }) => {
  const columnsClass = `wrapper--${columns}-columns`;

  return (
    <ul className={`${styles.wrapper} ${styles[columnsClass]}`}>
      {Children.map(children, (child) => {
        return <li className={styles.item}>{child}</li>;
      })}
    </ul>
  );
};

export default Gallery;
e.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
import { ComponentMeta, ComponentStory } from '@storybook/react';
import DescriptionListItemComponent from './description-list-item';

export default {
  title: 'Atoms/Typography/Lists/DescriptionList/Item',
  component: DescriptionListItemComponent,
  args: {
    layout: 'stacked',
    withSeparator: false,
  },
  argTypes: {
    className: {
      control: {
        type: 'text',
      },
      description: 'Set additional classnames to the list item wrapper.',
      table: {
        category: 'Styles',
      },
      type: {
        name: 'string',
        required: false,
      },
    },
    descriptionClassName: {
      control: {
        type: 'text',
      },
      description: 'Set additional classnames to the list item description.',
      table: {
        category: 'Styles',
      },
      type: {
        name: 'string',
        required: false,
      },
    },
    label: {
      control: {
        type: 'text',
      },
      description: 'The item label.',
      type: {
        name: 'string',
        required: true,
      },
    },
    layout: {
      control: {
        type: 'select',
      },
      description: 'The item layout.',
      options: ['inline', 'inline-values', 'stacked'],
      table: {
        category: 'Options',
        defaultValue: { summary: 'stacked' },
      },
      type: {
        name: 'string',
        required: false,
      },
    },
    termClassName: {
      control: {
        type: 'text',
      },
      description: 'Set additional classnames to the list item term.',
      table: {
        category: 'Styles',
      },
      type: {
        name: 'string',
        required: false,
      },
    },
    value: {
      description: 'The item value.',
      type: {
        name: 'object',
        required: true,
        value: {},
      },
    },
    withSeparator: {
      control: {
        type: 'boolean',
      },
      description: 'Add a slash as separator between multiple values.',
      table: {
        category: 'Options',
        defaultValue: { summary: false },
      },
      type: {
        name: 'boolean',
        required: false,
      },
    },
  },
} as ComponentMeta<typeof DescriptionListItemComponent>;

const Template: ComponentStory<typeof DescriptionListItemComponent> = (
  args
) => <DescriptionListItemComponent {...args} />;

export const SingleValueStacked = Template.bind({});
SingleValueStacked.args = {
  label: 'Recusandae vitae tenetur',
  value: ['praesentium'],
  layout: 'stacked',
};

export const SingleValueInlined = Template.bind({});
SingleValueInlined.args = {
  label: 'Recusandae vitae tenetur',
  value: ['praesentium'],
  layout: 'inline',
};

export const MultipleValuesStacked = Template.bind({});
MultipleValuesStacked.args = {
  label: 'Recusandae vitae tenetur',
  value: ['praesentium', 'voluptate', 'tempore'],
  layout: 'stacked',
};

export const MultipleValuesInlined = Template.bind({});
MultipleValuesInlined.args = {
  label: 'Recusandae vitae tenetur',
  value: ['praesentium', 'voluptate', 'tempore'],
  layout: 'inline-values',
  withSeparator: true,
};