Skip to content

Commit

Permalink
feat: 完善 tabs 组件
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyh2001 committed Jul 28, 2023
1 parent 829e393 commit d953cfb
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
32 changes: 22 additions & 10 deletions packages/fighting-design/tabs/src/tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,32 @@

<template>
<div role="tab" :class="classList" :style="styleList">
<!-- 标签列表 -->
<div class="f-tabs__navs">
<div
v-for="(item, index) in children"
:key="index"
:class="['f-tabs__nav-item', { 'f-tabs__nav-active': item.name === activeName }]"
@[trigger]="changeNavs(item.name)"
>
{{ item.label }}
<!-- 头部内容 -->
<div class="f-tabs__head">
<!-- 前缀插槽 -->
<slot v-if="$slots.prefix" name="prefix" />

<!-- 标签列表 -->
<div class="f-tabs__navs">
<div
v-for="(item, index) in children"
:key="index"
:class="[
'f-tabs__nav-item',
{ 'f-tabs__nav-active': item.name === activeName }
]"
@[trigger]="changeNavs(item.name)"
>
{{ item.label }}
</div>
</div>

<!-- 后缀插槽 -->
<slot v-if="$slots.suffix" name="suffix" />
</div>

<!-- 主要展示的内容 -->
<div class="f-tabs__content">
<div class="f-tabs__body">
<slot />
</div>
</div>
Expand Down
13 changes: 12 additions & 1 deletion packages/fighting-theme/src/tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
display: flex;
flex-direction: column;

&__head {
display: flex;
justify-content: space-between;
align-items: center;
column-gap: 13px;

.f-tabs__navs {
width: 100%;
}
}

// 菜单栏
// 线性类型
&__line {
Expand Down Expand Up @@ -130,7 +141,7 @@
}

// 主要展示的内容
&__content {
&__body {
flex: 1;
}
}
11 changes: 8 additions & 3 deletions start/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
{{ act }}
<f-tabs
v-model="act"
position="left"
type="segment"
justify-content="flex-end"
position="top"
trigger="click"
>
<template #prefix>
<f-button type="primary">前缀</f-button>
</template>
<template #suffix>
<f-button type="primary">后缀</f-button>
</template>

<f-tabs-item label="如烟">
<p>七岁的那一年,抓住那只蝉,以为能抓住夏天;</p>
<!-- <p>十七岁的那年,吻过他的脸,就以为和他能永远。</p> -->
Expand Down

0 comments on commit d953cfb

Please sign in to comment.