Skip to content

Commit 49999c9

Browse files
nullptr-zxingyuefeng
authored andcommitted
doc(SearchInputBar): 重构搜索栏文档
1 parent 89f632a commit 49999c9

File tree

2 files changed

+73
-116
lines changed

2 files changed

+73
-116
lines changed
Lines changed: 41 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
SearchInputBar 动作面板
1+
SearchInputBar 搜索栏
22
---
33

44
可用于用户输入搜索信息
55

6-
![](https://user-images.githubusercontent.com/66067296/140004397-65ffc69e-a79f-425d-9d75-2928c125e5c8.gif)<!--rehype:style=zoom: 33%;float: right; margin-left: 15px;-->
6+
<!-- ![](https://user-images.githubusercontent.com/66067296/140004397-65ffc69e-a79f-425d-9d75-2928c125e5c8.gif) -->
7+
<!--rehype:style=zoom: 33%;float: right; margin-left: 15px;-->
78

89

910
### 基础示例
10-
11-
```jsx
12-
import { Fragment, useState } from 'react';
11+
```jsx mdx:preview
12+
import React, { useState } from 'react';
1313
import { SearchInputBar } from '@uiw/react-native';
14+
1415
function Demo() {
16+
console.log('1')
1517
const [value, setValue] = useState('')
1618
return (
17-
<Fragment>
1819
<SearchInputBar
1920
onChangeText={setValue}
2021
onClear={()=>setValue('')}
@@ -25,73 +26,42 @@ function Demo() {
2526
}
2627
}}
2728
/>
28-
</Fragment>
29-
);
29+
)
3030
}
31+
export default Demo
3132
```
3233

33-
### 一直显示右侧按钮 && 自定义placeholder && 自定右侧搜索内容
34+
### 自定义搜索按钮
35+
```jsx mdx:preview
36+
import React, { useState } from 'react';
37+
import SearchInputBar from '@uiw/react-native/lib/SearchInputBar';
3438

35-
```jsx
36-
import { Fragment, useState } from 'react';
37-
import { SearchInputBar } from '@uiw/react-native';
3839
function Demo() {
3940
const [value, setValue] = useState('')
4041
return (
41-
<Fragment>
4242
<SearchInputBar
4343
onChangeText={setValue}
4444
onClear={()=>setValue('')}
4545
value={value}
4646
placeholder="请输入搜索关键字"
47-
searchRender={<View style={styles.search}><Text>搜索</Text></View>}
47+
searchRender={<div style={{ display:'flex', alignItems:'center' }}><label>搜索</label></div>}
4848
actionName="搜一下"
4949
showActionButton
50-
button={{
51-
onPress() {
52-
// 点击搜索按钮触法
53-
}
54-
}}
5550
/>
56-
</Fragment>
57-
);
51+
)
5852
}
53+
export default Demo
5954
```
6055

61-
### 键盘不收起来
62-
63-
**注意: 每层```ScrollView```都要写```keyboardShouldPersistTaps="always"```**
64-
65-
```jsx
66-
import { Fragment, useState } from 'react';
67-
import { SearchInputBar } from '@uiw/react-native';
68-
function Demo() {
69-
const [value, setValue] = useState('')
70-
return (
71-
<ScrollView keyboardShouldPersistTaps="always" >
72-
<SearchInputBar
73-
onChangeText={setValue}
74-
onClear={()=>setValue('')}
75-
value={value}
76-
showActionButton
77-
button={{
78-
onPress() {
79-
// 点击搜索按钮触法
80-
}
81-
}}
82-
/>
83-
</ScrollView>
84-
);
85-
}
86-
```
8756

8857
### 获取输入框 Ref
58+
```jsx mdx:preview
59+
import React, { useState, Fragment, useRef } from 'react';
60+
import { SearchInputBar, Button } from '@uiw/react-native';
8961

90-
```jsx
91-
import { Fragment, useRef } from 'react';
92-
import { SearchInputBar } from '@uiw/react-native';
9362
function Demo() {
9463
const inputRef = useRef()
64+
const [value, setValue] = useState('')
9565
return (
9666
<Fragment>
9767
<SearchInputBar
@@ -113,39 +83,32 @@ function Demo() {
11383
console.log(inputRef.current.inputRef)
11484
}}
11585
>获取 输入框 Ref</Button>
116-
</Fragment>
117-
);
86+
</Fragment>
87+
)
11888
}
89+
export default Demo
11990
```
12091

12192
### Props
12293
**注意: 组件继承了```TextInput```属性**
123-
```ts
94+
95+
```js
12496
import { TextInputProps,StyleProp,ViewStyle } from 'react-native';
12597
import { ButtonProps,IconsProps } from '@uiw/react-native'
98+
```
99+
100+
| 参数 | 说明 | 类型 | 默认值 |
101+
|------|------|-----|------|
102+
| containerStyle | 容器样式 | StyleProp<ViewStyle> | - |
103+
| button | 右侧按钮 | ButtonProps | - |
104+
| actionName | 右侧按钮文案 | string | - |
105+
| showActionButton | 是否一直显示右侧按钮 null = 永不显示 | `boolean` \| `null` | - |
106+
| searchIcon | 搜索图标Icon参数 参考Icon组件 | IconsProps | - |
107+
| onSearch | 点击搜索图标时触发事件 | Function | - |
108+
| closeIcon | 清除图标Icon参数 参考Icon组件 | IconsProps | - |
109+
| onClear | 点击清除图标时触发事件 | Function | - |
110+
| searchRender | 自定义搜索 | React.ReactNode | - |
111+
| inputStyle | 输入框TextInput样式 | TextStyle | - |
112+
| loading | loading加载 | any | - |
113+
126114

