Skip to content

Commit

Permalink
feat(comp:tabs): supoort dataSource, removable, onAdd
Browse files Browse the repository at this point in the history
  • Loading branch information
danranVm committed Apr 15, 2023
1 parent e323867 commit 907fd37
Show file tree
Hide file tree
Showing 43 changed files with 828 additions and 768 deletions.
1 change: 1 addition & 0 deletions packages/cdk/resize/demo/Basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const textareaRef = ref()
const text = ref('')
useResizeObserver(textareaRef, entry => {
console.log(entry)
const { contentRect } = entry
text.value = `height: ${contentRect.height}`
})
Expand Down
2 changes: 1 addition & 1 deletion packages/components/alert/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

&-icon,
&-close-icon {
font-size: var(--ix-font-size-icon);
font-size: var(--ix-font-size-lg);
}

&-content {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
@button-ghost-background-color-disabled: rgba(255, 255, 255, 0.4);

@button-icon-color: inherit;
@button-icon-font-size: var(--ix-font-size-icon);
@button-icon-font-size: var(--ix-font-size-lg);
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@

@header-description-color: var(--ix-text-color-info);

@header-icon-font-size: var(--ix-font-size-icon);
@header-icon-font-size: var(--ix-font-size-lg);
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@popconfirm-border-radius: var(--ix-border-radius-md);
@popconfirm-box-shadow: @shadow-bottom-md;

@popconfirm-icon-size: var(--ix-font-size-icon);
@popconfirm-icon-size: var(--ix-font-size-lg);
@popconfirm-icon-color: var(--ix-color-brown);

@popconfirm-title-font-size: var(--ix-font-size-md);
Expand Down
1 change: 0 additions & 1 deletion packages/components/select/src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export default defineComponent({
})

const handleOptionClick = (option: SelectData) => {
console.log('handleOptionClick', option)
changeSelected(getKey.value(option))
props.allowInput && clearInput()
if (!props.multiple) {
Expand Down
1 change: 0 additions & 1 deletion packages/components/style/themes/default.less
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
--ix-font-size-xl: 20px;
--ix-font-size-2xl: 24px;
--ix-font-size-3xl: 30px;
--ix-font-size-icon: 16px;

// Font-Weight
--ix-font-weight-xs: 200;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ exports[`Tabs > render work 1`] = `
"<div class=\\"ix-tabs ix-tabs-md ix-tabs-card ix-tabs-nav-top\\">
<div class=\\"ix-tabs-nav-wrapper\\">
<!---->
<div class=\\"ix-tabs-nav\\"></div>
<div class=\\"ix-tabs-nav\\" style=\\"transform: translateX(-0px);\\">
<!---->
</div>
<!---->
<div class=\\"ix-tabs-nav-border\\"></div>
<!---->
Expand Down
2 changes: 1 addition & 1 deletion packages/components/tabs/__tests__/tabs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { h } from 'vue'

import { renderWork, wait } from '@tests'

import Tab from '../src/Tab'
import Tabs from '../src/Tabs'
import { Tab } from '../src/tab'
import { TabsProps } from '../src/types'

const defaultSlots = [
Expand Down
12 changes: 5 additions & 7 deletions packages/components/tabs/demo/Card.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<template>
<IxTabs v-model:selectedKey="selectedKey">
<IxTab key="tab1" title="Tab 1"> Content of Tab 1 </IxTab>
<IxTab key="tab2" title="Tab 2"> Content of Tab 2 </IxTab>
<IxTab key="tab3" title="Tab 3"> Content of Tab 3 </IxTab>
<IxTabs :dataSource="dataSource">
<template #content="{ key }"> Content of Tab {{ key }} </template>
</IxTabs>
</template>

<script setup lang="ts">
import { ref } from 'vue'
const selectedKey = ref('tab1')
const dataSource = Array.from({ length: 3 }).map((_, index) => {
return { key: index, title: `Tab ${index}` }
})
</script>
2 changes: 1 addition & 1 deletion packages/components/tabs/demo/CustomTab.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title:
zh: 自定义标签
en: Custom tab
order: 5
order: 12
---

## zh
Expand Down
47 changes: 24 additions & 23 deletions packages/components/tabs/demo/CustomTab.vue
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
<template>
<IxTabs v-model:selectedKey="selectedKey" type="segment" mode="primary">
<IxTab key="tab1">
<template #title>
<IxIcon name="file"></IxIcon>
Tab 1
</template>
Content of Tab 1
</IxTab>
<IxTab key="tab2">
<template #title>
<IxIcon name="file"></IxIcon>
Tab 2
</template>
Content of Tab 2
</IxTab>
<IxTab key="tab3">
<template #title>
<IxIcon name="file"></IxIcon>
Tab 3
</template>
Content of Tab 3
</IxTab>
<IxTabs v-model:selectedKey="selectedKey" :dataSource="dataSource">
<template #title="{ title }"> Default {{ title }}</template>
<template #content="{ key }"> Default content of Tab {{ key }} </template>
<template #customTitle="{ title }"> Custom {{ title }}</template>
<template #customContent="{ key }"> Custom content of Tab {{ key }} </template>
</IxTabs>
</template>

<script setup lang="ts">
import { ref } from 'vue'
const selectedKey = ref('tab1')
import { type TabsData } from '@idux/components/tabs'
const selectedKey = ref(0)
const dataSource: TabsData[] = [
{
key: 0,
title: 'Tab 0',
},
{
key: 1,
title: 'Tab 1',
},
{
key: 2,
title: 'Tab 2',
customTitle: 'customTitle',
customContent: 'customContent',
},
]
</script>
4 changes: 2 additions & 2 deletions packages/components/tabs/demo/Disabled.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
title:
zh: 禁用
en: Disabled
order: 3
order: 5
---

## zh

使用`disabled`控制标签是否禁用
使用 `disabled` 控制标签是否禁用

## en

Expand Down
25 changes: 11 additions & 14 deletions packages/components/tabs/demo/Disabled.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
<template>
<IxSpace vertical :size="40">
<IxTabs v-model:selectedKey="selectedKey">
<IxTab key="tab1" title="Tab 1"> Content of Tab 1 </IxTab>
<IxTab key="tab2" title="Tab 2" disabled> Content of Tab 2 </IxTab>
<IxTab key="tab3" title="Tab 3"> Content of Tab 3 </IxTab>
<IxSpace size="lg" vertical>
<IxTabs v-model:selectedKey="selectedKey" :dataSource="dataSource">
<template #content="{ key }"> Content of Tab {{ key }} </template>
</IxTabs>
<IxTabs v-model:selectedKey="selectedKey" type="line">
<IxTab key="tab1" title="Tab 1"> Content of Tab 1 </IxTab>
<IxTab key="tab2" title="Tab 2" disabled> Content of Tab 2 </IxTab>
<IxTab key="tab3" title="Tab 3"> Content of Tab 3 </IxTab>
<IxTabs v-model:selectedKey="selectedKey" :dataSource="dataSource" type="line">
<template #content="{ key }"> Content of Tab {{ key }} </template>
</IxTabs>
<IxTabs v-model:selectedKey="selectedKey" type="segment">
<IxTab key="tab1" title="Tab 1"> Content of Tab 1 </IxTab>
<IxTab key="tab2" title="Tab 2" disabled> Content of Tab 2 </IxTab>
<IxTab key="tab3" title="Tab 3"> Content of Tab 3 </IxTab>
<IxTabs v-model:selectedKey="selectedKey" :dataSource="dataSource" type="segment">
<template #content="{ key }"> Content of Tab {{ key }} </template>
</IxTabs>
</IxSpace>
</template>

<script setup lang="ts">
import { ref } from 'vue'
const selectedKey = ref('tab1')
const selectedKey = ref(0)
const dataSource = Array.from({ length: 3 }).map((_, index) => {
return { key: index, title: `Tab ${index}` }
})
</script>
14 changes: 14 additions & 0 deletions packages/components/tabs/demo/Dynamic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title:
zh: 新增和关闭
en: Add and Close
order: 10
---

## zh

卡片类型标签页,默认为此类型

## en

The simplest usage.
23 changes: 23 additions & 0 deletions packages/components/tabs/demo/Dynamic.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<IxTabs v-model:selectedKey="selectedKey" :dataSource="dataSource" addable closable @add="onAdd">
<template #content="{ key }"> Content of Tab {{ key }} </template>
</IxTabs>
</template>

<script setup lang="ts">
import { ref } from 'vue'
const selectedKey = ref(0)
const dataSource = ref(
Array.from({ length: 3 }).map((_, index) => {
return { key: index, title: `Tab ${index}` }
}),
)
const onAdd = () => {
const newKey = dataSource.value.length
dataSource.value = [...dataSource.value, { key: newKey, title: `Tab ${newKey}` }]
selectedKey.value = newKey
}
</script>
2 changes: 1 addition & 1 deletion packages/components/tabs/demo/Line.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ order: 1

## zh

下划线类型标签页
通过设置 `type``line`, 展示下划线类型标签页

## en

Expand Down
12 changes: 5 additions & 7 deletions packages/components/tabs/demo/Line.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<template>
<IxTabs v-model:selectedKey="selectedKey" type="line">
<IxTab key="tab1" title="Tab 1"> Content of Tab 1 </IxTab>
<IxTab key="tab2" title="Tab 2"> Content of Tab 2 </IxTab>
<IxTab key="tab3" title="Tab 3"> Content of Tab 3 </IxTab>
<IxTabs :dataSource="dataSource" type="line">
<template #content="{ key }"> Content of Tab {{ key }} </template>
</IxTabs>
</template>

<script setup lang="ts">
import { ref } from 'vue'
const selectedKey = ref('tab1')
const dataSource = Array.from({ length: 3 }).map((_, index) => {
return { key: index, title: `Tab ${index}` }
})
</script>
6 changes: 3 additions & 3 deletions packages/components/tabs/demo/Placement.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
title:
zh: 标签页位置
zh: 位置
en: Basic usage
order: 4
order: 6
---

## zh

提供了`top``bottom``start``bottom`四种标签页位置,默认为`top`其他类型仅在type为`line`生效
提供了 `top``bottom``start``bottom` 四种标签页位置,默认为 `top`其他类型仅在 `type``line` 生效

## en

Expand Down
24 changes: 12 additions & 12 deletions packages/components/tabs/demo/Placement.vue
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<template>
<IxRadioGroup v-model:value="placement">
<IxRadio value="top">top</IxRadio>
<IxRadio value="start">start</IxRadio>
<IxRadio value="end">end</IxRadio>
<IxRadio value="bottom">bottom</IxRadio>
</IxRadioGroup>
<IxTabs v-model:selectedKey="selectedKey" type="line" :placement="placement">
<IxTab key="tab1" title="Tab 1"> Content of Tab 1 </IxTab>
<IxTab key="tab2" title="Tab 2"> Content of Tab 2 </IxTab>
<IxTab key="tab3" title="Tab 3"> Content of Tab 3 </IxTab>
</IxTabs>
<IxSpace size="lg" vertical>
<IxRadioGroup v-model:value="placement" :dataSource="placements"> </IxRadioGroup>
<IxTabs v-model:selectedKey="selectedKey" :dataSource="dataSource" :placement="placement" type="line">
<template #content="{ key }"> Content of Tab {{ key }} </template>
</IxTabs>
</IxSpace>
</template>
<script setup lang="ts">
import type { TabsPlacement } from '@idux/components/tabs'
import { ref } from 'vue'
const placement = ref<TabsPlacement>('top')
const selectedKey = ref('tab1')
const placements = ['top', 'start', 'end', 'bottom'].map(item => ({ key: item, label: item }))
const selectedKey = ref(0)
const dataSource = Array.from({ length: 3 }).map((_, index) => {
return { key: index, title: `Tab ${index}` }
})
</script>
2 changes: 1 addition & 1 deletion packages/components/tabs/demo/Scroll.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title:
zh: 滑动
en: Basic usage
order: 6
order: 10
---

## zh
Expand Down
37 changes: 12 additions & 25 deletions packages/components/tabs/demo/Scroll.vue
Original file line number Diff line number Diff line change
@@ -1,39 +1,26 @@
<template>
<IxSpace vertical :size="40" block>
<IxTabs v-model:selectedKey="selectedKey" style="width: 410px">
<IxTab v-for="panel in panels" :key="panel" :title="'Tab ' + panel"> Content of Tab {{ panel }} </IxTab>
<IxSpace block size="lg" vertical>
<IxTabs v-model:selectedKey="selectedKey" :dataSource="dataSource">
<template #content="{ key }"> Content of Tab {{ key }} </template>
</IxTabs>
<IxTabs v-model:selectedKey="selectedKey" style="width: 410px" type="line">
<IxTab v-for="panel in panels" :key="panel" :title="'Tab ' + panel"> Content of Tab {{ panel }} </IxTab>
<IxTabs v-model:selectedKey="selectedKey" :dataSource="dataSource" type="line">
<template #content="{ key }"> Content of Tab {{ key }} </template>
</IxTabs>
<IxTabs v-model:selectedKey="selectedKey" style="height: 200px" type="line" placement="start">
<IxTab v-for="panel in panels" :key="panel" :title="'Tab ' + panel"> Content of Tab {{ panel }} </IxTab>
</IxTabs>
<IxTabs v-model:selectedKey="selectedKey" style="width: 410px" type="segment">
<IxTab v-for="panel in panels" :key="panel" :title="'Tab ' + panel"> Content of Tab {{ panel }} </IxTab>
<IxTabs v-model:selectedKey="selectedKey" :dataSource="dataSource" type="segment">
<template #content="{ key }"> Content of Tab {{ key }} </template>
</IxTabs>
<IxSpace align="center">
<IxButton @click="addTab">addTab</IxButton>
<IxButton @click="closeTab">closeTab</IxButton>
移动到第几个:<IxInputNumber v-model:value="selectedKey" :max="20" :min="1"></IxInputNumber>
<IxInputNumber v-model:value="selectedKey" :max="98" :min="0"></IxInputNumber>
</IxSpace>
</IxSpace>
</template>

<script setup lang="ts">
import { ref } from 'vue'
const selectedKey = ref(7)
const selectedKey = ref(0)
const panels = ref([1, 2, 3, 4, 5, 6, 7])
const addTab = () => {
const key = (panels.value[panels.value.length - 1] || 0) + 1
panels.value.push(key)
selectedKey.value = key
}
const closeTab = () => {
panels.value.pop()
const key = panels.value[panels.value.length - 1]
selectedKey.value = key
}
const dataSource = Array.from({ length: 99 }).map((_, index) => {
return { key: index, title: `Tab ${index}` }
})
</script>
2 changes: 1 addition & 1 deletion packages/components/tabs/demo/Segment.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ order: 2

## zh

分段类型标签页,当type为`segment`时,可以使用`mode`属性,修改按钮的类型
通过设置 `type``line`, 展示分段类型标签页,此时可以使用 `mode` 属性,修改按钮的颜色

## en

Expand Down

0 comments on commit 907fd37

Please sign in to comment.