Skip to content

Commit

Permalink
fix: tabs 代码简化\修订纵向样式 (#2948)
Browse files Browse the repository at this point in the history
* fix: tabs 代码简化\修订纵向样式

* fix: tabs 代码简化\修订纵向样式
  • Loading branch information
xiaoyatong authored Jan 24, 2025
1 parent 96a4da5 commit 59bdd17
Show file tree
Hide file tree
Showing 39 changed files with 139 additions and 209 deletions.
4 changes: 1 addition & 3 deletions src/packages/tabpane/tabpane.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,5 @@ export const TabPane: FunctionComponent<
className
)

return children ? (
<View className={classes}>{!disabled && children}</View>
) : null
return children && <View className={classes}>{!disabled && children}</View>
}
4 changes: 1 addition & 3 deletions src/packages/tabpane/tabpane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,5 @@ export const TabPane: FunctionComponent<
className
)

return children ? (
<div className={classes}>{!disabled && children}</div>
) : null
return children && <div className={classes}>{!disabled && children}</div>
}
2 changes: 1 addition & 1 deletion src/packages/tabs/demos/h5/demo1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Demo1 = () => {
setTabvalue(value)
}}
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/tabs/demos/h5/demo10.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Demo10 = () => {
setTabvalue(value)
}}
>
<Tabs.TabPane title="Tab 1"> Tab 1</Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem</Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
4 changes: 2 additions & 2 deletions src/packages/tabs/demos/h5/demo11.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const Demo11 = () => {
setTabvalue(value)
}}
>
<Tabs.TabPane title="Tab 1" value="0">
Tab 1
<Tabs.TabPane title="Tab longitem" value="0">
Tab longitem
</Tabs.TabPane>
<Tabs.TabPane title="Tab 2" value="1" disabled>
Tab 2
Expand Down
4 changes: 2 additions & 2 deletions src/packages/tabs/demos/h5/demo12.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Demo12 = () => {
setTabIndex(page)
}}
>
<Tabs.TabPane title="Tab 1" />
<Tabs.TabPane title="Tab longitem" />
<Tabs.TabPane title="Tab 2" />
<Tabs.TabPane title="Tab 3" />
</Tabs>
Expand All @@ -28,7 +28,7 @@ const Demo12 = () => {
}}
>
<Swiper.Item>
<div style={style}>Tab 1</div>
<div style={style}>Tab longitem</div>
</Swiper.Item>
<Swiper.Item>
<div style={style}>Tab 2</div>
Expand Down
20 changes: 10 additions & 10 deletions src/packages/tabs/demos/h5/demo13.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ const Demo13 = () => {
setTabvalue(value)
}}
>
<Tabs.TabPane title="Tab 1" value="0">
<p>Tab 1</p>
<p>Tab 1</p>
<p>Tab 1</p>
<p>Tab 1</p>
<p>Tab 1</p>
<p>Tab 1</p>
<p>Tab 1</p>
<p>Tab 1</p>
<p>Tab 1</p>
<Tabs.TabPane title="Tab longitem" value="0">
<p>Tab longitem</p>
<p>Tab longitem</p>
<p>Tab longitem</p>
<p>Tab longitem</p>
<p>Tab longitem</p>
<p>Tab longitem</p>
<p>Tab longitem</p>
<p>Tab longitem</p>
<p>Tab longitem</p>
</Tabs.TabPane>
<Tabs.TabPane title="Tab 2" value="1">
<p>Tab 2</p>
Expand Down
10 changes: 5 additions & 5 deletions src/packages/tabs/demos/h5/demo14.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ const Demo14 = () => {
setTabvalue(value)
}}
>
<Tabs.TabPane title="Tab 1">
<p>Tab 1</p>
<p>Tab 1</p>
<p>Tab 1</p>
<p>Tab 1</p>
<Tabs.TabPane title="Tab longitem">
<p>Tab longitem</p>
<p>Tab longitem</p>
<p>Tab longitem</p>
<p>Tab longitem</p>
</Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/tabs/demos/h5/demo2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Demo2 = () => {
}}
activeType="smile"
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
4 changes: 2 additions & 2 deletions src/packages/tabs/demos/h5/demo20.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ const Demo20 = () => {
}}
direction="vertical"
>
<Tabs.TabPane title="Tab 1">
<Tabs.TabPane title="Tab longitem">
<Tabs
value={tabvalue1}
onChange={(value) => {
setTabvalue1(value)
}}
direction="horizontal"
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
4 changes: 2 additions & 2 deletions src/packages/tabs/demos/h5/demo21.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ const Demo21 = () => {
}}
autoHeight
>
<Tabs.TabPane title="Tab 1">
<Tabs.TabPane title="Tab longitem">
<Tabs
value={tabvalue1}
onChange={(value) => {
setTabvalue1(value)
}}
direction="vertical"
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
4 changes: 2 additions & 2 deletions src/packages/tabs/demos/h5/demo22.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Demo22 = () => {
}}
style={{ '--nutui-tabs-titles-font-size': '20px' }}
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand All @@ -24,7 +24,7 @@ const Demo22 = () => {
}}
style={{ '--nutui-tabs-titles-font-size': '12px' }}
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/tabs/demos/h5/demo3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Demo3 = () => {
}}
activeType="simple"
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/tabs/demos/h5/demo4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Demo4 = () => {
}}
activeType="card"
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/tabs/demos/h5/demo5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Demo5 = () => {
}}
activeType="button"
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/tabs/demos/h5/demo6.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Demo6 = () => {
}}
activeType="divider"
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/tabs/demos/h5/demo7.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Demo7 = () => {
setTabvalue(value)
}}
>
<Tabs.TabPane title="Tab 1"> Tab 1</Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem</Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/tabs/demos/h5/demo8.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Demo8 = () => {
setTabvalue(value)
}}
>
<Tabs.TabPane title="Tab 1"> Tab 1</Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem</Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/tabs/demos/h5/demo9.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Demo9 = () => {
setTabvalue(value)
}}
>
<Tabs.TabPane title="Tab 1"> Tab 1</Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem</Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/tabs/demos/taro/demo1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Demo1 = () => {
setTabvalue(value)
}}
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/tabs/demos/taro/demo10.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Demo10 = () => {
}}
align="left"
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
4 changes: 2 additions & 2 deletions src/packages/tabs/demos/taro/demo11.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const Demo11 = () => {
setTabvalue(value)
}}
>
<Tabs.TabPane title="Tab 1" value="0">
Tab 1
<Tabs.TabPane title="Tab longitem" value="0">
Tab longitem
</Tabs.TabPane>
<Tabs.TabPane title="Tab 2" value="1" disabled>
Tab 2
Expand Down
4 changes: 2 additions & 2 deletions src/packages/tabs/demos/taro/demo12.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Demo12 = () => {
setTabIndex(page)
}}
>
<Tabs.TabPane title="Tab 1" />
<Tabs.TabPane title="Tab longitem" />
<Tabs.TabPane title="Tab 2" />
<Tabs.TabPane title="Tab 3" />
</Tabs>
Expand All @@ -30,7 +30,7 @@ const Demo12 = () => {
}}
>
<Swiper.Item>
<View style={contentStyle}>Tab 1</View>
<View style={contentStyle}>Tab longitem</View>
</Swiper.Item>
<Swiper.Item>
<View style={contentStyle}>Tab 2</View>
Expand Down
4 changes: 2 additions & 2 deletions src/packages/tabs/demos/taro/demo13.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ const Demo13 = () => {
setTabvalue(value)
}}
>
<Tabs.TabPane title="Tab 1">
<Tabs.TabPane title="Tab longitem">
{Array(8)
.fill(null)
.map((_, index) => (
<View key={index}>Tab 1</View>
<View key={index}>Tab longitem</View>
))}
</Tabs.TabPane>
<Tabs.TabPane title="Tab 2">
Expand Down
4 changes: 2 additions & 2 deletions src/packages/tabs/demos/taro/demo14.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ const Demo14 = () => {
setTabvalue(value)
}}
>
<Tabs.TabPane title="Tab 1">
<Tabs.TabPane title="Tab longitem">
{Array(8)
.fill(null)
.map((_, index) => (
<View key={index}>Tab 1</View>
<View key={index}>Tab longitem</View>
))}
</Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/tabs/demos/taro/demo2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Demo2 = () => {
}}
activeType="smile"
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
4 changes: 2 additions & 2 deletions src/packages/tabs/demos/taro/demo20.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ const Demo20 = () => {
}}
direction="vertical"
>
<Tabs.TabPane title="Tab 1">
<Tabs.TabPane title="Tab longitem">
<Tabs
value={tabvalue1}
onChange={(value) => {
setTabvalue1(value)
}}
direction="horizontal"
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
4 changes: 2 additions & 2 deletions src/packages/tabs/demos/taro/demo21.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ const Demo21 = () => {
}}
autoHeight
>
<Tabs.TabPane title="Tab 1">
<Tabs.TabPane title="Tab longitem">
<Tabs
value={tabvalue1}
onChange={(value) => {
setTabvalue1(value)
}}
direction="vertical"
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
4 changes: 2 additions & 2 deletions src/packages/tabs/demos/taro/demo22.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Demo22 = () => {
}}
style={{ '--nutui-tabs-titles-font-size': '20px' }}
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand All @@ -24,7 +24,7 @@ const Demo22 = () => {
}}
style={{ '--nutui-tabs-titles-font-size': '12px' }}
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/tabs/demos/taro/demo3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Demo3 = () => {
}}
activeType="simple"
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/tabs/demos/taro/demo4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Demo4 = () => {
}}
activeType="card"
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/tabs/demos/taro/demo5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Demo5 = () => {
}}
activeType="button"
>
<Tabs.TabPane title="Tab 1"> Tab 1 </Tabs.TabPane>
<Tabs.TabPane title="Tab longitem"> Tab longitem </Tabs.TabPane>
<Tabs.TabPane title="Tab 2"> Tab 2 </Tabs.TabPane>
<Tabs.TabPane title="Tab 3"> Tab 3 </Tabs.TabPane>
</Tabs>
Expand Down
Loading

0 comments on commit 59bdd17

Please sign in to comment.