Skip to content

Commit b56786b

Browse files
author
Muyouz
committed
fix(components-react): picker 全屏蒙层主题命中与可配置颜色
overlay 增加 theme 修饰类并修正 SCSS 选择器,使 light/dark 蒙层色生效;移除主题块内无效的 mask-overlay 嵌套;colors 新增 maskColor 覆盖蒙层背景。
1 parent fa2bf2b commit b56786b

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

‎packages/taro-components-react/src/components/picker/index.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ export interface PickerColors {
114114
backgroundColor?: string // 面板背景色
115115
lineColor?: string // 指示线条颜色
116116
titleColor?: string // 标题颜色
117+
/** 全屏点击蒙层背景色;不设则随 theme 使用默认浅色/深色蒙层 */
118+
maskColor?: string
117119
}
118120

119121
export interface PickerDate {
@@ -921,6 +923,7 @@ const Picker = React.forwardRef<PickerRef, IProps>((props, ref) => {
921923
})
922924
const backgroundStyle = colors.backgroundColor ? { backgroundColor: colors.backgroundColor } : null
923925
const titleStyle = colors.titleColor ? { color: colors.titleColor } : null
926+
const maskOverlayStyle = colors.maskColor ? { backgroundColor: colors.maskColor } : undefined
924927

925928
// 暴露方法给外部
926929
React.useImperativeHandle(ref, () => ({
@@ -941,8 +944,8 @@ const Picker = React.forwardRef<PickerRef, IProps>((props, ref) => {
941944
{children}
942945
</View>
943946
{!state.hidden && (
944-
<View className="taro-picker__overlay">
945-
<View className={clsMask} onClick={handleCancel} />
947+
<View className={classNames('taro-picker__overlay', `taro-picker__overlay--theme-${theme}`)}>
948+
<View className={clsMask} style={maskOverlayStyle} onClick={handleCancel} />
946949
<View className={clsSlider} {...(backgroundStyle ? { style: backgroundStyle } : {})}>
947950
<View className="taro-picker__hd" {...(backgroundStyle ? { style: backgroundStyle } : {})}>
948951
<View

‎packages/taro-components-react/src/components/picker/style/index.scss‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424
z-index: $weuiPickerZIndexMask;
2525
}
2626

27+
// 全屏蒙层颜色:mask 与 taro-picker-theme-* 面板为兄弟节点,由 overlay 主题修饰类命中
28+
.taro-picker__overlay.taro-picker__overlay--theme-light .taro-picker__mask-overlay {
29+
background-color: $weuiMaskColorLight;
30+
}
31+
32+
.taro-picker__overlay.taro-picker__overlay--theme-dark .taro-picker__mask-overlay {
33+
background-color: $weuiMaskColorDark;
34+
}
35+
2736
.taro-picker {
2837
position: absolute;
2938
bottom: 0;
@@ -88,10 +97,6 @@
8897
.taro-picker-theme-light {
8998
background-color: $weuiLineColorLight;
9099

91-
.taro-picker__mask-overlay {
92-
background-color: $weuiMaskColorLight;
93-
}
94-
95100
.taro-picker__hd {
96101
background-color: $weuiBackgroundColorLight;
97102

@@ -151,10 +156,6 @@
151156
.taro-picker-theme-dark {
152157
background-color: $weuiLineColorDark;
153158

154-
.taro-picker__mask-overlay {
155-
background-color: $weuiMaskColorDark;
156-
}
157-
158159
.taro-picker__hd {
159160
background-color: $weuiBackgroundColorDark;
160161

0 commit comments

Comments
 (0)