import * as React from "react"
import { ComponentStory, ComponentMeta } from "@storybook/react"
import { Modal } from "../src"

export default {
  title: "通用/Modal",
  component: Modal
} as ComponentMeta<typeof Modal>

// Story模版
const Template: ComponentStory<typeof Modal> = () => {
  const [show, setShow] = React.useState(false)

  const handleClose = () => {
    setShow(false)
  }

  return (
    <div>
      <button style={{ marginBottom: 20 }} onClick={e => setShow(!show)}>
        显示
      </button>

      <Modal
        open={show}
        title="偏好设置"
        cancelText="取消"
        okText="确认"
        confirmConfig={{ color: "red", className: "h-14" }}
        onClose={handleClose}
        onOk={() => alert("111")}
      />
    </div>
  )
}

export const Normal = Template.bind({})
