Skip to content

Commit f4fcf78

Browse files
crisbetommalerba
authored andcommitted
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.
1 parent ed4e082 commit f4fcf78

File tree

3 files changed

+7
-44
lines changed

3 files changed

+7
-44
lines changed

src/demo-app/table/table-demo.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,14 @@
77
*/
88

99
import {Component} from '@angular/core';
10+
import {EXAMPLE_COMPONENTS} from '@angular/material-examples';
1011

1112

1213
@Component({
1314
moduleId: module.id,
1415
templateUrl: 'table-demo.html',
1516
})
1617
export class TableDemo {
17-
examples = [
18-
'table-basic',
19-
'table-basic-flex',
20-
'cdk-table-basic',
21-
'cdk-table-basic-flex',
22-
'table-dynamic-columns',
23-
'table-filtering',
24-
'table-footer-row',
25-
'table-http',
26-
'table-overview',
27-
'table-pagination',
28-
'table-row-context',
29-
'table-selection',
30-
'table-sorting',
31-
'table-expandable-rows',
32-
'table-sticky-header',
33-
'table-sticky-columns',
34-
'table-sticky-footer',
35-
'table-sticky-complex',
36-
'table-sticky-complex-flex',
37-
];
18+
examples = Object.keys(EXAMPLE_COMPONENTS)
19+
.filter(example => example.startsWith('table-') || example.startsWith('cdk-table-'));
3820
}

src/demo-app/tabs/tabs-demo.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,13 @@
77
*/
88

99
import {Component} from '@angular/core';
10+
import {EXAMPLE_COMPONENTS} from '@angular/material-examples';
1011

1112
@Component({
1213
moduleId: module.id,
1314
selector: 'tabs-demo',
1415
templateUrl: 'tabs-demo.html',
1516
})
1617
export class TabsDemo {
17-
examples = [
18-
'tab-group-basic',
19-
'tab-group-dynamic-height',
20-
'tab-group-stretched',
21-
'tab-group-async',
22-
'tab-group-custom-label',
23-
'tab-group-header-below',
24-
'tab-group-theme',
25-
'tab-group-lazy-loaded',
26-
'tab-group-dynamic',
27-
'tab-nav-bar-basic',
28-
];
18+
examples = Object.keys(EXAMPLE_COMPONENTS).filter(example => example.startsWith('tab-'));
2919
}

src/demo-app/tooltip/tooltip-demo.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,13 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
import {Component} from '@angular/core';
9+
import {EXAMPLE_COMPONENTS} from '@angular/material-examples';
910

1011
@Component({
1112
moduleId: module.id,
1213
selector: 'tooltip-demo',
1314
templateUrl: 'tooltip-demo.html',
1415
})
1516
export class TooltipDemo {
16-
examples = [
17-
'tooltip-overview',
18-
'tooltip-position',
19-
'tooltip-disabled',
20-
'tooltip-message',
21-
'tooltip-delay',
22-
'tooltip-manual',
23-
'tooltip-modified-defaults',
24-
'tooltip-auto-hide',
25-
'tooltip-custom-class',
26-
];
17+
examples = Object.keys(EXAMPLE_COMPONENTS).filter(example => example.startsWith('tooltip-'));
2718
}

0 commit comments

Comments
 (0)