fix(nav-bar): fix --nav-bar-icon-color not work & fix wrong style without title (#3643)

fix #3593, fix #3514
This commit is contained in:
rex 2020-09-27 11:42:28 +08:00 committed by GitHub
parent 02ea9f6a80
commit 0e784e227f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 19 deletions

View File

@ -294,10 +294,11 @@
@loading-spinner-animation-duration: 0.8s; @loading-spinner-animation-duration: 0.8s;
// NavBar // NavBar
@nav-bar-height: 44px; @nav-bar-height: 46px;
@nav-bar-background-color: @white; @nav-bar-background-color: @white;
@nav-bar-text-color: @blue;
@nav-bar-arrow-size: 16px; @nav-bar-arrow-size: 16px;
@nav-bar-icon-color: @blue;
@nav-bar-text-color: @blue;
@nav-bar-title-font-size: @font-size-lg; @nav-bar-title-font-size: @font-size-lg;
@nav-bar-title-text-color: @text-color; @nav-bar-title-text-color: @text-color;

View File

@ -11,6 +11,7 @@
&__content { &__content {
position: relative; position: relative;
height: 100%;
} }
&__text { &__text {
@ -27,8 +28,8 @@
&__arrow { &__arrow {
vertical-align: middle; vertical-align: middle;
.theme(font-size, '@nav-bar-arrow-size'); .theme(font-size, '@nav-bar-arrow-size') !important;
.theme(color, '@nav-bar-text-color'); .theme(color, '@nav-bar-icon-color') !important;
+ .van-nav-bar__text { + .van-nav-bar__text {
margin-left: -20px; margin-left: -20px;

View File

@ -1,5 +1,5 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { getSystemInfoSync } from '../common/utils'; import { getRect, getSystemInfoSync } from '../common/utils';
VantComponent({ VantComponent({
classes: ['title-class'], classes: ['title-class'],
@ -33,20 +33,15 @@ VantComponent({
}, },
data: { data: {
statusBarHeight: 0, height: 46,
height: 44,
baseStyle: '',
}, },
created() { created() {
const { statusBarHeight } = getSystemInfoSync(); const { statusBarHeight } = getSystemInfoSync();
const { safeAreaInsetTop, zIndex } = this.data;
const paddingTop = safeAreaInsetTop ? statusBarHeight : 0;
const baseStyle = `z-index: ${zIndex};padding-top: ${paddingTop}px;`;
this.setData({ this.setData({
statusBarHeight, statusBarHeight,
height: 44 + statusBarHeight, height: 46 + statusBarHeight,
baseStyle,
}); });
}, },
@ -69,11 +64,9 @@ VantComponent({
} }
wx.nextTick(() => { wx.nextTick(() => {
this.getRect('.van-nav-bar').then( getRect.call(this, '.van-nav-bar').then((res) => {
(res: WechatMiniprogram.BoundingClientRectCallbackResult) => { this.setData({ height: res.height });
this.setData({ height: res.height }); });
}
);
}); });
}, },
}, },

View File

@ -1,10 +1,11 @@
<wxs src="../wxs/utils.wxs" module="utils" /> <wxs src="../wxs/utils.wxs" module="utils" />
<wxs src="./index.wxs" module="computed" />
<view wx:if="{{ fixed && placeholder }}" style="height: {{ height }}px;" /> <view wx:if="{{ fixed && placeholder }}" style="height: {{ height }}px;" />
<view <view
class="{{ utils.bem('nav-bar', { fixed }) }} custom-class {{ border ? 'van-hairline--bottom' : '' }}" class="{{ utils.bem('nav-bar', { fixed }) }} custom-class {{ border ? 'van-hairline--bottom' : '' }}"
style="{{ baseStyle }}; {{ customStyle }}" style="{{ computed.barStyle({ zIndex, statusBarHeight, safeAreaInsetTop }) }}; {{ customStyle }}"
> >
<view class="van-nav-bar__content"> <view class="van-nav-bar__content">
<view class="van-nav-bar__left" bind:tap="onClickLeft"> <view class="van-nav-bar__left" bind:tap="onClickLeft">

View File

@ -0,0 +1,17 @@
/* eslint-disable */
function barStyle(data) {
var styles = [
['z-index', data.zIndex],
['padding-top', data.safeAreaInsetTop ? data.statusBarHeight + 'px' : 0],
];
return styles
.map(function (item) {
return item.join(':');
})
.join(';');
}
module.exports = {
barStyle: barStyle,
};