|
3 | 3 | class="mat-elevation-z8"> |
4 | 4 | @for (column of columnsToDisplay; track column) { |
5 | 5 | <ng-container matColumnDef="{{column}}"> |
6 | | - <th mat-header-cell *matHeaderCellDef> {{column}} </th> |
7 | | - <td mat-cell *matCellDef="let element"> {{element[column]}} </td> |
| 6 | + <th mat-header-cell *matHeaderCellDef>{{column}}</th> |
| 7 | + <td mat-cell *matCellDef="let element">{{element[column]}}</td> |
8 | 8 | </ng-container> |
9 | 9 | } |
10 | 10 | <ng-container matColumnDef="expand"> |
11 | 11 | <th mat-header-cell *matHeaderCellDef aria-label="row actions"> </th> |
12 | 12 | <td mat-cell *matCellDef="let element"> |
13 | | - <button mat-icon-button aria-label="expand row" (click)="(expandedElement = expandedElement === element ? null : element); $event.stopPropagation()"> |
14 | | - @if (expandedElement === element) { |
15 | | - <mat-icon>keyboard_arrow_up</mat-icon> |
16 | | - } @else { |
17 | | - <mat-icon>keyboard_arrow_down</mat-icon> |
18 | | - } |
| 13 | + <button |
| 14 | + mat-icon-button |
| 15 | + aria-label="expand row" |
| 16 | + (click)="toggle(element); $event.stopPropagation()" |
| 17 | + class="example-toggle-button" |
| 18 | + [class.example-toggle-button-expanded]="isExpanded(element)"> |
| 19 | + <mat-icon>keyboard_arrow_down</mat-icon> |
19 | 20 | </button> |
20 | 21 | </td> |
21 | 22 | </ng-container> |
22 | 23 |
|
23 | 24 | <!-- Expanded Content Column - The detail row is made up of this one column that spans across all columns --> |
24 | 25 | <ng-container matColumnDef="expandedDetail"> |
25 | 26 | <td mat-cell *matCellDef="let element" [attr.colspan]="columnsToDisplayWithExpand.length"> |
26 | | - <div class="example-element-detail" |
27 | | - [@detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'"> |
28 | | - <div class="example-element-diagram"> |
29 | | - <div class="example-element-position"> {{element.position}} </div> |
30 | | - <div class="example-element-symbol"> {{element.symbol}} </div> |
31 | | - <div class="example-element-name"> {{element.name}} </div> |
32 | | - <div class="example-element-weight"> {{element.weight}} </div> |
33 | | - </div> |
34 | | - <div class="example-element-description"> |
35 | | - {{element.description}} |
36 | | - <span class="example-element-description-attribution"> -- Wikipedia </span> |
| 27 | + <div class="example-element-detail-wrapper" |
| 28 | + [class.example-element-detail-wrapper-expanded]="isExpanded(element)"> |
| 29 | + <div class="example-element-detail"> |
| 30 | + <div class="example-element-diagram"> |
| 31 | + <div class="example-element-position">{{element.position}}</div> |
| 32 | + <div class="example-element-symbol">{{element.symbol}}</div> |
| 33 | + <div class="example-element-name">{{element.name}}</div> |
| 34 | + <div class="example-element-weight">{{element.weight}}</div> |
| 35 | + </div> |
| 36 | + <div class="example-element-description"> |
| 37 | + {{element.description}} |
| 38 | + <span class="example-element-description-attribution"> -- Wikipedia </span> |
| 39 | + </div> |
37 | 40 | </div> |
38 | 41 | </div> |
39 | 42 | </td> |
|
42 | 45 | <tr mat-header-row *matHeaderRowDef="columnsToDisplayWithExpand"></tr> |
43 | 46 | <tr mat-row *matRowDef="let element; columns: columnsToDisplayWithExpand;" |
44 | 47 | class="example-element-row" |
45 | | - [class.example-expanded-row]="expandedElement === element" |
46 | | - (click)="expandedElement = expandedElement === element ? null : element"> |
| 48 | + [class.example-expanded-row]="isExpanded(element)" |
| 49 | + (click)="toggle(element)"> |
47 | 50 | </tr> |
48 | 51 | <tr mat-row *matRowDef="let row; columns: ['expandedDetail']" class="example-detail-row"></tr> |
49 | 52 | </table> |
0 commit comments