diff --git a/docs/en-US/component/divider.md b/docs/en-US/component/divider.md index f7801abaa9..807da42b7a 100644 --- a/docs/en-US/component/divider.md +++ b/docs/en-US/component/divider.md @@ -27,6 +27,16 @@ divider/custom-content ::: +## dashed line + +You can set the style of divider. + +:::demo + +divider/line-dashed + +::: + ## Vertical divider :::demo @@ -37,7 +47,8 @@ divider/vertical-divider ## Divider Attributes -| Attribute | Description | Type | Accepted Values | Default | -| ---------------- | ----------------------------------------- | ------ | --------------------- | ---------- | -| direction | Set divider's direction | string | horizontal / vertical | horizontal | -| content-position | customize the content on the divider line | String | left / right / center | center | +| Attribute | Description | Type | Accepted Values | Default | +| ---------------- | ----------------------------------------- | ------ | --------------------------------------------------------------------------------- | ---------- | +| direction | Set divider's direction | string | horizontal / vertical | horizontal | +| border-style | Set the style of divider | string | [CSS/border-style](https://developer.mozilla.org/zh-CN/docs/Web/CSS/border-style) | solid | +| content-position | customize the content on the divider line | String | left / right / center | center | diff --git a/docs/examples/divider/custom-content.vue b/docs/examples/divider/custom-content.vue index 1b7350e1ec..4b93b0c49c 100644 --- a/docs/examples/divider/custom-content.vue +++ b/docs/examples/divider/custom-content.vue @@ -2,14 +2,14 @@
What you are you do not see, what you see is your shadow. Rabindranath Tagore - I cannot choose the best. The best chooses me. - - - My wishes are fools, they shout across thy song, my Master. Let me but listen. + + + + I cannot choose the best. The best chooses me. Rabindranath Tagore
diff --git a/docs/examples/divider/line-dashed.vue b/docs/examples/divider/line-dashed.vue new file mode 100644 index 0000000000..1d761c4633 --- /dev/null +++ b/docs/examples/divider/line-dashed.vue @@ -0,0 +1,11 @@ + diff --git a/docs/examples/divider/vertical-divider.vue b/docs/examples/divider/vertical-divider.vue index 2f10758566..a4b08ee508 100644 --- a/docs/examples/divider/vertical-divider.vue +++ b/docs/examples/divider/vertical-divider.vue @@ -3,7 +3,7 @@ Rain Home - + Grass diff --git a/packages/components/divider/__tests__/divider.spec.ts b/packages/components/divider/__tests__/divider.spec.ts index 21a9293e5e..761e8faead 100644 --- a/packages/components/divider/__tests__/divider.spec.ts +++ b/packages/components/divider/__tests__/divider.spec.ts @@ -42,4 +42,30 @@ describe('Divider.vue', () => { }) expect(wrapper.classes()).toContain('customClass') }) + + test('line-dashed', () => { + const wrapper = mount(Divider, { + props: { + borderStyle: 'dashed', + }, + }) + expect( + getComputedStyle(wrapper.element, null).getPropertyValue( + '--el-border-style' + ) + ).toBe('dashed') + }) + + test('line-solid', () => { + const wrapper = mount(Divider, { + props: { + direction: 'vertical', + }, + }) + expect( + getComputedStyle(wrapper.element, null).getPropertyValue( + '--el-border-style' + ) + ).toBe('solid') + }) }) diff --git a/packages/components/divider/src/divider.ts b/packages/components/divider/src/divider.ts index 38e62ddbaa..28fe022d43 100644 --- a/packages/components/divider/src/divider.ts +++ b/packages/components/divider/src/divider.ts @@ -1,7 +1,9 @@ -import { buildProps } from '@element-plus/utils/props' +import { buildProps, definePropType } from '@element-plus/utils/props' import type { ExtractPropTypes } from 'vue' +export type BorderStyle = CSSStyleDeclaration['borderStyle'] + export const dividerProps = buildProps({ direction: { type: String, @@ -13,5 +15,9 @@ export const dividerProps = buildProps({ values: ['left', 'center', 'right'], default: 'center', }, + borderStyle: { + type: definePropType(String), + default: 'solid', + }, } as const) export type DividerProps = ExtractPropTypes diff --git a/packages/components/divider/src/divider.vue b/packages/components/divider/src/divider.vue index 6d1dccd54a..fa4bfc2d83 100644 --- a/packages/components/divider/src/divider.vue +++ b/packages/components/divider/src/divider.vue @@ -1,5 +1,8 @@