import React from 'react';
import {
  Title,
  Description,
  Primary,
  PRIMARY_STORY,
  ArgsTable,
} from '@storybook/addon-docs/blocks';

import NumberRating from '.';

export default {
  title: 'Theme/Atoms/Number Rating',
  component: NumberRating,
  argTypes: {
    total: {
      name: 'total',
      type: { name: 'number', required: true },
      defaultValue: '',
      description: 'Total number.',
      table: {
        type: { summary: 'one of 5 and 10' },
        defaultValue: { summary: '' },
      },
      control: {
        type: 'inline-radio',
        options: [5, 10],
      },
    },
    rating: {
      name: 'rating',
      type: { name: 'string', required: true },
      defaultValue: '',
      description: 'Rate number/s.',
      table: {
        type: { summary: 'number | array of numbers' },
        defaultValue: { summary: '' },
      },
      control: { type: 'range', min: 0, max: 10, step: 1 },
    },
  },
  parameters: {
    docs: {
      description: {
        component:
          'A component that accepts the rate numbers and the total number and generates a rating div.',
      },
      page: () => (
        <>
          <Title />
          <Description />
          <Primary />
          <ArgsTable story={PRIMARY_STORY} />
        </>
      ),
    },
  },
};

const Template = (args) => <NumberRating {...args} />;

export const Default = Template.bind({});
Default.args = {
  total: 10,
  rating: 4,
};
