Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BottomSheet 底部滑出 #24

Merged
merged 31 commits into from
Apr 11, 2020
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
cbe7f01
chore:packaga文件
superstaring Mar 13, 2020
efb822e
chore:Dialog组件
superstaring Mar 16, 2020
033a8f4
chore:Dialog组件
superstaring Mar 17, 2020
02e5d71
chore:Dialog组件
superstaring Mar 18, 2020
546f12a
chore(Dialog): 修复拖拽报错的问题
tianyanqiu Mar 19, 2020
9bd7a2f
chore:dialog文档添加不可拖拽示例
superstaring Mar 20, 2020
1b9e8f9
chore(Dialog): 处理ts警告错误
tianyanqiu Mar 20, 2020
6579d73
Merge branch 'dialog' of https://github.com/sinoui/core into dialog
tianyanqiu Mar 20, 2020
a976778
chore:调整closeIcon
superstaring Mar 20, 2020
bd0d592
chore:组件调整
superstaring Mar 20, 2020
3c6e39f
chore:动画调整
superstaring Mar 20, 2020
eff9233
chore:dialog调整
superstaring Mar 23, 2020
54d9da6
chore:BottomSheet组件
superstaring Mar 24, 2020
972e871
chore:合并master分支
superstaring Mar 24, 2020
31b6eba
chore:合并master分支
superstaring Mar 24, 2020
a1e0ffb
chore:BottomSheet组件
superstaring Mar 24, 2020
915d630
chore:组件调整
superstaring Mar 25, 2020
5e42092
chore:组件调整
superstaring Mar 25, 2020
45d9aaf
chore:组件调整
superstaring Mar 25, 2020
37379e8
chore:BottomSheet组件调整
superstaring Mar 25, 2020
5e7be6e
chore: 文档调整
superstaring Mar 25, 2020
766b5b5
chore:去掉是否显示遮罩层属性
superstaring Mar 25, 2020
cf3544e
chore:添加动画文件
superstaring Apr 7, 2020
9913e5e
chore:BottomSheet组件调整
superstaring Apr 8, 2020
0f1f6dd
chore:Dialog组件调整
superstaring Apr 8, 2020
8a8911b
chore:BottomSheet组件添加单元测试
superstaring Apr 9, 2020
1e67a02
chore:BottomSheet和Dialog调整
superstaring Apr 9, 2020
c51311e
chore:BottomSheet组件调整
superstaring Apr 10, 2020
3a7912d
chore:Dialog文档调整
superstaring Apr 10, 2020
5beb30f
chore:Dialog调整
superstaring Apr 10, 2020
e7c7438
chore:Dialog添加快照测试
superstaring Apr 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/docs/components-apis/bottomSheet.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
id: bottomSheet
title: BottomSheet
---

BottomSheet 底部滑出组件。

## 引用方式

```tsx
import BottomSheet from '@sinoui/core/BottomSheet';
```

## API

BottomSheet 组件属性:

| 参数名称 | 参数类型 | 默认值 | 说明 |
| ------------------ | --------------- | ------ | ---------------------------- |
| open | boolean | false | 是否显示 |
| backdropClick | boolean | true | 是否响应点击遮罩层事件 |
| onBackdropClick | ()=>void | | 点击遮罩层事件触发的回调函数 |
| transitionDuration | number | 300 | 动画延长时间 |
| color | string | | 指定背景颜色 |
| children | React.ReactNode | | 子元素 |
| className | string | | 添加自定义类名 |

更多使用示例,请参考[BottomSheet Demos](/docs/components/bottomSheet)
88 changes: 88 additions & 0 deletions docs/docs/components-apis/dialog.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
id: dialog
title: Dialog
---

弹窗。

## Dialog

包裹整个弹窗的根组件。

引用方式:

```tsx
import Dialog from '@sinoui/core/Dialog';
```

Dialog 组件属性:

