File tree Expand file tree Collapse file tree 4 files changed +35
-5
lines changed
Expand file tree Collapse file tree 4 files changed +35
-5
lines changed Original file line number Diff line number Diff line change 353353 "author" : " hx"
354354 },
355355 {
356- "version" : " 2 .0.0" ,
356+ "version" : " 3 .0.0" ,
357357 "name" : " Tabbar" ,
358358 "type" : " component" ,
359359 "cName" : " 标签栏" ,
Original file line number Diff line number Diff line change 4242 color : $tabbar-active-color ;
4343
4444 .nut-tabbar-item-icon-box {
45+ /* #ifdef harmony*/
46+ color : $tabbar-active-color ;
47+ /* #endif*/
48+ /* #ifndef harmony*/
4549 color : inherit ;
50+ /* #endif*/
4651
4752 .nut-icon {
53+ /* #ifdef harmony*/
54+ color : $tabbar-active-color ;
55+ /* #endif*/
56+ /* #ifndef harmony*/
4857 color : inherit ;
58+ /* #endif*/
4959 }
5060 }
5161 }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { View } from '@tarojs/components'
44import { BasicComponent , ComponentDefaults } from '@/utils/typings'
55import Badge from '@/packages/badge/index.taro'
66import TabbarContext from '@/packages/tabbar/context'
7+ import addColorForHarmony from '@/utils/add-color-for-harmony'
78
89export interface TabbarItemProps extends BasicComponent {
910 title : ReactNode
@@ -83,13 +84,32 @@ export const TabbarItem: FunctionComponent<Partial<TabbarItemProps>> = (
8384 { icon ? (
8485 < >
8586 < Badge { ...badgeProps } >
86- < View className = { boxPrefix } > { icon } </ View >
87+ < View className = { boxPrefix } >
88+ { addColorForHarmony (
89+ icon ,
90+ active ? ctx ?. activeColor : ctx ?. inactiveColor
91+ ) }
92+ </ View >
8793 </ Badge >
88- < View className = { titleClass } > { title } </ View >
94+ < View
95+ className = { titleClass }
96+ style = { {
97+ color : active ? ctx ?. activeColor : ctx ?. inactiveColor ,
98+ } }
99+ >
100+ { title }
101+ </ View >
89102 </ >
90103 ) : (
91104 < Badge { ...badgeProps } >
92- < View className = { titleClass } > { title } </ View >
105+ < View
106+ className = { titleClass }
107+ style = { {
108+ color : active ? ctx ?. activeColor : ctx ?. inactiveColor ,
109+ } }
110+ >
111+ { title }
112+ </ View >
93113 </ Badge >
94114 ) }
95115 </ View >
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ interface ColorProps {
1111 * @param color - 要添加的颜色值(如:'#ff0000')
1212 * @returns 处理后的 React 节点
1313 */
14- function addColorForHarmony ( maybeElement : ReactNode , color : string ) {
14+ function addColorForHarmony ( maybeElement : ReactNode , color ? : string ) {
1515 if ( React . isValidElement ( maybeElement ) && harmony ( ) ) {
1616 return React . cloneElement < ColorProps > ( maybeElement as ReactElement , {
1717 color,
You can’t perform that action at this time.
0 commit comments