Skip to content

prototype(checkbox): create radio checkbox based on MDC Web - 3.4. Copy in the canonical MDC DOM and add the MDC styles #16656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/material-experimental/mdc-radio/radio.html
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
<!-- TODO: MDC template here. -->
<div class="mdc-form-field">
<div class="mdc-radio">
<input class="mdc-radio__native-control" type="radio" [id]="inputId" name="radios">
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
<label [for]="inputId" ng-content></label>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this ng-content attribute?

</div>
8 changes: 7 additions & 1 deletion src/material-experimental/mdc-radio/radio.scss
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
// TODO: MDC core styles here.
@import '@material/radio/mixins';
@import '@material/form-field/mixins';
@import '../mdc-helpers/mdc-helpers';


@include mdc-radio-without-ripple($query: $mat-base-styles-query);
@include mdc-form-field-core-styles($query: $mat-base-styles-query);
18 changes: 16 additions & 2 deletions src/material-experimental/mdc-radio/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
* found in the LICENSE file at https://angular.io/license
*/

import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core';
import {ChangeDetectionStrategy, Component, ViewEncapsulation, Input} from '@angular/core';

// Increasing integer for generating unique ids for radio components.
let nextUniqueId = 0;

/**
* A Material design radio-button. Typically placed inside of `<mat-radio-group>` elements.
*/
@Component({
moduleId: module.id,
selector: 'mat-radio',
selector: 'mat-radio-button',
templateUrl: 'radio.html',
styleUrls: ['radio.css'],
host: {
Expand All @@ -22,4 +28,12 @@ import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/co
})
export class MatRadio {
// TODO: set up MDC foundation class.

private _uniqueId: string = `mat-radio-${++nextUniqueId}`;

/** The unique ID for the radio button. */
@Input() id: string = this._uniqueId;

/** ID of the native input element inside `<mat-radio-button>` */
get inputId(): string { return `${this.id || this._uniqueId}-input`; }
}