Skip to content

Commit a0dcd56

Browse files
author
Nathan Tate
committed
3.4. Copy in the canonical MDC DOM and add the MDC styles
1 parent 1de1b98 commit a0dcd56

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
<!-- TODO: MDC template here. -->
1+
<div class="mdc-form-field">
2+
<div class="mdc-radio">
3+
<input class="mdc-radio__native-control" type="radio" [id]="inputId" name="radios">
4+
<div class="mdc-radio__background">
5+
<div class="mdc-radio__outer-circle"></div>
6+
<div class="mdc-radio__inner-circle"></div>
7+
</div>
8+
</div>
9+
<label [for]="inputId" ng-content></label>
10+
</div>
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
// TODO: MDC core styles here.
1+
@import '@material/radio/mixins';
2+
@import '@material/form-field/mixins';
3+
@import '../mdc-helpers/mdc-helpers';
4+
5+
6+
@include mdc-radio-without-ripple($query: $mat-base-styles-query);
7+
@include mdc-form-field-core-styles($query: $mat-base-styles-query);

src/material-experimental/mdc-radio/radio.ts

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

9-
import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core';
9+
import {ChangeDetectionStrategy, Component, ViewEncapsulation, Input} from '@angular/core';
1010

11+
// Increasing integer for generating unique ids for radio components.
12+
let nextUniqueId = 0;
13+
14+
/**
15+
* A Material design radio-button. Typically placed inside of `<mat-radio-group>` elements.
16+
*/
1117
@Component({
1218
moduleId: module.id,
13-
selector: 'mat-radio',
19+
selector: 'mat-radio-button',
1420
templateUrl: 'radio.html',
1521
styleUrls: ['radio.css'],
1622
host: {
@@ -22,4 +28,12 @@ import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/co
2228
})
2329
export class MatRadio {
2430
// TODO: set up MDC foundation class.
31+
32+
private _uniqueId: string = `mat-radio-${++nextUniqueId}`;
33+
34+
/** The unique ID for the radio button. */
35+
@Input() id: string = this._uniqueId;
36+
37+
/** ID of the native input element inside `<mat-radio-button>` */
38+
get inputId(): string { return `${this.id || this._uniqueId}-input`; }
2539
}

0 commit comments

Comments
 (0)