diff --git a/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.css b/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.css index 7432308753e6..54cb383a615b 100644 --- a/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.css +++ b/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.css @@ -1 +1,12 @@ -/** No CSS for this example */ +.example-section { + margin: 12px 0; +} + +.example-margin { + margin: 0 12px; +} + +ul { + list-style-type: none; + margin-top: 4px; +} diff --git a/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.html b/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.html index b5b049fae683..807d40030145 100644 --- a/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.html +++ b/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.html @@ -1 +1,26 @@ -Check me! +
+ Check me! + Disabled +
+ +
+ + + {{task.name}} + + + + + +
diff --git a/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.ts b/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.ts index 5ae9040e8b65..0a2ccfed39e5 100644 --- a/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.ts +++ b/src/components-examples/material/checkbox/checkbox-overview/checkbox-overview-example.ts @@ -1,4 +1,12 @@ import {Component} from '@angular/core'; +import {ThemePalette} from '@angular/material/core'; + +export interface Task { + name: string; + completed: boolean; + color: ThemePalette; + subtasks?: Task[]; +} /** * @title Basic checkboxes @@ -8,4 +16,36 @@ import {Component} from '@angular/core'; templateUrl: 'checkbox-overview-example.html', styleUrls: ['checkbox-overview-example.css'], }) -export class CheckboxOverviewExample {} +export class CheckboxOverviewExample { + task: Task = { + name: 'Indeterminate', + completed: false, + color: 'primary', + subtasks: [ + {name: 'Primary', completed: false, color: 'primary'}, + {name: 'Accent', completed: false, color: 'accent'}, + {name: 'Warn', completed: false, color: 'warn'} + ] + }; + + allComplete: boolean = false; + + updateAllComplete() { + this.allComplete = this.task.subtasks != null && this.task.subtasks.every(t => t.completed); + } + + someComplete(): boolean { + if (this.task.subtasks == null) { + return false; + } + return this.task.subtasks.filter(t => t.completed).length > 0 && !this.allComplete; + } + + setAll(completed: boolean) { + this.allComplete = completed; + if (this.task.subtasks == null) { + return; + } + this.task.subtasks.forEach(t => t.completed = completed); + } +} diff --git a/src/components-examples/material/checkbox/index.ts b/src/components-examples/material/checkbox/index.ts index cf90ffe79a4f..8cb793d06739 100644 --- a/src/components-examples/material/checkbox/index.ts +++ b/src/components-examples/material/checkbox/index.ts @@ -1,3 +1,4 @@ +import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; import {FormsModule} from '@angular/forms'; import {MatCardModule} from '@angular/material/card'; @@ -18,6 +19,7 @@ const EXAMPLES = [ @NgModule({ imports: [ + CommonModule, MatCardModule, MatCheckboxModule, MatRadioModule, diff --git a/src/dev-app/checkbox/BUILD.bazel b/src/dev-app/checkbox/BUILD.bazel index e4221ee1de05..38728e0e5232 100644 --- a/src/dev-app/checkbox/BUILD.bazel +++ b/src/dev-app/checkbox/BUILD.bazel @@ -11,6 +11,7 @@ ng_module( ":checkbox_demo_scss", ], deps = [ + "//src/components-examples/material/checkbox", "//src/material/checkbox", "//src/material/core", "//src/material/form-field", diff --git a/src/dev-app/checkbox/checkbox-demo-module.ts b/src/dev-app/checkbox/checkbox-demo-module.ts index 30f45534b841..513099988a07 100644 --- a/src/dev-app/checkbox/checkbox-demo-module.ts +++ b/src/dev-app/checkbox/checkbox-demo-module.ts @@ -7,6 +7,7 @@ */ import {CommonModule} from '@angular/common'; +import {CheckboxExamplesModule} from '@angular/components-examples/material/checkbox'; import {NgModule} from '@angular/core'; import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {MatCheckboxModule} from '@angular/material/checkbox'; @@ -25,6 +26,7 @@ import { @NgModule({ imports: [ + CheckboxExamplesModule, CommonModule, FormsModule, MatCheckboxModule, diff --git a/src/dev-app/checkbox/checkbox-demo.html b/src/dev-app/checkbox/checkbox-demo.html index 0c867edb0597..b14bf4c38ffa 100644 --- a/src/dev-app/checkbox/checkbox-demo.html +++ b/src/dev-app/checkbox/checkbox-demo.html @@ -245,3 +245,7 @@
No animations
+ +

Overview example

+ +