Skip to content

Commit b4c9900

Browse files
committed
refactor(material/badge): convert to standalone
Converts `material/badge` to standalone.
1 parent 40c9d8b commit b4c9900

File tree

5 files changed

+30
-13
lines changed

5 files changed

+30
-13
lines changed

src/material/badge/badge-module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import {A11yModule} from '@angular/cdk/a11y';
1212
import {MatBadge} from './badge';
1313

1414
@NgModule({
15-
imports: [A11yModule, MatCommonModule],
15+
imports: [A11yModule, MatCommonModule, MatBadge],
1616
exports: [MatBadge, MatCommonModule],
17-
declarations: [MatBadge],
1817
})
1918
export class MatBadgeModule {}

src/material/badge/badge.spec.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ describe('MatBadge', () => {
1414

1515
beforeEach(fakeAsync(() => {
1616
TestBed.configureTestingModule({
17-
imports: [MatBadgeModule],
18-
declarations: [BadgeOnInteractiveElement, PreExistingBadge, NestedBadge, BadgeOnTemplate],
17+
imports: [
18+
MatBadgeModule,
19+
BadgeOnInteractiveElement,
20+
PreExistingBadge,
21+
NestedBadge,
22+
BadgeOnTemplate,
23+
],
1924
}).compileComponents();
2025

2126
fixture = TestBed.createComponent(BadgeOnInteractiveElement);
@@ -227,8 +232,7 @@ describe('MatBadge', () => {
227232

228233
beforeEach(async () => {
229234
await TestBed.configureTestingModule({
230-
imports: [MatBadgeModule],
231-
declarations: [BadgeOnNonInteractiveElement],
235+
imports: [MatBadgeModule, BadgeOnNonInteractiveElement],
232236
}).compileComponents();
233237

234238
fixture = TestBed.createComponent(BadgeOnNonInteractiveElement);
@@ -287,6 +291,8 @@ describe('MatBadge', () => {
287291
home
288292
</button>
289293
`,
294+
standalone: true,
295+
imports: [MatBadgeModule],
290296
})
291297
class BadgeOnInteractiveElement {
292298
@ViewChild(MatBadge) badgeInstance: MatBadge;
@@ -300,7 +306,11 @@ class BadgeOnInteractiveElement {
300306
badgeDisabled = false;
301307
}
302308

303-
@Component({template: '<span matBadge="7" [matBadgeDescription]="description">Hello</span>'})
309+
@Component({
310+
template: '<span matBadge="7" [matBadgeDescription]="description">Hello</span>',
311+
standalone: true,
312+
imports: [MatBadgeModule],
313+
})
304314
class BadgeOnNonInteractiveElement {
305315
description = '';
306316
}
@@ -312,6 +322,8 @@ class BadgeOnNonInteractiveElement {
312322
<div class="mat-badge-content">Pre-existing badge</div>
313323
</span>
314324
`,
325+
standalone: true,
326+
imports: [MatBadgeModule],
315327
})
316328
class PreExistingBadge {}
317329

@@ -322,11 +334,15 @@ class PreExistingBadge {}
322334
<span matBadge="Hi">Something</span>
323335
</span>
324336
`,
337+
standalone: true,
338+
imports: [MatBadgeModule],
325339
})
326340
class NestedBadge {}
327341

328342
@Component({
329343
template: `
330344
<ng-template matBadge="1">Notifications</ng-template>`,
345+
standalone: true,
346+
imports: [MatBadgeModule],
331347
})
332348
class BadgeOnTemplate {}

src/material/badge/badge.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const BADGE_CONTENT_CLASS = 'mat-badge-content';
5858
'[class.mat-badge-hidden]': 'hidden || !content',
5959
'[class.mat-badge-disabled]': 'disabled',
6060
},
61+
standalone: true,
6162
})
6263
export class MatBadge implements OnInit, OnDestroy {
6364
/** The color of the badge. Can be `primary`, `accent`, or `warn`. */

src/material/badge/testing/badge-harness.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ describe('MatBadgeHarness', () => {
1111

1212
beforeEach(async () => {
1313
await TestBed.configureTestingModule({
14-
imports: [MatBadgeModule],
15-
declarations: [BadgeHarnessTest],
14+
imports: [MatBadgeModule, BadgeHarnessTest],
1615
}).compileComponents();
1716

1817
fixture = TestBed.createComponent(BadgeHarnessTest);
@@ -127,6 +126,8 @@ describe('MatBadgeHarness', () => {
127126
matBadge="Disabled badge"
128127
[matBadgeDisabled]="disabled">Disabled</button>
129128
`,
129+
standalone: true,
130+
imports: [MatBadgeModule],
130131
})
131132
class BadgeHarnessTest {
132133
simpleContent = 'Simple badge';

tools/public_api_guard/material/badge.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import { AriaDescriber } from '@angular/cdk/a11y';
88
import { ElementRef } from '@angular/core';
99
import * as i0 from '@angular/core';
10-
import * as i2 from '@angular/cdk/a11y';
11-
import * as i3 from '@angular/material/core';
10+
import * as i1 from '@angular/cdk/a11y';
11+
import * as i2 from '@angular/material/core';
1212
import { NgZone } from '@angular/core';
1313
import { OnDestroy } from '@angular/core';
1414
import { OnInit } from '@angular/core';
@@ -44,7 +44,7 @@ export class MatBadge implements OnInit, OnDestroy {
4444
position: MatBadgePosition;
4545
size: MatBadgeSize;
4646
// (undocumented)
47-
static ɵdir: i0.ɵɵDirectiveDeclaration<MatBadge, "[matBadge]", never, { "color": { "alias": "matBadgeColor"; "required": false; }; "overlap": { "alias": "matBadgeOverlap"; "required": false; }; "disabled": { "alias": "matBadgeDisabled"; "required": false; }; "position": { "alias": "matBadgePosition"; "required": false; }; "content": { "alias": "matBadge"; "required": false; }; "description": { "alias": "matBadgeDescription"; "required": false; }; "size": { "alias": "matBadgeSize"; "required": false; }; "hidden": { "alias": "matBadgeHidden"; "required": false; }; }, {}, never, never, false, never>;
47+
static ɵdir: i0.ɵɵDirectiveDeclaration<MatBadge, "[matBadge]", never, { "color": { "alias": "matBadgeColor"; "required": false; }; "overlap": { "alias": "matBadgeOverlap"; "required": false; }; "disabled": { "alias": "matBadgeDisabled"; "required": false; }; "position": { "alias": "matBadgePosition"; "required": false; }; "content": { "alias": "matBadge"; "required": false; }; "description": { "alias": "matBadgeDescription"; "required": false; }; "size": { "alias": "matBadgeSize"; "required": false; }; "hidden": { "alias": "matBadgeHidden"; "required": false; }; }, {}, never, never, true, never>;
4848
// (undocumented)
4949
static ɵfac: i0.ɵɵFactoryDeclaration<MatBadge, [null, null, null, null, { optional: true; }]>;
5050
}
@@ -56,7 +56,7 @@ export class MatBadgeModule {
5656
// (undocumented)
5757
static ɵinj: i0.ɵɵInjectorDeclaration<MatBadgeModule>;
5858
// (undocumented)
59-
static ɵmod: i0.ɵɵNgModuleDeclaration<MatBadgeModule, [typeof i1.MatBadge], [typeof i2.A11yModule, typeof i3.MatCommonModule], [typeof i1.MatBadge, typeof i3.MatCommonModule]>;
59+
static ɵmod: i0.ɵɵNgModuleDeclaration<MatBadgeModule, never, [typeof i1.A11yModule, typeof i2.MatCommonModule, typeof i3.MatBadge], [typeof i3.MatBadge, typeof i2.MatCommonModule]>;
6060
}
6161

6262
// @public

0 commit comments

Comments
 (0)