import React from "react";
import { AtomProgressBar, IProgressBarProps } from "react/atoms/ProgressBar";
import { Meta, Story } from "@storybook/react";
import { theme } from "data/dataMx";

const getPercentage = () => {
  const numbers = Array.from({ length: 101 });

  numbers.map((n, i) => numbers.push(i));

  return numbers.filter((n) => n !== undefined);
};

const meta: Meta = {
  title: "React/atoms",
  component: AtomProgressBar,
  argTypes: {
    background: {
      control: {
        type: "select",
      },
      options: Object.keys(theme),
    },
    colorPoints: {
      control: {
        type: "select",
      },
      options: Object.keys(theme),
    },
    percentage: {
      control: {
        type: "select",
      },
      type: { name: "number", required: true },
      options: getPercentage(),
    },
    height: {
      control: "text",
      defaultValue: "10px",
    },
  },
  parameters: {
    controls: { expanded: true },
    colorPicker: {
      primaryPalette: getPercentage(),
    },
  },
};

export default meta;

const TemplateProgressBar: Story<IProgressBarProps> = (props) => {
  return <AtomProgressBar {...props} />;
};

export const ProgressBar = TemplateProgressBar.bind({});

ProgressBar.args = {
  background: "neutral300",
  colorPoints: "quaternary500",
  percentage: 50,
};
