Skip to content
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

feat(Descriptions): 增加尺寸 size 配置项 #930

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion components/descriptions/descriptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ export default defineComponent({

return () => {
return (
<div class={prefixCls}>
<div
class={[
`${prefixCls}`,
props.size && `${prefixCls}-size-${props.size}`,
]}
>
{renderHeader()}
<div
class={[
Expand Down
1 change: 1 addition & 0 deletions components/descriptions/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { DescriptionsItemProps } from './props';

export type LabelAlign = 'center' | 'left' | 'right';
export type LabelPlacement = 'top' | 'left';
export type Size = 'small' | 'middle' | 'large';

export interface DescriptionsItemInst {
id: ComponentInternalInstance['uid'];
Expand Down
9 changes: 8 additions & 1 deletion components/descriptions/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
PropType,
} from 'vue';
import type { ExtractPublicPropTypes } from '../_util/interface';
import type { LabelAlign, LabelPlacement } from './interface';
import type { LabelAlign, LabelPlacement, Size } from './interface';

// ----- Description -----

Expand Down Expand Up @@ -35,6 +35,13 @@ export const descriptionsProps = {
},
title: String,
bordered: Boolean,
size: {
type: String as PropType<Size>,
default: 'small',
validator(value: string) {
return ['small', 'middle', 'large'].includes(value);
},
},
} as const satisfies ComponentObjectPropsOptions;

export type DescriptionsProps = ExtractPublicPropTypes<
Expand Down
10 changes: 10 additions & 0 deletions components/descriptions/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
border-radius: var(--f-border-radius-base);
}
}
&-size-middle {
.@{descriptions-prefix-cls}-body {
grid-gap: var(--f-padding-small) var(--f-padding-middle);
}
}
&-size-large {
.@{descriptions-prefix-cls}-body {
grid-gap: var(--f-padding-middle) var(--f-padding-large);
}
}
}

.@{descriptions-item-prefix-cls} {
Expand Down
27 changes: 19 additions & 8 deletions docs/.vitepress/components/descriptions/common.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
<template>
<FForm labelWidth="150px">
<FFormItem label="尺寸:">
<FRadioGroup
v-model="size"
:options="[
{ label: 'small(默认)', value: 'small' },
{ label: 'middle', value: 'middle' },
{ label: 'large', value: 'large' },
]"
/>
</FFormItem>
</FForm>

<FDivider />

<FSpace vertical>
<FDescriptions title="一二三向前冲">
<FDescriptions title="一二三向前冲" :size="size">
<FDescriptionsItem label="墓封"> 鬼切 </FDescriptionsItem>
<FDescriptionsItem label="墓封">魂镰</FDescriptionsItem>
<FDescriptionsItem label="墓封">寒钉</FDescriptionsItem>
Expand All @@ -11,12 +26,8 @@
</FSpace>
</template>

<script>
import { defineComponent } from 'vue';
<script setup>
import { ref } from 'vue';

export default defineComponent({
setup() {
return {};
},
});
const size = ref('small');
</script>
31 changes: 16 additions & 15 deletions docs/.vitepress/components/descriptions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,25 @@ borded.vue

### Descriptions Props

| 属性 | 说明 | 类型 | 默认值 |
| -------------- | --------------------------------------- | ----------------------- | ------ |
| column | 设置总列数 | number | 3 |
| contentStyle | 内容样式 | string / object | - |
| labelAlign | label 对齐方式 | `left` `right` `center` | `left` |
| labelPlacement | label 位置 | `top` `left` | `left` |
| labelStyle | label 样式 | string / object | - |
| separator | 分隔符,`labelPlacement` 为 `left` 有效 | string | ':' |
| title | 标题 | string | - |
| bordered | 边框 | boolean | false |
| 属性 | 说明 | 类型 | 默认值 |
| -------------- | --------------------------------------- | ------------------------ | ------- |
| column | 设置总列数 | number | 3 |
| contentStyle | 内容样式 | string / object | - |
| labelAlign | label 对齐方式 | `left` `right` `center` | `left` |
| labelPlacement | label 位置 | `top` `left` | `left` |
| labelStyle | label 样式 | string / object | - |
| separator | 分隔符,`labelPlacement` 为 `left` 有效 | string | ':' |
| title | 标题 | string | - |
| bordered | 边框 | boolean | false |
| size | 尺寸 | `small` `middle` `large` | `small` |

### DescriptionItem Props

| 属性 | 说明 | 类型 | 默认值 |
|--------------|----------------------------------------------------------|-----------------|--------|
| contentStyle | 内容样式 | string / object | - |
| label | label 值 | string | - |
| labelStyle | label 样式 | string / object | - |
| 属性 | 说明 | 类型 | 默认值 |
| ------------ | ------------------------------------------------------------ | --------------- | ------ |
| contentStyle | 内容样式 | string / object | - |
| label | label 值 | string | - |
| labelStyle | label 样式 | string / object | - |
| span | 所占列数<br/>(建议不设置最后一项 Item,由组件内部自动计算) | number | 1 |

## Slots
Expand Down
Loading