Skip to content

Commit

Permalink
feat(descriptions): add descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangpaopao0609 committed Jan 15, 2024
1 parent 0de55f8 commit 38b1c52
Show file tree
Hide file tree
Showing 28 changed files with 850 additions and 1 deletion.
13 changes: 13 additions & 0 deletions script/generate-usage/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,4 +664,17 @@ module.exports = {
`,
},
},
descriptions: {
panelStr: `const panelList = [{label: 'descriptions', value: 'descriptions'}];`,
render: {
descriptions: `
<t-descriptions title="Shipping address" v-bind="configProps">
<t-descriptions-item label="Name">TDesign</t-descriptions-item>
<t-descriptions-item label="Telephone Number">139****0609</t-descriptions-item>
<t-descriptions-item label="Area">China Tencent Headquarters</t-descriptions-item>
<t-descriptions-item label="Address">Shenzhen Penguin Island D1 4A Mail Center</t-descriptions-item>
</t-descriptions>
`,
},
},
};
8 changes: 8 additions & 0 deletions site/site.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,14 @@ const docs = [
component: () => import('tdesign-vue/comment/comment.md'),
componentEn: () => import('tdesign-vue/comment/comment.en-US.md'),
},
{
title: 'Descriptions 描述',
titleEn: 'Descriptions',
name: 'descriptions',
path: '/vue/components/descriptions',
component: () => import('tdesign-vue/descriptions/descriptions.md'),
componentEn: () => import('tdesign-vue/descriptions/descriptions.en-US.md'),
},
{
title: 'Image 图片',
titleEn: 'Image',
Expand Down
1 change: 1 addition & 0 deletions src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export * from './badge';
export * from './calendar';
export * from './card';
export * from './comment';
export * from './descriptions';
export * from './image';
export * from './image-viewer';
export * from './list';
Expand Down
8 changes: 8 additions & 0 deletions src/descriptions/_example/base.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<template>
<t-descriptions title="Shipping address">
<t-descriptions-item label="Name">TDesign</t-descriptions-item>
<t-descriptions-item label="Telephone Number">139****0609</t-descriptions-item>
<t-descriptions-item label="Area">China Tencent Headquarters</t-descriptions-item>
<t-descriptions-item label="Address">Shenzhen Penguin Island D1 4A Mail Center</t-descriptions-item>
</t-descriptions>
</template>
8 changes: 8 additions & 0 deletions src/descriptions/_example/bordered.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<template>
<t-descriptions title="Shipping address" bordered :column="3">
<t-descriptions-item label="Name">TDesign</t-descriptions-item>
<t-descriptions-item label="Telephone Number">139****0609</t-descriptions-item>
<t-descriptions-item label="Area">China Tencent Headquarters</t-descriptions-item>
<t-descriptions-item label="Address">Shenzhen Penguin Island D1 4A Mail Center</t-descriptions-item>
</t-descriptions>
</template>
17 changes: 17 additions & 0 deletions src/descriptions/_example/colon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<t-space direction="vertical">
<t-checkbox v-model="checked">展示引号</t-checkbox>
<t-descriptions title="Shipping address" bordered :colon="checked" :column="3">
<t-descriptions-item label="Name">TDesign</t-descriptions-item>
<t-descriptions-item label="Telephone Number">139****0609</t-descriptions-item>
<t-descriptions-item label="Area">China Tencent Headquarters</t-descriptions-item>
<t-descriptions-item label="Address">Shenzhen Penguin Island D1 4A Mail Center</t-descriptions-item>
</t-descriptions>
</t-space>
</template>

<script setup>
import { ref } from 'vue';
const checked = ref(true);
</script>
19 changes: 19 additions & 0 deletions src/descriptions/_example/column.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<template>
<t-space direction="vertical">
<t-radio-group v-model="column" :options="columnOptions"></t-radio-group>
<t-descriptions bordered :column="column">
<t-descriptions-item label="Name">TDesign</t-descriptions-item>
<t-descriptions-item label="Telephone Number">139****0609</t-descriptions-item>
<t-descriptions-item label="Area">China Tencent Headquarters</t-descriptions-item>
<t-descriptions-item label="Address">Shenzhen Penguin Island D1 4A Mail Center</t-descriptions-item>
</t-descriptions>
</t-space>
</template>

<script setup>
import { ref } from 'vue';
const columnOptions = [2, 3, 4];
const column = ref(2);
</script>
14 changes: 14 additions & 0 deletions src/descriptions/_example/custom-style.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<t-descriptions
title="Shipping address"
bordered
:label-style="{ width: '100px', textAlign: 'left' }"
:content-style="{ textAlign: 'right' }"
:column="3"
>
<t-descriptions-item label="Name">TDesign</t-descriptions-item>
<t-descriptions-item label="Telephone Number">139****0609</t-descriptions-item>
<t-descriptions-item label="Area">China Tencent Headquarters</t-descriptions-item>
<t-descriptions-item label="Address">Shenzhen Penguin Island D1 4A Mail Center</t-descriptions-item>
</t-descriptions>
</template>
24 changes: 24 additions & 0 deletions src/descriptions/_example/items.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<t-descriptions title="Shipping address" :items="items" :column="3" />
</template>

<script setup lang="jsx">
const items = [
{ label: 'Name', content: 'TDesign' },
{ label: <button>Telephone Number</button>, content: '139****0609' },
{ label: 'Area', content: <h3>China Tencent Headquarters</h3> },
{ label: () => <i>'Address'</i>, content: () => <mark> 'Shenzhen Penguin Island D1 4A Mail Center'</mark> },
];
</script>

<!-- <template>
<t-descriptions title="Shipping address" :items="items" />
</template>
<script setup>
import Base from './base.vue';
const items = [
{ label: 'Name', content: 'TDesign' },
{ label: Base, content: '139****0609' },
];
</script> -->
30 changes: 30 additions & 0 deletions src/descriptions/_example/layout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<template>
<t-space direction="vertical">
<t-row>
<span>layout:</span>
<t-radio-group v-model="layout" :options="layoutOptions"></t-radio-group>
</t-row>

<t-row>
<span>itemLayout:</span>
<t-radio-group v-model="itemLayout" :options="itemLayoutOptions"></t-radio-group>
</t-row>

<t-descriptions title="Shipping address" bordered :layout="layout" :item-layout="itemLayout" :column="3">
<t-descriptions-item label="Name">TDesign</t-descriptions-item>
<t-descriptions-item label="Telephone Number">139****0609</t-descriptions-item>
<t-descriptions-item label="Area">China Tencent Headquarters</t-descriptions-item>
<t-descriptions-item label="Address">Shenzhen Penguin Island D1 4A Mail Center</t-descriptions-item>
</t-descriptions>
</t-space>
</template>

<script setup>
import { ref } from 'vue';
const layout = ref('horizontal');
const itemLayout = ref('horizontal');
const layoutOptions = ['horizontal', 'vertical'];
const itemLayoutOptions = ['horizontal', 'vertical'];
</script>
18 changes: 18 additions & 0 deletions src/descriptions/_example/size.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<t-space direction="vertical">
<t-radio-group v-model="size" :options="sizeOptions"></t-radio-group>
<t-descriptions bordered :size="size" :column="3">
<t-descriptions-item label="Name">TDesign</t-descriptions-item>
<t-descriptions-item label="Telephone Number">139****0609</t-descriptions-item>
<t-descriptions-item label="Area">China Tencent Headquarters</t-descriptions-item>
<t-descriptions-item label="Address">Shenzhen Penguin Island D1 4A Mail Center</t-descriptions-item>
</t-descriptions>
</t-space>
</template>

<script setup>
import { ref } from 'vue';
const sizeOptions = ['large', 'medium', 'small'];
const size = ref('medium');
</script>
32 changes: 32 additions & 0 deletions src/descriptions/_usage/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!-- 该脚本为自动生成,如有需要请在 /script/generate-usage.js 中调整 -->
<template>
<base-usage :code="usageCode" :config-list="configList" :panel-list="panelList" @PanelChange="onPanelChange">
<template #descriptions="{ configProps }">
<t-descriptions title="Shipping address" v-bind="configProps">
<t-descriptions-item label="Name">TDesign</t-descriptions-item>
<t-descriptions-item label="Telephone Number">139****0609</t-descriptions-item>
<t-descriptions-item label="Area">China Tencent Headquarters</t-descriptions-item>
<t-descriptions-item label="Address">Shenzhen Penguin Island D1 4A Mail Center</t-descriptions-item>
</t-descriptions>
</template>
</base-usage>
</template>

<script setup lang="jsx">
/* eslint-disable */
import { ref, onMounted } from '@vue/composition-api';
import configJson from './props.json';
const configList = ref(configJson);
const panelList = [{ label: 'descriptions', value: 'descriptions' }];
const usageCodeMap = {
descriptions:
'\n <t-descriptions title="Shipping address" v-bind="configProps">\n <t-descriptions-item label="Name">TDesign</t-descriptions-item>\n <t-descriptions-item label="Telephone Number">139****0609</t-descriptions-item>\n <t-descriptions-item label="Area">China Tencent Headquarters</t-descriptions-item>\n <t-descriptions-item label="Address">Shenzhen Penguin Island D1 4A Mail Center</t-descriptions-item>\n </t-descriptions>\n ',
};
const usageCode = ref(`<template>${usageCodeMap[panelList[0].value].trim()}</template>`);
function onPanelChange(panel) {
usageCode.value = `<template>${usageCodeMap[panel].trim()}</template>`;
}
</script>
63 changes: 63 additions & 0 deletions src/descriptions/_usage/props.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[
{
"name": "bordered",
"type": "Boolean",
"defaultValue": false,
"options": []
},
{
"name": "colon",
"type": "Boolean",
"defaultValue": false,
"options": []
},
{
"name": "size",
"type": "enum",
"defaultValue": "medium",
"options": [
{
"label": "large",
"value": "large"
},
{
"label": "medium",
"value": "medium"
},
{
"label": "small",
"value": "small"
}
]
},
{
"name": "layout",
"type": "enum",
"defaultValue": "horizontal",
"options": [
{
"label": "horizontal",
"value": "horizontal"
},
{
"label": "vertical",
"value": "vertical"
}
]
},
{
"name": "itemLayout",
"type": "enum",
"defaultValue": "horizontal",
"options": [
{
"label": "horizontal",
"value": "horizontal"
},
{
"label": "vertical",
"value": "vertical"
}
]
}
]
6 changes: 6 additions & 0 deletions src/descriptions/const/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { InjectionKey } from '@vue/composition-api';
import { TdDescriptionsProps } from '../type';

const descriptionsKey: InjectionKey<TdDescriptionsProps> = Symbol('TDescriptions');

export default descriptionsKey;
28 changes: 28 additions & 0 deletions src/descriptions/description-item-props.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* eslint-disable */

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { TdDescriptionItemProps } from '../descriptions/type';
import { PropType } from 'vue';

export default {
/** 描述项内容 */
content: {
type: [String, Function] as PropType<TdDescriptionItemProps['content']>,
},
/** 描述项内容,同 `content` */
default: {
type: [String, Function] as PropType<TdDescriptionItemProps['default']>,
},
/** 描述项标签 */
label: {
type: [String, Function] as PropType<TdDescriptionItemProps['label']>,
},
/** 占用的宽度数量 */
span: {
type: Number,
default: 1,
},
};
7 changes: 7 additions & 0 deletions src/descriptions/descriptions-item.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineComponent } from '@vue/composition-api';
import props from './props';

export default defineComponent({
name: 'TDescriptionsItem',
props,
});
Loading

0 comments on commit 38b1c52

Please sign in to comment.