Skip to content

Commit e428083

Browse files
feat(module:tag): borderless mode (#8320)
* feat(module:tag): borderless mode * feat(module:tag): borderless mode * feat(module:tag): borderless mode * feat(module:tag): borderless mode * feat(module:tag): borderless mode
1 parent 66a88db commit e428083

7 files changed

Lines changed: 46 additions & 0 deletions

File tree

‎components/tag/demo/borderless.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
order: 5
3+
title:
4+
zh-CN: 无边框
5+
en-US: Borderless
6+
---
7+
8+
## zh-CN
9+
10+
无边框模式。
11+
12+
## en-US
13+
14+
borderless.

‎components/tag/demo/borderless.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Component } from '@angular/core';
2+
3+
import { presetColors } from 'ng-zorro-antd/core/color';
4+
5+
@Component({
6+
selector: 'nz-demo-tag-borderless',
7+
template: `
8+
<ng-container *ngFor="let color of tagColors">
9+
<nz-tag [nzColor]="color" [nzBordered]="false">{{ color }}</nz-tag>
10+
</ng-container>
11+
`
12+
})
13+
export class NzDemoTagBorderlessComponent {
14+
public tagColors = presetColors;
15+
}

‎components/tag/doc/index.en-US.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ import { NzTagModule } from 'ng-zorro-antd/tag';
2626
| `[nzMode]` | Mode of tag | `'closeable' \| 'default' \| 'checkable'` | `'default'` |
2727
| `[nzChecked]` | Checked status of Tag, double binding, only works when `nzMode="checkable"` | `boolean` | `false` |
2828
| `[nzColor]` | Color of the Tag | `string` | - |
29+
| `[nzBordered]` | Whether has border style | `boolean` | `true` |
2930
| `(nzOnClose)` | Callback executed when tag is closed, only works when `nzMode="closable"` | `EventEmitter<MouseEvent>` | - |
3031
| `(nzCheckedChange)` | Checked status change call back, only works when `nzMode="checkable"` | `EventEmitter<boolean>` | - |

‎components/tag/doc/index.zh-CN.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ import { NzTagModule } from 'ng-zorro-antd/tag';
2626
| `[nzMode]` | 设定标签工作的模式 | `'closeable' \| 'default' \| 'checkable'` | `'default'` |
2727
| `[nzChecked]` | 设置标签的选中状态,可双向绑定,在 `nzMode="checkable"` 时可用 | `boolean` | `false` |
2828
| `[nzColor]` | 标签色 | `string` | - |
29+
| `[nzBordered]` | 是否有边框 | `boolean` | `true` |
2930
| `(nzOnClose)` | 关闭时的回调,在 `nzMode="closable"` 时可用 | `EventEmitter<MouseEvent>` | - |
3031
| `(nzCheckedChange)` | 设置标签的选中状态的回调,在 `nzMode="checkable"` 时可用 | `EventEmitter<void>` | - |

‎components/tag/style/index.less‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@
9494
background: @@lightColor;
9595
border-color: @@lightBorderColor;
9696
}
97+
98+
&-borderless {
99+
border-color: transparent;
100+
}
101+
97102
&-@{color}-inverse {
98103
color: @text-color-inverse;
99104
background: @@darkColor;

‎components/tag/tag.component.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import { NzIconModule } from 'ng-zorro-antd/icon';
6060
'[class.ant-tag-checkable]': `nzMode === 'checkable'`,
6161
'[class.ant-tag-checkable-checked]': `nzChecked`,
6262
'[class.ant-tag-rtl]': `dir === 'rtl'`,
63+
'[class.ant-tag-borderless]': `!nzBordered`,
6364
'(click)': 'updateCheckedStatus()'
6465
},
6566
imports: [NzIconModule, NgIf],
@@ -71,6 +72,7 @@ export class NzTagComponent implements OnChanges, OnDestroy, OnInit {
7172
@Input() nzMode: 'default' | 'closeable' | 'checkable' = 'default';
7273
@Input() nzColor?: string | NzStatusColor | NzPresetColor;
7374
@Input() @InputBoolean() nzChecked = false;
75+
@Input() @InputBoolean() nzBordered = true;
7476
@Output() readonly nzOnClose = new EventEmitter<MouseEvent>();
7577
@Output() readonly nzCheckedChange = new EventEmitter<boolean>();
7678
dir: Direction = 'ltr';

‎components/tag/tag.spec.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ describe('tag', () => {
9898
fixture.detectChanges();
9999
expect(tag.nativeElement.classList).not.toContain('ant-tag-has-color');
100100
});
101+
it('should have bordered by default', () => {
102+
expect(tag.nativeElement.classList).not.toContain('ant-tag-borderless');
103+
testComponent.bordered = false;
104+
fixture.detectChanges();
105+
expect(tag.nativeElement.classList).toContain('ant-tag-borderless');
106+
});
101107
});
102108
describe('prevent tag', () => {
103109
let fixture: ComponentFixture<NzTestTagPreventComponent>;
@@ -140,6 +146,7 @@ describe('tag', () => {
140146
[nzMode]="mode"
141147
[(nzChecked)]="checked"
142148
[nzColor]="color"
149+
[nzBordered]="bordered"
143150
(nzCheckedChange)="checkedChange($event)"
144151
(nzOnClose)="onClose()"
145152
>
@@ -151,6 +158,7 @@ export class NzTestTagBasicComponent {
151158
mode = 'default';
152159
color: string | undefined;
153160
checked = false;
161+
bordered = true;
154162
onClose = jasmine.createSpy('on close');
155163
afterClose = jasmine.createSpy('after close');
156164
checkedChange = jasmine.createSpy('after close');

0 commit comments

Comments
 (0)