-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor(tabBar): update api * refactor(tabBar): finish (#633) * fix(tabBar): fix ts type error (#633) * fix(tabBar): update snap (#633) * fix(tabBar): update font-size and snap (#633)
- Loading branch information
Showing
18 changed files
with
1,684 additions
and
643 deletions.
There are no files selected for viewing
1,772 changes: 1,286 additions & 486 deletions
1,772
src/tab-bar/__test__/__snapshots__/demo.test.jsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 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,33 +1,29 @@ | ||
<template> | ||
<t-tab-bar v-model="value" @change="change"> | ||
<t-tab-bar-item v-for="(item, i) in list" :key="item.name || i" :value="item.name" :badge-props="item.badgeProps"> | ||
<t-tab-bar v-model="value" :split="false"> | ||
<t-tab-bar-item | ||
v-for="item in list" | ||
:key="item.name" | ||
:value="item.name" | ||
:badge-props="item.badgeProps" | ||
:aria-label="item.ariaLabel" | ||
> | ||
{{ item.text }} | ||
<template #icon> | ||
<icon :name="item.icon" /> | ||
<t-icon :name="item.icon" /> | ||
</template> | ||
</t-tab-bar-item> | ||
</t-tab-bar> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref, watch } from 'vue'; | ||
import { Icon } from 'tdesign-icons-vue-next'; | ||
import { ref } from 'vue'; | ||
import { Icon as TIcon } from 'tdesign-icons-vue-next'; | ||
const value = ref('label_1'); | ||
const list = ref([ | ||
{ name: 'label_1', text: '文字', icon: 'app', badgeProps: { count: 16 } }, | ||
{ name: 'label_2', text: '文字', icon: 'app', badgeProps: { dot: true } }, | ||
{ name: 'label_3', text: '文字', icon: 'app', badgeProps: { count: 'New' } }, | ||
{ name: 'label_4', text: '文字', icon: 'app', badgeProps: { count: '···' } }, | ||
{ name: 'label_1', text: '首页', icon: 'home', badgeProps: { count: 16 }, ariaLabel: '首页,有16条消息' }, | ||
{ name: 'label_2', text: '软件', icon: 'app', badgeProps: { dot: true }, ariaLabel: '软件,有新的消息' }, | ||
{ name: 'label_3', text: '聊天', icon: 'chat', badgeProps: { count: 'New' }, ariaLabel: '聊天,New' }, | ||
{ name: 'label_4', text: '我的', icon: 'user', badgeProps: { count: '···' }, ariaLabel: '我的,有很多消息' }, | ||
]); | ||
watch( | ||
() => value.value, | ||
(newValue) => { | ||
console.log('当前值改变为:', newValue); | ||
}, | ||
); | ||
const change = (changeValue: number | string) => { | ||
console.log('TabBar 值改变为:', changeValue); | ||
}; | ||
</script> |
This file contains 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,33 +1,23 @@ | ||
<template> | ||
<t-tab-bar v-model="value" @change="change"> | ||
<t-tab-bar-item v-for="(item, i) in list" :key="item.name || i" :value="item.name"> | ||
{{ item.text }} | ||
<t-tab-bar v-model="value" theme="tag" :split="false"> | ||
<t-tab-bar-item v-for="item in list" :key="item.value" :value="item.value"> | ||
{{ item.label }} | ||
<template #icon> | ||
<icon :name="item.icon" /> | ||
<t-icon :name="item.icon" /> | ||
</template> | ||
</t-tab-bar-item> | ||
</t-tab-bar> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref, watch } from 'vue'; | ||
import { Icon } from 'tdesign-icons-vue-next'; | ||
import { ref } from 'vue'; | ||
import { Icon as TIcon } from 'tdesign-icons-vue-next'; | ||
const value = ref('label_1'); | ||
const list = ref([ | ||
{ name: 'label_1', text: '文字', icon: 'app' }, | ||
{ name: 'label_2', text: '文字', icon: 'app' }, | ||
{ name: 'label_3', text: '文字', icon: 'app' }, | ||
{ name: 'label_4', text: '文字', icon: 'app' }, | ||
{ value: 'label_1', label: '首页', icon: 'home' }, | ||
{ value: 'label_2', label: '应用', icon: 'app' }, | ||
{ value: 'label_3', label: '聊天', icon: 'chat' }, | ||
{ value: 'label_4', label: '我的', icon: 'user' }, | ||
]); | ||
watch( | ||
() => value.value, | ||
(newValue) => { | ||
console.log('当前值改变为:', newValue); | ||
}, | ||
); | ||
const change = (changeValue: number | string) => { | ||
console.log('TabBar 值改变为:', changeValue); | ||
}; | ||
</script> |
This file contains 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<template> | ||
<t-tab-bar v-model="value" class="wrapper"> | ||
<t-tab-bar-item v-for="item in list" :key="item.value" :value="item.value"> | ||
<template #icon> | ||
<t-icon :name="item.icon" /> | ||
</template> | ||
</t-tab-bar-item> | ||
</t-tab-bar> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
import { Icon as TIcon } from 'tdesign-icons-vue-next'; | ||
const value = ref('label_1'); | ||
const list = ref([ | ||
{ value: 'label_1', label: '首页', icon: 'home' }, | ||
{ value: 'label_2', label: '应用', icon: 'app' }, | ||
{ value: 'label_3', label: '聊天', icon: 'chat' }, | ||
{ value: 'label_4', label: '我的', icon: 'user' }, | ||
]); | ||
</script> | ||
|
||
<style lang="less" scoped> | ||
.wrapper { | ||
--td-tab-bar-border-color: #e7e7e7; | ||
--td-tab-bar-bg-color: #eee; | ||
--td-tab-bar-hover-color: #ddd; | ||
--td-tab-bar-item-color: #bbb; | ||
--td-tab-bar-item-active-color: #333; | ||
} | ||
</style> |
This file contains 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 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,27 +1,22 @@ | ||
<template> | ||
<t-tab-bar v-model="value" @change="change"> | ||
<t-tab-bar-item v-for="(item, i) in list" :key="item.name || i" :value="item.name"> | ||
<t-tab-bar v-model="value" theme="tag" :split="false"> | ||
<t-tab-bar-item v-for="item in list" :key="item.value" :value="item.value"> | ||
<template #icon> | ||
<app-icon /> | ||
<t-icon :name="item.icon" /> | ||
</template> | ||
</t-tab-bar-item> | ||
</t-tab-bar> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref, watch } from 'vue'; | ||
import { AppIcon } from 'tdesign-icons-vue-next'; | ||
import { ref } from 'vue'; | ||
import { Icon as TIcon } from 'tdesign-icons-vue-next'; | ||
const value = ref('label_1'); | ||
const list = ref([{ name: 'label_1' }, { name: 'label_2' }, { name: 'label_3' }, { name: 'label_4' }]); | ||
watch( | ||
() => value.value, | ||
(newValue) => { | ||
console.log('当前值改变为:', newValue); | ||
}, | ||
); | ||
const change = (changeValue: number | string) => { | ||
console.log('TabBar 值改变为:', changeValue); | ||
}; | ||
const list = ref([ | ||
{ value: 'label_1', icon: 'home', ariaLabel: '首页' }, | ||
{ value: 'label_2', icon: 'app', ariaLabel: '软件' }, | ||
{ value: 'label_3', icon: 'chat', ariaLabel: '聊天' }, | ||
{ value: 'label_4', icon: 'user', ariaLabel: '我的' }, | ||
]); | ||
</script> |
This file contains 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<template> | ||
<t-tab-bar v-model="value" shape="round" theme="tag" :split="false"> | ||
<t-tab-bar-item v-for="item in list" :key="item.value" :value="item.value"> | ||
<template #icon> | ||
<t-icon :name="item.icon" /> | ||
</template> | ||
</t-tab-bar-item> | ||
</t-tab-bar> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
import { Icon as TIcon } from 'tdesign-icons-vue-next'; | ||
const value = ref('label_1'); | ||
const list = ref([ | ||
{ value: 'label_1', label: '首页', icon: 'home' }, | ||
{ value: 'label_2', label: '应用', icon: 'app' }, | ||
{ value: 'label_3', label: '聊天', icon: 'chat' }, | ||
{ value: 'label_4', label: '我的', icon: 'user' }, | ||
]); | ||
</script> |
This file contains 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,43 +1,46 @@ | ||
<template> | ||
<t-tab-bar default-value="label_3"> | ||
<t-tab-bar-item | ||
v-for="(item, index) in list" | ||
:key="item.name || index" | ||
:value="item.name" | ||
:sub-tab-bar="item.children" | ||
> | ||
{{ item.text }} | ||
<t-tab-bar default-value="home" theme="tag" :split="false" @change="change"> | ||
<t-tab-bar-item v-for="item in list" :key="item.value" :value="item.value" :sub-tab-bar="item.children"> | ||
{{ item.label }} | ||
</t-tab-bar-item> | ||
</t-tab-bar> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
const list = [ | ||
{ | ||
name: 'label_1', | ||
text: '标签栏一', | ||
value: 'home', | ||
label: '首页', | ||
icon: 'home', | ||
children: [], | ||
}, | ||
{ | ||
name: 'label_2', | ||
text: '标签栏二', | ||
value: 'app', | ||
label: '应用', | ||
icon: 'app', | ||
children: [], | ||
}, | ||
{ | ||
name: 'label_3', | ||
text: '此处展开', | ||
value: 'user', | ||
label: '我的', | ||
children: [ | ||
{ | ||
value: 'spread_3', | ||
label: '展开项三', | ||
value: 'info', | ||
label: '基本信息', | ||
}, | ||
{ | ||
value: 'spread_2', | ||
label: '展开项二', | ||
value: 'home-page', | ||
label: '个人主页', | ||
}, | ||
{ | ||
value: 'spread_1', | ||
label: '展开项一', | ||
value: 'setting', | ||
label: '设置', | ||
}, | ||
], | ||
}, | ||
]; | ||
const change = (changeValue: number | string) => { | ||
console.log('TabBar 值改变为:', changeValue); | ||
}; | ||
</script> |
This file contains 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
Oops, something went wrong.