# Dialog

对话框

当需要一个简洁的确认框询问用户时，可以使用 Dialog。

## Usage

### Basic

```tsx
import React, { useState } from 'react'
import { Button, Dialog } from 'react-icecream'

export default () => {
  const [visible, setVisible] = useState(false)
  return (
    <>
      <Button type="primary" onClick={() => setVisible(true)}>
        open a dialog
      </Button>
      <Dialog
        title="基本的对话框"
        visible={visible}
        onCancel={() => setVisible(false)}
      >
        此处是一条通知提醒，此处是一条通知提醒，此处是一条通知提醒，此处是一条通知提醒此处是一条通知提醒，此处是一条通知提醒。
      </Dialog>
    </>
  )
}
```

### 带 Icon

设置 `icon` 属性即可

```tsx
import React, { useState } from 'react'
import { Button, Dialog } from 'react-icecream'

export default () => {
  const [visible, setVisible] = useState(false)
  return (
    <>
      <Button type="primary" onClick={() => setVisible(true)}>
        open a dialog
      </Button>
      <Dialog
        title="基本的对话框"
        icon
        visible={visible}
        onOk={() => setVisible(false)}
        onCancel={() => setVisible(false)}
      >
        此处是一条通知提醒，此处是一条通知提醒，此处是一条通知提醒，此处是一条通知提醒此处是一条通知提醒，此处是一条通知提醒。
      </Dialog>
    </>
  )
}
```

### 不带标题

不设置 `title` 即可

```tsx
import React, { useState } from 'react'
import { Button, Dialog } from 'react-icecream'

export default () => {
  const [visible, setVisible] = useState(false)
  return (
    <>
      <Button type="primary" onClick={() => setVisible(true)}>
        open a dialog
      </Button>
      <Dialog
        visible={visible}
        onOk={() => setVisible(false)}
        onCancel={() => setVisible(false)}
      >
        此处是一条通知提醒，此处是一条通知提醒，此处是一条通知提醒，此处是一条通知提醒此处是一条通知提醒，此处是一条通知提醒。
      </Dialog>
    </>
  )
}
```

### 对 `footer` 进行配置

通过对传入 prop `footer` 的 `Footer` 进行配置，我们可以控制 `footer` 中按钮的文本、类型等

<code src="./demos/footer.tsx"></code>

### 自定义 `Footer` 组件

你也可以实现完全自定义的 `Footer` 组件，注意在自定义的 `Footer` 组件中可以通过 `useModalFooterCtx` 获得当前弹框的信息

<code src="./demos/custom-footer.tsx"></code>

### 点击 mask 关闭

<code src="./demos/mask-closable.tsx"></code>

<API src="./Dialog.tsx" exports='["default"]'></API>
