-
Notifications
You must be signed in to change notification settings - Fork 6.8k
/
Copy pathexample-list.ts
82 lines (73 loc) · 2.14 KB
/
example-list.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
import {EXAMPLE_COMPONENTS} from '@angular/components-examples';
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
import {MatExpansionModule} from '@angular/material/expansion';
import {Example} from './example';
/** Displays a set of components-examples in a mat-accordion. */
@Component({
selector: 'material-example-list',
imports: [MatExpansionModule, Example],
template: `
<mat-accordion multi>
@for (id of ids; track id) {
<mat-expansion-panel [expanded]="expandAll">
<mat-expansion-panel-header>
<div class="header">
<div class="title">{{_getTitle(id)}}</div>
<div class="id"> <{{id}}> </div>
</div>
</mat-expansion-panel-header>
<ng-template matExpansionPanelContent>
<material-example [id]="id"></material-example>
</ng-template>
</mat-expansion-panel>
}
</mat-accordion>
`,
styles: `
mat-expansion-panel {
box-shadow: none !important;
border-radius: 0 !important;
background: transparent;
border-top: 1px solid #CCC;
}
.header {
display: flex;
justify-content: space-between;
width: 100%;
padding-right: 24px;
align-items: center;
}
.id {
font-family: monospace;
color: #666;
font-size: 12px;
}
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ExampleList {
/** Type of examples being displayed. */
@Input() type: string;
/** IDs of the examples to display. */
@Input() ids: string[];
@Input()
get expandAll(): boolean {
return this._expandAll;
}
set expandAll(v: BooleanInput) {
this._expandAll = coerceBooleanProperty(v);
}
_expandAll: boolean;
exampleComponents = EXAMPLE_COMPONENTS;
protected _getTitle(id: string) {
return this.exampleComponents[id]?.title;
}
}