| 参数名称 | 参数类型 | 默认值 | 说明 |
| --------------- | --------------- | ------ | ------------------------ |
| children | React.ReactNode | | 子元素 |
| open | boolean | false | 是否显示 Dialog |
| backdrop | boolean | true | 是否显示遮罩层 |
| showCloseIcon | boolean | false | 是否显示关闭图标 |
| onRequestClose | ()=>void | | 点击关闭按钮的回调函数 |
| draggable | boolean | true | 是否弹窗可以拖拽 |
| backdropClick | boolean | false | 是否开启遮罩层的点击事件 |
| onBackdropClick | ()=>void | | 点击遮罩层的回调函数 |
| absolute | boolean | false | 布局方式 |
| fullScreen | boolean | false | 设置全屏显示 |
| fullWidth | boolean | false | 设置最大宽度显示 |
| autoWidth | boolean | false | 设置宽度自适应 |
| className | string | | 自定义类名 |

## DialogTitle

弹窗标题组件。

引用方式:

```tsx
import DialogTitle from '@sinoui/core/DialogTitle';
```

DialogTitle 组件属性:

| 参数名称 | 参数类型 | 默认值 | 说明 |
| --------- | --------------- | ------ | ---------- |
| children | React.ReactNode | | 子元素 |
| className | string | | 自定义类名 |

## DialogContent

弹窗内容组件。

引用方式:

```tsx
import DialogContent from '@sinoui/core/DialogContent';
```

DialogContent 组件属性:

| 参数名称 | 参数类型 | 默认值 | 说明 |
| --------- | --------------- | ------ | ---------- |
| children | React.ReactNode | | 子元素 |
| className | string | | 自定义类名 |

## DialogActions

弹窗按钮组件。

引用方式:

```tsx
import DialogActions from '@sinoui/core/DialogActions';
```

DialogActions 组件属性:

| 参数名称 | 参数类型 | 默认值 | 说明 |
| --------- | --------------- | ------ | ------------ |
| children | React.ReactNode | | 子元素 |
| column | boolean | false | 是否垂直显示 |
| className | string | | 自定义类名 |

更多示例,请参考[Dialog Demos](/docs/components/Dialog)
77 changes: 77 additions & 0 deletions docs/docs/components/bottomSheet-demos/BottomSheetDemo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React, { useState } from 'react';
import { ThemeProvider } from 'styled-components';
import { defaultTheme } from '@sinoui/theme';
import Button from '@sinoui/core/Button';
import BottomSheet from '@sinoui/core/BottomSheet';
import List from '@sinoui/core/List';
import ListItem from '@sinoui/core/ListItem';
import ListItemText from '@sinoui/core/ListItemText';
import ListItemPrimaryAction from '@sinoui/core/ListItemPrimaryAction';
import SvgIcon from '@sinoui/core/SvgIcon';
import { MdShare, MdInsertLink, MdModeEdit, MdDelete } from 'react-icons/md';

const listData = [
{ icon: MdShare, text: 'Share' },
{ icon: MdInsertLink, text: 'Get link' },
{ icon: MdShare, text: 'Share' },
{ icon: MdModeEdit, text: 'Edit name' },
{ icon: MdDelete, text: 'Delete collection' },
];

const listScrollData = listData.concat(listData, listData);

const Content = (props: any) => {
const { data, onClick } = props;
return (
<List>
{data.map((item: any, index: number) => (
<React.Fragment key={index.toString()}>
<ListItem onClick={onClick}>
<ListItemPrimaryAction>
<SvgIcon as={item.icon} color="textSecondary" />
</ListItemPrimaryAction>
<ListItemText>{item.text}</ListItemText>
</ListItem>
</React.Fragment>
))}
</List>
);
};

function BottomSheetDemo(props: any) {
const [open, setOpen] = useState(false);

const onClick = () => {
setOpen(!open);
};

const onBackdropClick = () => {
setOpen(false);
};

const onItemClick = () => {
setOpen(false);
};

const { backdrop: backdropProps, listScroll } = props;
return (
<ThemeProvider theme={defaultTheme}>
<div style={{ width: '300px' }}>
<Button onClick={onClick}>CLICK</Button>
<BottomSheet
open={open}
onBackdropClick={onBackdropClick}
backdrop={backdropProps}
{...props}
>
<Content
onClick={onItemClick}
data={listScroll ? listScrollData : listData}
/>
</BottomSheet>
</div>
</ThemeProvider>
);
}

export default BottomSheetDemo;
superstaring marked this conversation as resolved.
Show resolved Hide resolved
135 changes: 135 additions & 0 deletions docs/docs/components/bottomSheet.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
id: bottomSheet
title: bottomSheet 底部滑出
---

