Skip to content

Commit df01dcc

Browse files
authoredNov 11, 2022
feat(abc:notice-icon): add centered property (#1546)
1 parent 04e97f1 commit df01dcc

File tree

6 files changed

+27
-14
lines changed

6 files changed

+27
-14
lines changed
 

‎packages/abc/notice-icon/index.en-US.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Used on the navigation toolbar as a unified notification center for the entire p
1717
| `[data]` | Data | `NoticeItem[]` | - |
1818
| `[count]` | Total number of messages on the icon | `number` | - |
1919
| `[loading]` | Pop up card loading status | `boolean` | `false` |
20+
| `[centered]` | Whether the tab is centered | `boolean` | `false` |
2021
| `(select)` | Click the callback of the list item | `EventEmitter<NoticeIconSelect>` | - |
2122
| `(clear)` | Callback for clicking the clear button | `EventEmitter<string>` | - |
2223
| `[popoverVisible]` | Manual control of Popover display | `boolean` | `false` |

‎packages/abc/notice-icon/index.zh-CN.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module: import { NoticeIconModule } from '@delon/abc/notice-icon';
1717
| `[data]` | 数据 | `NoticeItem[]` | - |
1818
| `[count]` | 图标上的消息总数 | `number` | - |
1919
| `[loading]` | 弹出卡片加载状态 | `boolean` | `false` |
20+
| `[centered]` | 标签页是否居中 | `boolean` | `false` |
2021
| `(select)` | 点击列表项的回调 | `EventEmitter<NoticeIconSelect>` | - |
2122
| `(clear)` | 点击清空按钮的回调 | `EventEmitter<string>` | - |
2223
| `[popoverVisible]` | 手动控制Popover显示 | `boolean` | `false` |

‎packages/abc/notice-icon/notice-icon.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
(nzVisibleChange)="onVisibleChange($event)"
1414
nzTrigger="click"
1515
nzPlacement="bottomRight"
16-
nzOverlayClassName="header-dropdown notice-icon"
16+
[nzOverlayClassName]="overlayCls"
1717
[nzDropdownMenu]="noticeMenu"
1818
>
1919
<ng-template [ngTemplateOutlet]="badgeTpl"></ng-template>
2020
</div>
2121
<nz-dropdown-menu #noticeMenu="nzDropdownMenu">
2222
<nz-spin [nzSpinning]="loading" [nzDelay]="0">
23-
<nz-tabset nzSelectedIndex="0">
23+
<nz-tabset nzSelectedIndex="0" [nzCentered]="centered">
2424
<nz-tab *ngFor="let i of data" [nzTitle]="i.title">
2525
<notice-icon-tab
2626
[locale]="locale"

‎packages/abc/notice-icon/notice-icon.component.ts

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class NoticeIconComponent implements OnInit, OnChanges, OnDestroy {
3131
static ngAcceptInputType_count: NumberInput;
3232
static ngAcceptInputType_loading: BooleanInput;
3333
static ngAcceptInputType_popoverVisible: BooleanInput;
34+
static ngAcceptInputType_centered: BooleanInput;
3435

3536
private i18n$!: Subscription;
3637
locale: LocaleData = {};
@@ -41,10 +42,15 @@ export class NoticeIconComponent implements OnInit, OnChanges, OnDestroy {
4142
@Input() @InputBoolean() popoverVisible = false;
4243
@Input() btnClass?: NgClassType;
4344
@Input() btnIconClass?: NgClassType;
45+
@Input() @InputBoolean() centered = false;
4446
@Output() readonly select = new EventEmitter<NoticeIconSelect>();
4547
@Output() readonly clear = new EventEmitter<string>();
4648
@Output() readonly popoverVisibleChange = new EventEmitter<boolean>();
4749

50+
get overlayCls(): string {
51+
return `header-dropdown notice-icon${!this.centered ? ' notice-icon__tab-left' : ''}`;
52+
}
53+
4854
constructor(private i18n: DelonLocaleService, private cdr: ChangeDetectorRef) {}
4955

5056
onVisibleChange(result: boolean): void {

‎packages/abc/notice-icon/notice-icon.spec.ts

+11
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ describe('abc: notice-icon', () => {
9898
done();
9999
}, CLICKTIME);
100100
});
101+
it('#centered', done => {
102+
context.centered = true;
103+
context.popoverVisible = true;
104+
fixture.detectChanges();
105+
setTimeout(() => {
106+
expect(document.querySelectorAll('.notice-icon__tab-left').length).toBe(0);
107+
done();
108+
}, CLICKTIME);
109+
});
101110
});
102111

103112
it('#i18n', done => {
@@ -123,6 +132,7 @@ describe('abc: notice-icon', () => {
123132
[data]="data"
124133
[count]="count"
125134
[loading]="loading"
135+
[centered]="centered"
126136
(select)="select($event)"
127137
(clear)="clear($event)"
128138
[(popoverVisible)]="popoverVisible"
@@ -178,6 +188,7 @@ class TestComponent {
178188
];
179189
count = 10;
180190
loading = false;
191+
centered = false;
181192
popoverVisible?: boolean;
182193
select(): void {}
183194
clear(): void {}

‎packages/abc/notice-icon/style/index.less

+6-12
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,16 @@
1717
&-bar {
1818
margin-bottom: 4px;
1919
}
20+
}
2021

21-
&-nav {
22-
.@{ant-prefix}-tabs-tab {
23-
margin-right: 32px;
24-
padding: 12px 16px;
25-
26-
&:last-child {
27-
margin-right: 0;
28-
}
29-
}
30-
31-
&-scroll {
32-
text-align: center;
22+
&__tab-left {
23+
.@{ant-prefix}-tabs-nav-list {
24+
.@{ant-prefix}-tabs-tab:first-child {
25+
margin-left: @tabs-horizontal-gutter;
3326
}
3427
}
3528
}
29+
3630
.@{ant-prefix}-list {
3731
max-height: 400px;
3832
overflow: auto;

0 commit comments

Comments
 (0)
Please sign in to comment.