import {ArgsTable, Meta, Story, Canvas} from '@storybook/addon-docs';
import {StoryVariant} from '../../docs/utils';

import MathSymbol, {MATH_SYMBOL_TYPE, ICON_COLOR, SIZE} from './MathSymbol';
import Flex from '../flex/Flex';
import MathSymbolA11y from './stories/MathSymbol.a11y.mdx';
import PageHeader from 'blocks/PageHeader';
import {formatTags} from '../../docs/utils';

<Meta
  title="Components/MathSymbol"
  component={MathSymbol}
  argTypes={{
    color: {
      control: {type: 'select', options: ICON_COLOR},
      table: {
        type: {
          summary: formatTags(Object.values(ICON_COLOR)),
        },
      },
    },
    size: {control: 'select'},
  }}
  args={{
    type: MATH_SYMBOL_TYPE.ALPHA,
    color: ICON_COLOR.ADAPTIVE,
  }}
/>

<PageHeader>MathSymbol</PageHeader>

- [Stories](#stories)
- [Accessibility](#accessibility)

## Overview

<Canvas>
  <Story name="Default">{args => <MathSymbol {...args} />}</Story>
</Canvas>

<ArgsTable story="Default" />

## Stories

### Types

<Canvas>
  <Story name="Types">
    {args => (
      <Flex wrap>
        {Object.values(MATH_SYMBOL_TYPE).map(type => (
          <StoryVariant label={`type - ${type}`} width={200} key={type}>
            <MathSymbol {...args} type={type} />
          </StoryVariant>
        ))}
      </Flex>
    )}
  </Story>
</Canvas>

### Sizes

<Canvas>
  <Story name="Sizes">
    {args => (
      <div>
        {Object.values(SIZE).map(size => (
          <StoryVariant label={`size - ${size}`} key={size}>
            <MathSymbol {...args} size={size} />
          </StoryVariant>
        ))}
      </div>
    )}
  </Story>
</Canvas>

### Colors

<Canvas>
  <Story name="Colors">
    {args => (
      <Flex wrap>
        {Object.values(ICON_COLOR).map(color => (
          <StoryVariant label={color} color={color} width={200} key={color}>
            {color === 'icon-white' ? (
              <div className="sg-story-variant-dark-box">
                <MathSymbol {...args} size={color} />
              </div>
            ) : (
              <MathSymbol {...args} size={color} />
            )}
          </StoryVariant>
        ))}
      </Flex>
    )}
  </Story>
</Canvas>

## Accessibility

<MathSymbolA11y />
