-
Notifications
You must be signed in to change notification settings - Fork 287
feat(Tabbar): v15 样式适配;增加 icon/value/title 的function类型,支持根据active状态渲染不同数据;增加 onDoubleClick 事件 #3110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
42e6f34
feat: v15 样式适配
xiaoyatong 7ccd1bf
docs: update
xiaoyatong 74b4bae
feat: add new feature
xiaoyatong 98addad
test: fixed
xiaoyatong 1ea27bb
feat: 调整icon和title的类型,支持function处理,增加双击事件
xiaoyatong be79626
docs: 修改doc
xiaoyatong 016df07
feat: 增加3个和2个的情况,及样式处理
xiaoyatong 2f67c0b
fix: 使用 safearea 组件
xiaoyatong 008d41d
perf: 优化渲染代码
xiaoyatong b1b4b2c
fix: 鸿蒙icon样式无法继承,特作支持
xiaoyatong b422416
fix: 鸿蒙基本可用
xiaoyatong 19a978f
fix: 删掉无用代码
xiaoyatong bcdad5b
fix: v15 样式
xiaoyatong 66acc78
test: fixed
xiaoyatong 676f7ba
fix: fix cr
xiaoyatong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
src/packages/tabbar/__tests__/__snapshots__/tabbar.spec.tsx.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
|
||
| exports[`should only render title 1`] = `"<div class="nut-tabbar"><div class="nut-tabbar-wrap"><div class="nut-tabbar-item nut-tabbar-item-active" style="color: blue;"><div class="nut-badge"><div class="nut-tabbar-item-icon-box nut-tabbar-item-icon-box-nav nut-tabbar-item-icon-box-large">首页</div><div class="nut-badge-sup nut-badge-number nut-badge-content" style="top: 0px; right: 0px;">11</div></div></div><div class="nut-tabbar-item" style="color: grey;"><div class="nut-badge"><div class="nut-tabbar-item-icon-box nut-tabbar-item-icon-box-nav nut-tabbar-item-icon-box-large">分类</div></div></div><div class="nut-tabbar-item" style="color: grey;"><div class="nut-badge"><div class="nut-tabbar-item-icon-box nut-tabbar-item-icon-box-nav nut-tabbar-item-icon-box-large">逛</div></div></div></div></div>"`; | ||
| exports[`should only render title 1`] = `"<div class="nut-tabbar"><div class="nut-tabbar-wrap"><div class="nut-tabbar-item nut-tabbar-item-active nut-tabbar-item-large" style="color: blue;"><div class="nut-badge"><div class="nut-tabbar-item-text">首页</div><div class="nut-badge-sup nut-badge-number nut-badge-content" style="top: 0px; right: 0px;">11</div></div></div><div class="nut-tabbar-item nut-tabbar-item-large" style="color: grey;"><div class="nut-badge"><div class="nut-tabbar-item-text">分类</div></div></div><div class="nut-tabbar-item nut-tabbar-item-large" style="color: grey;"><div class="nut-badge"><div class="nut-tabbar-item-text">逛</div></div></div></div></div>"`; | ||
|
|
||
| exports[`should render fixed element when using bottom prop 1`] = `"<div class="nut-tabbar nut-tabbar-fixed"><div class="nut-tabbar-wrap"><div class="nut-tabbar-item nut-tabbar-item-active"><div class="nut-badge"><div class="nut-tabbar-item-icon-box"><svg class="nut-icon nut-icon-Home " style="width: 20px; height: 20px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" aria-labelledby="Home" role="presentation"><path d="M.209 17.059 24 0l23.79 17.065a.5.5 0 0 1 .209.407v2.46a.5.5 0 0 1-.791.407l-2.208-1.584v19.242a8 8 0 0 1-8 8H11a8 8 0 0 1-8-8V18.749L.79 20.333A.5.5 0 0 1 0 19.926v-2.46a.5.5 0 0 1 .209-.407M24 3.692 6 16.598v21.399a5 5 0 0 0 5.001 5h26a5 5 0 0 0 5-5V16.603zm-4.939 21.447a.527.527 0 0 0-.718.011l-1.415 1.414a.481.481 0 0 0 .01.7c3.998 3.64 10.127 3.64 14.124 0a.482.482 0 0 0 .009-.7l-1.415-1.414a.527.527 0 0 0-.719-.011 7.501 7.501 0 0 1-9.876 0" fill="currentColor"></path></svg></div></div><div class="nut-tabbar-item-icon-box nut-tabbar-item-icon-box-nav">首页</div></div><div class="nut-tabbar-item"><div class="nut-badge"><div class="nut-tabbar-item-icon-box"><svg class="nut-icon nut-icon-Category " style="width: 20px; height: 20px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-labelledby="Category" role="presentation"><path d="M85.33 138.67V96c0-5.97 4.69-10.67 10.67-10.67h832c5.97 0 10.67 4.69 10.67 10.67v42.67c0 5.97-4.69 10.67-10.67 10.66H96c-5.97 0-10.67-4.69-10.67-10.66m0 394.66v-42.66C85.33 484.7 90.02 480 96 480h832c5.97 0 10.67 4.69 10.67 10.67v42.66c0 5.97-4.69 10.67-10.67 10.67H96c-5.97 0-10.67-4.69-10.67-10.67M928 874.67c5.97 0 10.67 4.69 10.67 10.66V928c0 5.97-4.69 10.67-10.67 10.67H96c-5.97 0-10.67-4.69-10.67-10.67v-42.67c0-5.97 4.69-10.67 10.67-10.66z" fill="currentColor"></path></svg></div></div><div class="nut-tabbar-item-icon-box nut-tabbar-item-icon-box-nav">分类</div></div></div><div class="nut-tabbar-safe-area"></div></div>"`; | ||
| exports[`should render fixed element when using bottom prop 1`] = `"<div class="nut-tabbar nut-tabbar-fixed"><div class="nut-tabbar-wrap"><div class="nut-tabbar-item nut-tabbar-item-active"><div class="nut-badge"><svg class="nut-icon nut-icon-Home " style="width: 20px; height: 20px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" aria-labelledby="Home" role="presentation"><path d="M.209 17.059 24 0l23.79 17.065a.5.5 0 0 1 .209.407v2.46a.5.5 0 0 1-.791.407l-2.208-1.584v19.242a8 8 0 0 1-8 8H11a8 8 0 0 1-8-8V18.749L.79 20.333A.5.5 0 0 1 0 19.926v-2.46a.5.5 0 0 1 .209-.407M24 3.692 6 16.598v21.399a5 5 0 0 0 5.001 5h26a5 5 0 0 0 5-5V16.603zm-4.939 21.447a.527.527 0 0 0-.718.011l-1.415 1.414a.481.481 0 0 0 .01.7c3.998 3.64 10.127 3.64 14.124 0a.482.482 0 0 0 .009-.7l-1.415-1.414a.527.527 0 0 0-.719-.011 7.501 7.501 0 0 1-9.876 0" fill="currentColor"></path></svg></div><div class="nut-tabbar-item-text">首页</div></div><div class="nut-tabbar-item"><div class="nut-badge"><svg class="nut-icon nut-icon-Category " style="width: 20px; height: 20px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" aria-labelledby="Category" role="presentation"><path d="M85.33 138.67V96c0-5.97 4.69-10.67 10.67-10.67h832c5.97 0 10.67 4.69 10.67 10.67v42.67c0 5.97-4.69 10.67-10.67 10.66H96c-5.97 0-10.67-4.69-10.67-10.66m0 394.66v-42.66C85.33 484.7 90.02 480 96 480h832c5.97 0 10.67 4.69 10.67 10.67v42.66c0 5.97-4.69 10.67-10.67 10.67H96c-5.97 0-10.67-4.69-10.67-10.67M928 874.67c5.97 0 10.67 4.69 10.67 10.66V928c0 5.97-4.69 10.67-10.67 10.67H96c-5.97 0-10.67-4.69-10.67-10.67v-42.67c0-5.97 4.69-10.67 10.67-10.66z" fill="currentColor"></path></svg></div><div class="nut-tabbar-item-text">分类</div></div></div><div class="nut-tabbar-safe-area"></div></div>"`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,18 @@ | ||
| import React from 'react' | ||
| import { Tabbar } from '@nutui/nutui-react' | ||
| import { Cart, Category, Hi, Home, User } from '@nutui/icons-react' | ||
| import { Cart, Hi, Home, User, Heart, HeartFill } from '@nutui/icons-react' | ||
|
|
||
| const Demo1 = () => ( | ||
| <Tabbar defaultValue={0}> | ||
| <Tabbar.Item title="首页" icon={<Home />} value={9} /> | ||
| <Tabbar.Item title="分类" icon={<Category />} dot /> | ||
| const Demo = () => ( | ||
| <Tabbar> | ||
| <Tabbar.Item title="首页" icon={<Home />} /> | ||
| <Tabbar.Item title="逛" icon={<Hi />} /> | ||
| <Tabbar.Item | ||
| title="收藏" | ||
| icon={(active: boolean) => (active ? <HeartFill /> : <Heart />)} | ||
| /> | ||
| <Tabbar.Item title="购物车" icon={<Cart />} /> | ||
| <Tabbar.Item title="我的" icon={<User />} /> | ||
| </Tabbar> | ||
| ) | ||
|
|
||
| export default Demo1 | ||
| export default Demo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,15 @@ | ||
| import React, { useState } from 'react' | ||
| import React from 'react' | ||
| import { Tabbar } from '@nutui/nutui-react' | ||
| import { Cart, Category, Hi, Home, User } from '@nutui/icons-react' | ||
| import { Cart, Message, Hi, Home, User } from '@nutui/icons-react' | ||
|
|
||
| const Demo2 = () => { | ||
| const [activeIndex, setActiveIndex] = useState(2) | ||
| const Demo = () => ( | ||
| <Tabbar> | ||
| <Tabbar.Item title="首页" icon={<Home />} dot /> | ||
| <Tabbar.Item title="逛" icon={<Hi />} value="内容" /> | ||
| <Tabbar.Item title="消息" icon={<Message />} value={100} /> | ||
| <Tabbar.Item title="购物车" icon={<Cart />} value={80} /> | ||
| <Tabbar.Item title="我的" icon={<User />} value={8} /> | ||
| </Tabbar> | ||
| ) | ||
|
|
||
| return ( | ||
| <Tabbar | ||
| defaultValue={0} | ||
| value={activeIndex} | ||
| onSwitch={(value) => { | ||
| setActiveIndex(value) | ||
| }} | ||
| > | ||
| <Tabbar.Item title="首页" icon={<Home />} /> | ||
| <Tabbar.Item title="分类" icon={<Category />} /> | ||
| <Tabbar.Item title="逛" icon={<Hi />} /> | ||
| <Tabbar.Item title="购物车" icon={<Cart />} /> | ||
| <Tabbar.Item title="我的" icon={<User />} /> | ||
| </Tabbar> | ||
| ) | ||
| } | ||
|
|
||
| export default Demo2 | ||
| export default Demo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,14 @@ | ||
| import React from 'react' | ||
| import { Tabbar } from '@nutui/nutui-react' | ||
| import { Cart, Category, Hi, Home, User } from '@nutui/icons-react' | ||
| import { Cart, Message, Hi, Home, User } from '@nutui/icons-react' | ||
|
|
||
| const Demo3 = () => ( | ||
| <Tabbar | ||
| onSwitch={(value) => { | ||
| console.log(value) | ||
| }} | ||
| > | ||
| const Demo = () => ( | ||
| <Tabbar> | ||
| <Tabbar.Item icon={<Home width={24} height={24} />} /> | ||
| <Tabbar.Item icon={<Category width={24} height={24} />} /> | ||
| <Tabbar.Item icon={<Hi width={24} height={24} />} /> | ||
| <Tabbar.Item icon={<Message width={24} height={24} />} /> | ||
| <Tabbar.Item icon={<Cart width={24} height={24} />} /> | ||
| <Tabbar.Item icon={<User width={24} height={24} />} /> | ||
| </Tabbar> | ||
| ) | ||
| export default Demo3 | ||
| export default Demo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,13 @@ | ||
| import React from 'react' | ||
| import { Tabbar } from '@nutui/nutui-react' | ||
|
|
||
| const Demo4 = () => ( | ||
| <Tabbar | ||
| onSwitch={(value) => { | ||
| console.log(value) | ||
| }} | ||
| > | ||
| const Demo = () => ( | ||
| <Tabbar> | ||
| <Tabbar.Item title="首页" value={9} /> | ||
| <Tabbar.Item title="分类" /> | ||
| <Tabbar.Item title="逛" /> | ||
| <Tabbar.Item title="消息" /> | ||
| <Tabbar.Item title="购物车" /> | ||
| <Tabbar.Item title="我的" /> | ||
| </Tabbar> | ||
| ) | ||
| export default Demo4 | ||
| export default Demo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,37 @@ | ||
| import React from 'react' | ||
| import { Tabbar } from '@nutui/nutui-react' | ||
| import { Cart, Category, Hi, Home, User } from '@nutui/icons-react' | ||
| import { Tabbar, Image } from '@nutui/nutui-react' | ||
| import { Cart, Hi, Home, User, Message } from '@nutui/icons-react' | ||
|
|
||
| const Demo5 = () => ( | ||
| <Tabbar> | ||
| <Tabbar.Item title="首页" icon={<Home />} value={11} /> | ||
| <Tabbar.Item title="分类" icon={<Category />} /> | ||
| <Tabbar.Item title="逛" icon={<Hi />} /> | ||
| <Tabbar.Item title="购物车" icon={<Cart />} value={110} /> | ||
| <Tabbar.Item title="我的" icon={<User />} /> | ||
| </Tabbar> | ||
| ) | ||
| const Demo = () => { | ||
| return ( | ||
| <Tabbar> | ||
| <Tabbar.Item | ||
| title={(active: boolean) => (active ? '' : '首页')} | ||
| icon={(active: boolean) => | ||
| active ? ( | ||
| <Image src="https://storage.360buyimg.com/imgtools/ba40719add-025fcd20-0618-11f0-8bdb-aba55e067ea2.png" /> | ||
| ) : ( | ||
| <Home /> | ||
| ) | ||
| } | ||
| /> | ||
|
|
||
| export default Demo5 | ||
| <Tabbar.Item | ||
| icon={(active: boolean) => | ||
| active ? ( | ||
| <Hi /> | ||
| ) : ( | ||
| <Image src="https://storage.360buyimg.com/imgtools/00e365dee3-8fe58f80-0952-11f0-8d73-ab964e6901f9.png" /> | ||
| ) | ||
| } | ||
| title={(active: boolean) => (active ? '逛' : '')} | ||
| value="AI" | ||
| /> | ||
| <Tabbar.Item title="消息" icon={<Message />} value={100} /> | ||
| <Tabbar.Item title="购物车" icon={<Cart />} /> | ||
| <Tabbar.Item title="我的" icon={<User />} /> | ||
| </Tabbar> | ||
| ) | ||
| } | ||
|
|
||
| export default Demo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,29 @@ | ||
| import React from 'react' | ||
| import { Tabbar } from '@nutui/nutui-react' | ||
| import { Cart, Category, Hi, Home, User } from '@nutui/icons-react' | ||
|
|
||
| const Demo6 = () => ( | ||
| <Tabbar> | ||
| <Tabbar.Item title="首页" icon={<Home />} dot /> | ||
| <Tabbar.Item title="分类" icon={<Category />} /> | ||
| <Tabbar.Item title="逛" icon={<Hi />} /> | ||
| <Tabbar.Item title="购物车" icon={<Cart />} dot /> | ||
| <Tabbar.Item title="我的" icon={<User />} /> | ||
| </Tabbar> | ||
| import { Tabbar, Space } from '@nutui/nutui-react' | ||
| import { Cart, Home, User } from '@nutui/icons-react' | ||
|
|
||
| const Demo = () => ( | ||
| <Space direction="vertical"> | ||
| <Tabbar inactiveColor="#7d7e80" activeColor="#0073ff"> | ||
| <Tabbar.Item title="首页" icon={<Home />} /> | ||
| <Tabbar.Item title="购物车" icon={<Cart />} /> | ||
| <Tabbar.Item title="我的" icon={<User />} /> | ||
| </Tabbar> | ||
|
|
||
| <Tabbar inactiveColor="#7d7e80" activeColor="#0073ff"> | ||
| <Tabbar.Item title="首页" icon={<Home />} /> | ||
| <Tabbar.Item title="我的" icon={<User />} /> | ||
| </Tabbar> | ||
|
|
||
| <Tabbar | ||
| inactiveColor="#7d7e80" | ||
| activeColor="#0073ff" | ||
| direction="horizontal" | ||
| > | ||
| <Tabbar.Item title="我的优惠券" icon={<Home />} dot /> | ||
| <Tabbar.Item title="领券中心" icon={<User />} value={22} /> | ||
| </Tabbar> | ||
| </Space> | ||
| ) | ||
|
|
||
| export default Demo6 | ||
| export default Demo |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
英文翻译中存在拼写错误
第48行中的英文翻译 "With Controled" 存在拼写错误,应修改为 "With Controlled"(多一个'l')。
此外,英文翻译中 "Custom" 可能过于简单,无法准确表达 "首坑品牌+营销态" 的含义,建议考虑使用更具描述性的翻译,如 "Featured Brand + Marketing State"。
📝 Committable suggestion