Skip to content

Commit 64f1963

Browse files
prototype(chips): Add MDC foundation
1 parent d50daef commit 64f1963

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

src/material-experimental/mdc-chips/chip-cell.html

Whitespace-only changes.

src/material-experimental/mdc-chips/chip-cell.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,31 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Directive} from '@angular/core';
9+
import {Component} from '@angular/core';
10+
import {MDCChipFoundation} from '@material/chips';
1011

11-
@Directive({
12+
@Component({
1213
selector: 'mat-chip-cell',
14+
templateUrl: 'chip-cell.html',
15+
styleUrls: ['chips.css'],
1316
host: {
1417
'class': 'mat-mdc-chip-cell',
18+
'(click)': '_chipFoundation.handleInteraction($event)',
19+
'(keydown)': '_chipFoundation.handleInteraction($event)'
1520
},
1621
})
1722
export class MatChipCell {
18-
// TODO: set up MDC foundation class.
23+
_chipFoundation: MDCChipFoundation;
24+
25+
constructor() {
26+
this._chipFoundation = new MDCChipFoundation();
27+
}
28+
29+
ngAfterViewInit() {
30+
this._chipFoundation.init();
31+
}
32+
33+
ngOnDestroy() {
34+
this._chipFoundation.destroy();
35+
}
1936
}

src/material-experimental/mdc-chips/chip-grid.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core';
9+
import {AfterViewInit, ChangeDetectionStrategy, Component, OnDestroy, ViewEncapsulation} from '@angular/core';
10+
import {MDCChipSetFoundation} from '@material/chips';
1011

1112
@Component({
1213
moduleId: module.id,
@@ -19,6 +20,18 @@ import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/co
1920
encapsulation: ViewEncapsulation.None,
2021
changeDetection: ChangeDetectionStrategy.OnPush,
2122
})
22-
export class MatChipGrid {
23-
// TODO: set up MDC foundation class.
23+
export class MatChipGrid implements AfterViewInit, OnDestroy {
24+
_chipSetFoundation: MDCChipSetFoundation;
25+
26+
constructor() {
27+
this._chipSetFoundation = new MDCChipSetFoundation();
28+
}
29+
30+
ngAfterViewInit() {
31+
this._chipSetFoundation.init();
32+
}
33+
34+
ngOnDestroy() {
35+
this._chipSetFoundation.destroy();
36+
}
2437
}

0 commit comments

Comments
 (0)