File tree Expand file tree Collapse file tree 8 files changed +108
-15
lines changed
Expand file tree Collapse file tree 8 files changed +108
-15
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ order : 4
3+ title :
4+ zh-CN : 变体
5+ en-US : Variant
6+ ---
7+
8+ ## zh-CN
9+
10+ 分隔线默认为 ` solid ` (实线)变体。您可以将其更改为 ` dashed ` (虚线)或 ` dotted ` (点线)。
11+
12+ ## en-US
13+
14+ Divider is of ` solid ` variant by default. You can change that to either ` dashed ` or ` dotted ` .
Original file line number Diff line number Diff line change 1+ import { Component } from '@angular/core' ;
2+
3+ import { NzDividerModule } from 'ng-zorro-antd/divider' ;
4+
5+ @Component ( {
6+ selector : 'nz-demo-divider-variant' ,
7+ standalone : true ,
8+ imports : [ NzDividerModule ] ,
9+ template : `
10+ <div>
11+ <p>
12+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae
13+ sunt a te dicta? Refert tamen, quo modo.
14+ </p>
15+ <nz-divider nzPlain nzText="Solid" nzVariant="solid"></nz-divider>
16+ <p>
17+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae
18+ sunt a te dicta? Refert tamen, quo modo.
19+ </p>
20+ <nz-divider nzPlain nzText="Dotted" nzVariant="dotted"></nz-divider>
21+ <p>
22+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae
23+ sunt a te dicta? Refert tamen, quo modo.
24+ </p>
25+ <nz-divider nzPlain nzText="Dashed" nzVariant="dashed"></nz-divider>
26+ <p>
27+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae
28+ sunt a te dicta? Refert tamen, quo modo.
29+ </p>
30+ </div>
31+ ` ,
32+ styles : [
33+ `
34+ nz-divider::after,
35+ nz-divider::before {
36+ border-color: #7cb305 !important;
37+ }
38+ `
39+ ]
40+ } )
41+ export class NzDemoDividerVariantComponent { }
Original file line number Diff line number Diff line change @@ -36,7 +36,8 @@ import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
3636 '[class.ant-divider-with-text-left]' : `nzText && nzOrientation === 'left'` ,
3737 '[class.ant-divider-with-text-right]' : `nzText && nzOrientation === 'right'` ,
3838 '[class.ant-divider-with-text-center]' : `nzText && nzOrientation === 'center'` ,
39- '[class.ant-divider-dashed]' : `nzDashed`
39+ '[class.ant-divider-dashed]' : `nzDashed || nzVariant === 'dashed'` ,
40+ '[class.ant-divider-dotted]' : `nzVariant === 'dotted'`
4041 } ,
4142 imports : [ NzOutletModule ] ,
4243 standalone : true
@@ -45,6 +46,7 @@ export class NzDividerComponent {
4546 @Input ( ) nzText ?: string | TemplateRef < void > ;
4647 @Input ( ) nzType : 'horizontal' | 'vertical' = 'horizontal' ;
4748 @Input ( ) nzOrientation : 'left' | 'right' | 'center' = 'center' ;
49+ @Input ( ) nzVariant : 'dashed' | 'dotted' | 'solid' = 'solid' ;
4850 @Input ( { transform : booleanAttribute } ) nzDashed = false ;
4951 @Input ( { transform : booleanAttribute } ) nzPlain = false ;
5052
Original file line number Diff line number Diff line change @@ -72,6 +72,20 @@ describe('divider', () => {
7272 } ) ;
7373 } ) ;
7474 } ) ;
75+
76+ describe ( '#nzVariant' , ( ) => {
77+ ( [ 'dashed' , 'dotted' ] as const ) . forEach ( type => {
78+ it ( `with ${ type } ` , ( ) => {
79+ context . comp . nzVariant = type ;
80+ fixture . detectChanges ( ) ;
81+ expect ( dl . query ( By . css ( `.ant-divider-${ type } ` ) ) != null ) . toBe ( true ) ;
82+ } ) ;
83+ } ) ;
84+
85+ it ( 'should have solid as default value for nzVariant' , ( ) => {
86+ expect ( context . comp . nzVariant ) . toEqual ( 'solid' ) ;
87+ } ) ;
88+ } ) ;
7589} ) ;
7690
7791@Component ( {
Original file line number Diff line number Diff line change @@ -20,10 +20,11 @@ import { NzDividerModule } from 'ng-zorro-antd/divider';
2020
2121### nz-divider: standalone
2222
23- | Property | Description | Type | Default |
24- | ----------------- | -------------------------------- | ------------------------------- | -------------- |
25- | ` [nzDashed] ` | whether line is dashed | ` boolean ` | ` false ` |
26- | ` [nzType] ` | direction type of divider | ` 'horizontal' \| 'vertical' ` | ` 'horizontal' ` |
27- | ` [nzText] ` | inner text of divider | ` string \| TemplateRef<void> ` | - |
28- | ` [nzPlain] ` | Divider text show as plain style | ` boolean ` | ` false ` |
29- | ` [nzOrientation] ` | inner text orientation | ` 'center' \| 'left' \| 'right' ` | ` 'center' ` |
23+ | Property | Description | Type | Default |
24+ | ----------------- | --------------------------------------- | --------------------------------- | -------------- |
25+ | ` [nzDashed] ` | whether line is dashed | ` boolean ` | ` false ` |
26+ | ` [nzType] ` | direction type of divider | ` 'horizontal' \| 'vertical' ` | ` 'horizontal' ` |
27+ | ` [nzText] ` | inner text of divider | ` string \| TemplateRef<void> ` | - |
28+ | ` [nzPlain] ` | Divider text show as plain style | ` boolean ` | ` false ` |
29+ | ` [nzOrientation] ` | inner text orientation | ` 'center' \| 'left' \| 'right' ` | ` 'center' ` |
30+ | ` [nzVariant] ` | Whether line is dashed, dotted or solid | ` 'dashed' \| 'dotted' \| 'solid' ` | ` 'solid' ` |
Original file line number Diff line number Diff line change @@ -21,10 +21,11 @@ import { NzDividerModule } from 'ng-zorro-antd/divider';
2121
2222### nz-divider: standalone
2323
24- | 参数 | 说明 | 类型 | 默认值 |
25- | ----------------- | -------------------------- | ------------------------------- | -------------- |
26- | ` [nzDashed] ` | 是否虚线 | ` boolean ` | ` false ` |
27- | ` [nzType] ` | 水平还是垂直类型 | ` 'horizontal' \| 'vertical' ` | ` 'horizontal' ` |
28- | ` [nzText] ` | 中间文字 | ` string \| TemplateRef<void> ` | - |
29- | ` [nzPlain] ` | 文字是否显示为普通正文样式 | ` boolean ` | ` false ` |
30- | ` [nzOrientation] ` | 中间文字方向 | ` 'center' \| 'left' \| 'right' ` | ` 'center' ` |
24+ | 参数 | 说明 | 类型 | 默认值 |
25+ | ----------------- | -------------------------- | --------------------------------- | -------------- |
26+ | ` [nzDashed] ` | 是否虚线 | ` boolean ` | ` false ` |
27+ | ` [nzType] ` | 水平还是垂直类型 | ` 'horizontal' \| 'vertical' ` | ` 'horizontal' ` |
28+ | ` [nzText] ` | 中间文字 | ` string \| TemplateRef<void> ` | - |
29+ | ` [nzPlain] ` | 文字是否显示为普通正文样式 | ` boolean ` | ` false ` |
30+ | ` [nzOrientation] ` | 中间文字方向 | ` 'center' \| 'left' \| 'right' ` | ` 'center' ` |
31+ | ` [nzVariant] ` | 分割线是虚线、点线还是实线 | ` 'dashed' \| 'dotted' \| 'solid' ` | ` 'solid' ` |
Original file line number Diff line number Diff line change 11@import ' ./index.less' ;
2+ @import ' ./patch.less' ;
Original file line number Diff line number Diff line change 1+ .@{divider-prefix-cls} {
2+ &-dotted {
3+ background : none ;
4+ border-color : @divider-color ;
5+ border-style : dotted ;
6+ border-width : @border-width-base 0 0 ;
7+ }
8+
9+ &-horizontal&-with-text&-dotted {
10+ & ::after ,
11+ & ::before {
12+ border-style : dotted none none ;
13+ }
14+ }
15+
16+ &-vertical&-dotted {
17+ border-width : 0 0 0 @border-width-base ;
18+ }
19+ }
You can’t perform that action at this time.
0 commit comments