127-
export interface SearchInputBarProps extends TextInputProps {
128-
/** 容器样式 */
129-
containerStyle?: StyleProp<ViewStyle>;
130-
/** 右侧按钮 */
131-
button?: ButtonProps;
132-
/** 右侧按钮文案 */
133-
actionName?: string;
134-
/** 是否一直显示右侧按钮 null = 永不显示 */
135-
showActionButton?: boolean | null;
136-
/** 搜索图标Icon参数 参考Icon组件 */
137-
searchIcon?: IconsProps;
138-
/** 点击搜索图标时触发事件 */
139-
onSearch?: Function;
140-
/** 清除图标Icon参数 参考Icon组件 */
141-
closeIcon?: IconsProps;
142-
/** 点击清除图标时触发事件 */
143-
onClear?: Function;
144-
/** 自定义搜索 */
145-
searchRender?: JSX.Element;
146-
/** 输入框TextInput样式 */
147-
inputStyle?: TextStyle
148-
/** loading加载 */
149-
loading?: any
150-
}
151-
```

packages/core/src/Tooltip/README.md

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,29 @@ Tooltip 工具提示
33

44
当用户点击元素时,工具提示将显示信息。
55

6-
![](https://user-images.githubusercontent.com/57083007/146734166-271ec118-69b6-437a-885e-803e435cc05b.gif)<!--rehype:style=zoom: 33%;float: right; margin-left: 15px;-->
6+
<!-- ![](https://user-images.githubusercontent.com/57083007/146734166-271ec118-69b6-437a-885e-803e435cc05b.gif) -->
7+
<!--rehype:style=zoom: 33%;float: right; margin-left: 15px;-->
78

89
### 基础示例
910

10-
```jsx
11+
```jsx mdx:preview
12+
import React, { useState } from 'react';
1113
import { Tooltip } from '@uiw/react-native';
1214

13-
1415
function Demo() {
1516
return (
16-
<Tooltip title='我是一个文本'>
17-
<Text>我是一个文本</Text>
17+
<Tooltip title={<label style={{ wordBreak: "keep-all" }}>我是一个文本</label>}>
18+
我是一个文本1
1819
</Tooltip>
1920
);
2021
}
22+
export default Demo
2123
```
2224

23-
### 使用 自定义提示内容
25+
### 自定义提示内容
2426

25-
```jsx
27+
```jsx mdx:preview
28+
import React, { useState } from 'react';
2629
import { Tooltip, Icon } from '@uiw/react-native';
2730

2831
function Demo() {
@@ -31,44 +34,35 @@ function Demo() {
3134
backgroundColor="pink"
3235
width={30}
3336
height={30}
34-
title={(<View>
35-
<Text>我是一个苹果</Text>
36-
<Icon name='apple' color="#fff" />
37-
</View>)}
37+
title={(
38+
<div>
39+
<label style={{ wordBreak: "keep-all" }}>我是一个苹果</label>
40+
<Icon name='apple' color="#fff" />
41+
</div>
42+
)}
3843
>
3944
<Icon name='apple' color="red" />
4045
</Tooltip>
4146
);
4247
}
48+
export default Demo
4349
```
4450

45-
### Tooltip Props
51+
### Props
4652

47-
```ts
53+
```js
4854
import { ModalProps } from 'react-native';
49-
50-
export interface TooltipProps extends ModalProps {
51-
/** cloud 元素 */
52-
title: React.ReactNode,
53-
/** 子元素 */
54-
children: JSX.Element,
55-
/** 点击类型 */
56-
toggleAction?: 'onPress' | 'onLongPress' | 'onPressIn' | 'onPressOut',
57-
/** 高度 */
58-
height?: number | 'auto',
59-
/** 宽度 */
60-
width?: number | 'auto',
61-
/** 背景色 */
62-
backgroundColor?: string,
63-
/** 圆角大小 */
64-
borderRadius?: number,
65-
/**
66-
* 打开时触发
67-
*/
68-
onOpen?: Function,
69-
/**
70-
* 关闭时触发
71-
*/
72-
onClose?: Function,
73-
}
7455
```
56+
57+
| 参数 | 说明 | 类型 | 默认值 |
58+
|------|------|-----|------|
59+
| title | cloud 元素 | React.ReactNode | - |
60+
| children | 子元素 | JSX.Element | - |
61+
| toggleAction | 点击类型 | `onPress` \| `onLongPress` \| `onPressIn` \| `onPressOut` | - |
62+
| height | 高度 | number \| `auto` | - |
63+
| width | 宽度 | number \| `auto` | - |
64+
| backgroundColor | 背景色 | string | - |
65+
| borderRadius | 圆角大小 | number | - |
66+
| onOpen | 打开时触发 | Function | - |
67+
| onClose | 关闭时触发 | Function | - |
68+

0 commit comments

Comments
 (0)