Skip to content

Commit ebd15a2

Browse files
nullptr-zxingyuefeng
authored andcommitted
doc(ActionSheet): 重构动作面板文档
1 parent 098c5b6 commit ebd15a2

File tree

3 files changed

+38
-52
lines changed

3 files changed

+38
-52
lines changed

packages/core/src/ActionSheet/README.md

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,36 @@ ActionSheet 动作面板
33

44
该组件提供了一种动作面板, 底部缓缓出现
55

6-
![](https://user-images.githubusercontent.com/57083007/137631382-70df5dd3-0200-4ddb-bd11-3578ee99d032.gif)<!--rehype:style=zoom: 33%;float: right; margin-left: 15px;-->
6+
<!-- ![](https://user-images.githubusercontent.com/57083007/137631382-70df5dd3-0200-4ddb-bd11-3578ee99d032.gif) -->
7+
<!--rehype:style=zoom: 33%;float: right; margin-left: 15px;-->
78

89
### 基础示例
10+
```jsx mdx:preview
11+
import React, { Fragment, useState } from 'react';
12+
import { Button, ActionSheet } from '@uiw/react-native';
13+
import { ActionSheetItem } from '@uiw/react-native/lib/ActionSheet'
914

10-
```jsx
11-
import { Fragment, useState } from 'react';
12-
import { ActionSheet, Button,ActionSheetItem } from '@uiw/react-native';
1315
function Demo() {
1416
const [visible, setVisible] = useState(false)
1517
return (
1618
<Fragment>
1719
<Button onPress={()=>setVisible(true)}>打开 ActionSheet</Button>
18-
<ActionSheet
19-
visible={visible}
20-
>
20+
<ActionSheet visible={visible}>
2121
<ActionSheetItem onPress={()=>console.log('按钮一')}>按钮一</ActionSheetItem>
2222
<ActionSheetItem onPress={()=>console.log('按钮二')}>按钮二</ActionSheetItem>
2323
</ActionSheet>
2424
</Fragment>
2525
);
2626
}
27+
export default Demo
2728
```
2829

29-
### 弹层关闭 && 自定义取消文本
30+
### 自定义按钮文字
31+
```jsx mdx:preview
32+
import React, { Fragment, useState } from 'react';
33+
import { Button, ActionSheet } from '@uiw/react-native';
34+
import { ActionSheetItem } from '@uiw/react-native/lib/ActionSheet'
3035

31-
```jsx
32-
import { Fragment, useState } from 'react';
33-
import { ActionSheet, Button,ActionSheetItem } from '@uiw/react-native';
3436
function Demo() {
3537
const [visible, setVisible] = useState(false)
3638
return (
@@ -39,56 +41,46 @@ function Demo() {
3941
<ActionSheet
4042
visible={visible}
4143
onCancel={true}
42-
cancelText='取消'
44+
cancelText='关闭弹层'
4345
>
4446
<ActionSheetItem onPress={()=>console.log('按钮一')}>按钮一</ActionSheetItem>
4547
<ActionSheetItem onPress={()=>console.log('按钮二')}>按钮二</ActionSheetItem>
4648
</ActionSheet>
4749
</Fragment>
4850
);
4951
}
52+
export default Demo
5053
```
5154

5255
### Props
5356

54-
```ts
57+
```js
5558
import { StyleProp, ViewStyle } from 'react-native';
5659
import { ModalProps } from '@uiw/react-native';
5760

5861
export interface DividerStyle {
5962
itemDivider?: StyleProp<ViewStyle>,
6063
actionDivider?: StyleProp<ViewStyle>,
6164
}
62-
63-
export interface ActionSheetProps extends ModalProps {
64-
/** 点击蒙层是否关闭 */
65-
onCancel?: Boolean;
66-
/** 分割线样式 */
67-
dividerStyle?: DividerStyle;
68-
/** 取消的容器样式 */
69-
containerStyle?: StyleProp<ViewStyle>;
70-
/** 动作在被触摸操作激活时以多少不透明度显示 默认 1 */
71-
activeOpacity?: number;
72-
/** 动作有触摸操作时显示出来的底层的颜色 默认 #f1f1f1 */
73-
underlayColor?: string;
74-
/** 取消的文本样式 */
75-
textStyle?: StyleProp<TextStyle>;
76-
/** 取消的文本 */
77-
cancelText?: React.ReactNode;
78-
}
7965
```
8066

81-
### ActionSheetItem Props
67+
| 参数 | 说明 | 类型 | 默认值 |
68+
|------|------|-----|------|
69+
| onCancel | 点击蒙层是否关闭 | Boolean | `false` |
70+
| dividerStyle | 分割线样式 | DividerStyle | - |
71+
| containerStyle | 取消的容器样式 | StyleProp<ViewStyle> | - |
72+
| activeOpacity | 动作在被触摸操作激活时以多少不透明度显示 | number | `#f1f1f1` |
73+
| underlayColor | 动作有触摸操作时显示出来的底层的颜色 | string | `#f1f1f1` |
74+
| cancelText | 取消的文本 | `React.ReactNode` | - |
75+
| textStyle | 取消的文本样式 | `StyleProp<TextStyle>` | - |
8276

83-
```ts
77+
### ActionSheetItem Props
78+
```js
8479
import { TextStyle, StyleProp, ViewStyle } from 'react-native';
80+
```
8581

86-
export interface ActionSheetItemProps {
87-
/** 容器样式 */
88-
containerStyle?: StyleProp<ViewStyle>;
89-
/** 文本样式 */
90-
textStyle?: StyleProp<TextStyle>;
91-
/** 点击 ActionSheetItem 触发的事件 */
92-
onPress?: ((event: GestureResponderEvent) => void),
93-
}
94-
```
82+
| 参数 | 说明 | 类型 | 默认值 |
83+
|------|------|-----|------|
84+
| containerStyle | 容器样式 | `StyleProp<ViewStyle>` | - |
85+
| textStyle | 文本样式 | `StyleProp<ViewStyle>` | - |
86+
| onPress | 点击 ActionSheetItem 触发的事件 | `(event: GestureResponderEvent) => void` | - |

packages/core/src/ActionSheet/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
22
import { View, Dimensions, StyleSheet, TextStyle, StyleProp, ViewStyle } from 'react-native';
33
import Modal, { ModalProps } from '../Modal';
4-
export { default as ActionSheetItem } from './item';
54
import ActionSheetItem from './item';
5+
export { default as ActionSheetItem } from './item';
66

77
let MainWidth = Dimensions.get('window').width;
88

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
import Markdown, { importAll } from '../../../component/Markdown';
1+
import Preview from 'src/component/Preview';
2+
import md from '@uiw/react-native/lib/ActionSheet/README.md';
23

3-
export default class Page extends Markdown {
4-
path = '/packages/core/src/ActionSheet/README.md';
5-
getMarkdown = async () => {
6-
const md = await import('@uiw/react-native/lib/ActionSheet/README.md');
7-
// 支持 markdown 中,相对于当前 index.tsx 相对路径引入图片资源
8-
importAll((require as any).context('./', true, /\.(png|gif|jpg|svg)$/), this.imageFiles);
9-
return md.default || md;
10-
};
11-
}
4+
const DEMO = () => <Preview {...md} />;
5+
export default DEMO;

0 commit comments

Comments
 (0)