import { ThemeProvider } from 'styled-components';
import { defaultTheme } from '@sinoui/theme';
import BottomSheet from '@sinoui/core/BottomSheet';
import BottomSheetDemo from './bottomSheet-demos/BottomSheetDemo';

## 基本使用

```tsx
import BottomSheet from '@sinoui/core/BottomSheet';

const listData = [
{ icon: MdShare, text: 'Share' },
{ icon: MdInsertLink, text: 'Get link' },
{ icon: MdShare, text: 'Share' },
{ icon: MdModeEdit, text: 'Edit name' },
{ icon: MdDelete, text: 'Delete collection' },
];

const Content = (props: any) => {
return (
<List>
{listData.map((item: any, index) => (
<React.Fragment key={index.toString()}>
<ListItem onClick={props.onClick}>
<ListItemPrimaryAction>
<SvgIcon as={item.icon} color="textSecondary" />
</ListItemPrimaryAction>
<ListItemText>{item.text}</ListItemText>
</ListItem>
</React.Fragment>
))}
</List>
);
};

function BottomSheetDemo() {
const [open, setOpen] = useState(false);

const onClick = () => {
setOpen(!open);
};

const onBackdropClick = () => {
setOpen(false);
};

const onItemClick = () => {
setOpen(false);
};

return (
<>
<Button onClick={onClick}>CLICK</Button>
<BottomSheet open={open} onBackdropClick={onBackdropClick}>
<Content onClick={onItemClick} />
</BottomSheet>
</>
);
}
```

效果如下:

<BottomSheetDemo />

## 内容超出屏幕一半显示滚动条

```tsx
import BottomSheet from '@sinoui/core/BottomSheet';

const listData = [
{ icon: MdShare, text: 'Share' },
{ icon: MdInsertLink, text: 'Get link' },
{ icon: MdShare, text: 'Share' },
{ icon: MdModeEdit, text: 'Edit name' },
{ icon: MdDelete, text: 'Delete collection' },
];

const listScrollData = listData.concat(listData, listData);

const Content = (props: any) => {
return (
<List>
{listScrollData.map((item: any, index) => (
<React.Fragment key={index.toString()}>
<ListItem onClick={props.onClick}>
<ListItemPrimaryAction>
<SvgIcon as={item.icon} color="textSecondary" />
</ListItemPrimaryAction>
<ListItemText>{item.text}</ListItemText>
</ListItem>
</React.Fragment>
))}
</List>
);
};

function BottomSheetDemo() {
const [open, setOpen] = useState(false);

const onClick = () => {
setOpen(!open);
};

const onBackdropClick = () => {
setOpen(false);
};

const onItemClick = () => {
setOpen(false);
};

return (
<>
<Button onClick={onClick}>CLICK</Button>
<BottomSheet open={open} onBackdropClick={onBackdropClick}>
<Content onClick={onItemClick} />
</BottomSheet>
</>
);
}
```

效果如下:

<BottomSheetDemo listScroll />

## API

查看[BottomSheet 组件 API](/docs/components-apis/bottomSheet)
31 changes: 31 additions & 0 deletions docs/docs/components/dialog-demos/DialogDemo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React, { useState } from 'react';
import Dialog from '@sinoui/core/Dialog';
import DialogTitle from '@sinoui/core/DialogTitle';
import DialogContent from '@sinoui/core/DialogContent';
import DialogActions from '@sinoui/core/DialogActions';
import Button from '@sinoui/core/Button';

export default function DialogDemo(props: any) {
const [open, setOpen] = useState(false);
return (
<>
<Button onClick={() => setOpen(true)}>CLICK</Button>
<Dialog
open={open}
{...props}
onRequestClose={() => props.onRequestClose && setOpen(false)}
onBackdropClick={() => props.onBackdropClick && setOpen(false)}
>
<DialogTitle>Use Google location service</DialogTitle>
<DialogContent>
Let Google help apps determine location. This means sending anonymous
location data to Google, even when no apps are running.
</DialogContent>
<DialogActions>
<Button onClick={() => setOpen(false)}>DISAGREE</Button>
<Button onClick={() => setOpen(false)}>AGREE</Button>
</DialogActions>
</Dialog>
</>
);
}
Loading