From f4fcf7865bccb4dbce0187996b81f28dfdb6fc34 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Tue, 24 Jul 2018 19:09:28 +0200 Subject: [PATCH] build: avoid manually-maintained example lists (#12335) Reworks the demos that were using the docs examples to avoid having to hard-code the list of examples for each component. --- src/demo-app/table/table-demo.ts | 24 +++--------------------- src/demo-app/tabs/tabs-demo.ts | 14 ++------------ src/demo-app/tooltip/tooltip-demo.ts | 13 ++----------- 3 files changed, 7 insertions(+), 44 deletions(-) diff --git a/src/demo-app/table/table-demo.ts b/src/demo-app/table/table-demo.ts index 12efcf8577d..2f3f0dcdc6b 100644 --- a/src/demo-app/table/table-demo.ts +++ b/src/demo-app/table/table-demo.ts @@ -7,6 +7,7 @@ */ import {Component} from '@angular/core'; +import {EXAMPLE_COMPONENTS} from '@angular/material-examples'; @Component({ @@ -14,25 +15,6 @@ import {Component} from '@angular/core'; templateUrl: 'table-demo.html', }) export class TableDemo { - examples = [ - 'table-basic', - 'table-basic-flex', - 'cdk-table-basic', - 'cdk-table-basic-flex', - 'table-dynamic-columns', - 'table-filtering', - 'table-footer-row', - 'table-http', - 'table-overview', - 'table-pagination', - 'table-row-context', - 'table-selection', - 'table-sorting', - 'table-expandable-rows', - 'table-sticky-header', - 'table-sticky-columns', - 'table-sticky-footer', - 'table-sticky-complex', - 'table-sticky-complex-flex', - ]; + examples = Object.keys(EXAMPLE_COMPONENTS) + .filter(example => example.startsWith('table-') || example.startsWith('cdk-table-')); } diff --git a/src/demo-app/tabs/tabs-demo.ts b/src/demo-app/tabs/tabs-demo.ts index 5ac8d1a6b0b..a12e3abf9f5 100644 --- a/src/demo-app/tabs/tabs-demo.ts +++ b/src/demo-app/tabs/tabs-demo.ts @@ -7,6 +7,7 @@ */ import {Component} from '@angular/core'; +import {EXAMPLE_COMPONENTS} from '@angular/material-examples'; @Component({ moduleId: module.id, @@ -14,16 +15,5 @@ import {Component} from '@angular/core'; templateUrl: 'tabs-demo.html', }) export class TabsDemo { - examples = [ - 'tab-group-basic', - 'tab-group-dynamic-height', - 'tab-group-stretched', - 'tab-group-async', - 'tab-group-custom-label', - 'tab-group-header-below', - 'tab-group-theme', - 'tab-group-lazy-loaded', - 'tab-group-dynamic', - 'tab-nav-bar-basic', - ]; + examples = Object.keys(EXAMPLE_COMPONENTS).filter(example => example.startsWith('tab-')); } diff --git a/src/demo-app/tooltip/tooltip-demo.ts b/src/demo-app/tooltip/tooltip-demo.ts index 0c1378ee977..47a63ff2db8 100644 --- a/src/demo-app/tooltip/tooltip-demo.ts +++ b/src/demo-app/tooltip/tooltip-demo.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ import {Component} from '@angular/core'; +import {EXAMPLE_COMPONENTS} from '@angular/material-examples'; @Component({ moduleId: module.id, @@ -13,15 +14,5 @@ import {Component} from '@angular/core'; templateUrl: 'tooltip-demo.html', }) export class TooltipDemo { - examples = [ - 'tooltip-overview', - 'tooltip-position', - 'tooltip-disabled', - 'tooltip-message', - 'tooltip-delay', - 'tooltip-manual', - 'tooltip-modified-defaults', - 'tooltip-auto-hide', - 'tooltip-custom-class', - ]; + examples = Object.keys(EXAMPLE_COMPONENTS).filter(example => example.startsWith('tooltip-')); }