Skip to content

Commit 2af2388

Browse files
authored
fix: searchbar 组件样式兼容 (jdf2e#333)
1 parent 3e91f74 commit 2af2388

File tree

4 files changed

+63
-5
lines changed

4 files changed

+63
-5
lines changed

src/packages/searchbar/searchbar.scss

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,19 @@
5151
right: 5px;
5252
top: 53%;
5353
}
54-
&__input {
55-
box-sizing: border-box;
54+
.nut-searchbar__input-box {
5655
display: flex;
5756
align-items: center;
57+
flex: 1;
58+
}
59+
&__input {
60+
border: 0;
61+
outline: 0;
62+
box-sizing: border-box;
63+
5864
width: $searchbar-input-width;
5965
height: $searchbar-input-height;
60-
flex: 1;
66+
width: 100%;
6167
padding: $searchbar-input-padding;
6268
border-radius: 0;
6369
font-size: $font-size-small;
@@ -105,3 +111,14 @@
105111
margin-left: 10px;
106112
}
107113
}
114+
.nut-searchbar-taro {
115+
.nut-searchbar__leftin-icon {
116+
top: 41%;
117+
}
118+
.nut-searchbar__rightin-icon {
119+
top: 41%;
120+
}
121+
.nut-searchbar__clear {
122+
top: 33%;
123+
}
124+
}

src/packages/searchbar/searchbar.taro.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import bem from '@/utils/bem'
33
import { useConfig } from '@/packages/configprovider/configprovider.taro'
44
import Icon from '@/packages/icon/index.taro'
55
import { IComponent, ComponentDefaults } from '@/utils/typings'
6+
import Taro from '@tarojs/taro'
67

78
type TIconDirection = 'in-left' | 'out-left' | 'in-right' | 'out-right'
89

@@ -297,9 +298,14 @@ export const SearchBar: FunctionComponent<
297298
}
298299
return null
299300
}
301+
302+
const envClass = () => {
303+
return Taro.getEnv() === 'WEB' ? 'nut-searchbar-taro' : ''
304+
}
305+
300306
return (
301307
<div
302-
className={`${searchbarBem()} ${
308+
className={`${searchbarBem()} ${envClass()} ${
303309
disabled ? searchbarBem('disabled') : ''
304310
} ${className || ''}`}
305311
style={{ ...props.style, background: props.background }}
@@ -308,7 +314,7 @@ export const SearchBar: FunctionComponent<
308314
{renderLabel()}
309315
<div className={`${searchbarBem('content')}`}>
310316
{renderLeftinIcon()}
311-
{renderField()}
317+
<div className="nut-searchbar__input-box">{renderField()}</div>
312318
{renderRightinIcon()}
313319
{clearable && value && handleClear()}
314320
</div>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"appid": "wx6b455a756cd0a489",
3+
"compileType": "miniprogram",
4+
"libVersion": "2.27.0",
5+
"packOptions": {
6+
"ignore": [],
7+
"include": []
8+
},
9+
"setting": {
10+
"coverView": true,
11+
"es6": true,
12+
"postcss": true,
13+
"minified": true,
14+
"enhance": true,
15+
"showShadowRootInWxmlPanel": true,
16+
"packNpmRelationList": [],
17+
"babelSetting": {
18+
"ignore": [],
19+
"disablePlugins": [],
20+
"outputPath": ""
21+
}
22+
},
23+
"condition": {},
24+
"editorSetting": {
25+
"tabIndent": "insertSpaces",
26+
"tabSize": 2
27+
}
28+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
3+
"projectname": "mobile",
4+
"setting": {
5+
"compileHotReLoad": true
6+
}
7+
}

0 commit comments

Comments
 (0)