Skip to content

Commit c89cd0c

Browse files
authoredApr 1, 2022
style(SearchTree): 增加大小尺寸样式&增加示例文档 (#733)
1 parent 0dd75b3 commit c89cd0c

File tree

3 files changed

+65
-3
lines changed

3 files changed

+65
-3
lines changed
 

‎packages/react-search-tree/README.md

+41
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,47 @@ const onChangeSinge=(selectd, selectedAll, isChecked)=>{
118118
ReactDOM.render(<Demo />, _mount_);
119119
```
120120

121+
## 尺寸
122+
123+
<!--rehype:bgWhite=true&codeSandbox=true&codePen=true-->
124+
```jsx
125+
import React, { useState, useEffect, useRef } from 'react';
126+
import { SearchTree } from 'uiw';
127+
128+
const Demo = () => {
129+
130+
const data = [
131+
{ label: '小尺寸', key: 1 },
132+
{ label: '默认尺寸', key: 2 },
133+
{ label: '大尺寸', key: 3 },
134+
]
135+
136+
return(
137+
<>
138+
<SearchTree
139+
style={{ width: 150 }}
140+
value={[{ label: '小尺寸', key: 1 }]}
141+
options={data}
142+
size="small"
143+
/>
144+
<SearchTree
145+
style={{ width: 175, marginTop: 10 }}
146+
value={[{ label: '默认尺寸', key: 2 }]}
147+
options={data}
148+
/>
149+
<SearchTree
150+
style={{ width: 200, marginTop: 10 }}
151+
value={[{ label: '大尺寸', key: 3 }]}
152+
options={data}
153+
size="large"
154+
/>
155+
</>
156+
)
157+
}
158+
159+
ReactDOM.render(<Demo />, _mount_);
160+
```
161+
121162
## 自定义空选项
122163

123164
<!--rehype:bgWhite=true&codeSandbox=true&codePen=true-->

‎packages/react-search-tree/src/SearchTagInput.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import Empty from '@uiw/react-empty';
88
import { IProps } from '@uiw/utils';
99
import './style/index.less';
1010

11+
const TagSize = { large: 25, default: 20, small: 17 };
12+
1113
export interface DropContent<V> {
1214
values: Array<V>;
1315
onSelected?: (selectedAll: Array<V>, selectd: V, isChecked: boolean) => void;
@@ -146,14 +148,14 @@ function SearchTagInput<V extends SearchTagInputOption>(props: SearchTagInputPro
146148
onMouseOver={() => renderSelectIcon('enter')}
147149
onMouseLeave={() => renderSelectIcon('leave')}
148150
onClick={() => inputRef.current?.focus()}
149-
style={{ minWidth: 200, maxWidth: 'none', ...style }}
151+
style={{ minWidth: style?.width || 200, maxWidth: 'none', ...style }}
150152
>
151-
<div className={`${prefixCls}-inner`}>
153+
<div className={[`${prefixCls}-inner`, `${prefixCls}-${size}`].filter(Boolean).join(' ').trim()}>
152154
<div style={{ display: 'flex', flexFlow: 'wrap', width: '100%' }}>
153155
{selectedOption.map((item, index) => {
154156
return (
155157
<Tag
156-
style={{ height: 20, margin: 1, display: 'flex', alignItems: 'center' }}
158+
style={{ height: TagSize[size], margin: 1, display: 'flex', alignItems: 'center' }}
157159
className={`${prefixCls}-tag`}
158160
key={index}
159161
closable

‎packages/react-search-tree/src/style/index.less

+19
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,24 @@
7373
display: flex;
7474
align-content: center;
7575
}
76+
77+
&-inner-small {
78+
height: 20px;
79+
}
80+
81+
&-inner-large {
82+
height: 30px;
83+
}
84+
85+
.w-input-small .w-input-inner {
86+
height: 16px;
87+
font-size: 10px;
88+
padding: 0px;
89+
}
90+
91+
.w-input-large .w-input-inner {
92+
// line-height:0px !important;
93+
height: 28px;
94+
}
7695
}
7796
}

0 commit comments

Comments
 (0)
Please sign in to comment.