Skip to content

Commit

Permalink
feat(material/table): migrate MDC examples (#25492)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewseguin committed Aug 19, 2022
1 parent 556e69a commit a8f847c
Show file tree
Hide file tree
Showing 129 changed files with 337 additions and 158 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -205,7 +205,7 @@
/src/dev-app/mdc-snack-bar/** @andrewseguin
/src/dev-app/mdc-slide-toggle/** @crisbeto
/src/dev-app/mdc-slider/** @devversion
/src/dev-app/mdc-table/** @andrewseguin
/src/dev-app/legacy-table/** @andrewseguin
/src/dev-app/mdc-tabs/** @crisbeto
/src/dev-app/mdc-tooltip/** @crisbeto
/src/dev-app/menu/** @crisbeto
Expand Down
File renamed without changes.
Expand Up @@ -3,7 +3,7 @@ load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite"
package(default_visibility = ["//visibility:public"])

ng_module(
name = "mdc-table",
name = "legacy-table",
srcs = glob(
["**/*.ts"],
exclude = ["**/*.spec.ts"],
Expand Down Expand Up @@ -47,7 +47,7 @@ ng_test_library(
name = "unit_tests_lib",
srcs = glob(["**/*.spec.ts"]),
deps = [
":mdc-table",
":legacy-table",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/legacy-table",
Expand Down
134 changes: 134 additions & 0 deletions src/components-examples/material/legacy-table/index.ts
@@ -0,0 +1,134 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {MatRippleModule} from '@angular/material/core';
import {MatLegacyButtonModule} from '@angular/material/legacy-button';
import {MatButtonToggleModule} from '@angular/material/button-toggle';
import {MatLegacyCheckboxModule} from '@angular/material/legacy-checkbox';
import {MatIconModule} from '@angular/material/icon';
import {MatLegacyInputModule} from '@angular/material/legacy-input';
import {MatLegacyPaginatorModule} from '@angular/material/legacy-paginator';
import {MatLegacyProgressSpinnerModule} from '@angular/material/legacy-progress-spinner';
import {MatSortModule} from '@angular/material/sort';
import {MatLegacyTableModule} from '@angular/material/legacy-table';
import {DragDropModule} from '@angular/cdk/drag-drop';
import {CdkTableModule} from '@angular/cdk/table';

import {TableFlexBasicExample} from './table-flex-basic/table-flex-basic-example';
import {TableBasicExample} from './table-basic/table-basic-example';
import {TableDynamicColumnsExample} from './table-dynamic-columns/table-dynamic-columns-example';
import {TableExpandableRowsExample} from './table-expandable-rows/table-expandable-rows-example';
import {TableFilteringExample} from './table-filtering/table-filtering-example';
import {TableFooterRowExample} from './table-footer-row/table-footer-row-example';
import {TableHttpExample} from './table-http/table-http-example';
import {TableMultipleHeaderFooterExample} from './table-multiple-header-footer/table-multiple-header-footer-example';
import {TableOverviewExample} from './table-overview/table-overview-example';
import {TablePaginationExample} from './table-pagination/table-pagination-example';
import {TableRowContextExample} from './table-row-context/table-row-context-example';
import {TableSelectionExample} from './table-selection/table-selection-example';
import {TableSortingExample} from './table-sorting/table-sorting-example';
import {TableStickyColumnsExample} from './table-sticky-columns/table-sticky-columns-example';
import {TableStickyComplexFlexExample} from './table-sticky-complex-flex/table-sticky-complex-flex-example';
import {TableStickyComplexExample} from './table-sticky-complex/table-sticky-complex-example';
import {TableStickyFooterExample} from './table-sticky-footer/table-sticky-footer-example';
import {TableStickyHeaderExample} from './table-sticky-header/table-sticky-header-example';
import {TableTextColumnAdvancedExample} from './table-text-column-advanced/table-text-column-advanced-example';
import {TableTextColumnExample} from './table-text-column/table-text-column-example';
import {TableWrappedExample, WrapperTable} from './table-wrapped/table-wrapped-example';
import {TableReorderableExample} from './table-reorderable/table-reorderable-example';
import {TableRecycleRowsExample} from './table-recycle-rows/table-recycle-rows-example';
import {TableHarnessExample} from './table-harness/table-harness-example';
import {TableWithRipplesExample} from './table-with-ripples/table-with-ripples-example';
import {TableColumnStylingExample} from './table-column-styling/table-column-styling-example';
import {TableRowBindingExample} from './table-row-binding/table-row-binding-example';
import {TableDynamicArrayDataExample} from './table-dynamic-array-data/table-dynamic-array-data-example';
import {TableDynamicObservableDataExample} from './table-dynamic-observable-data/table-dynamic-observable-data-example';
import {TableGeneratedColumnsExample} from './table-generated-columns/table-generated-columns-example';

export {
TableBasicExample,
TableColumnStylingExample,
TableDynamicArrayDataExample,
TableDynamicColumnsExample,
TableDynamicObservableDataExample,
TableExpandableRowsExample,
TableFilteringExample,
TableFlexBasicExample,
TableFooterRowExample,
TableGeneratedColumnsExample,
TableHarnessExample,
TableHttpExample,
TableMultipleHeaderFooterExample,
TableOverviewExample,
TablePaginationExample,
TableRecycleRowsExample,
TableReorderableExample,
TableRowBindingExample,
TableRowContextExample,
TableSelectionExample,
TableSortingExample,
TableStickyColumnsExample,
TableStickyComplexExample,
TableStickyComplexFlexExample,
TableStickyFooterExample,
TableStickyHeaderExample,
TableTextColumnAdvancedExample,
TableTextColumnExample,
TableWithRipplesExample,
TableWrappedExample,
WrapperTable,
};

const EXAMPLES = [
TableBasicExample,
TableColumnStylingExample,
TableDynamicArrayDataExample,
TableDynamicColumnsExample,
TableDynamicObservableDataExample,
TableExpandableRowsExample,
TableFilteringExample,
TableFlexBasicExample,
TableFooterRowExample,
TableGeneratedColumnsExample,
TableHarnessExample,
TableHttpExample,
TableMultipleHeaderFooterExample,
TableOverviewExample,
TablePaginationExample,
TableRecycleRowsExample,
TableReorderableExample,
TableRowBindingExample,
TableRowContextExample,
TableSelectionExample,
TableSortingExample,
TableStickyColumnsExample,
TableStickyComplexExample,
TableStickyComplexFlexExample,
TableStickyFooterExample,
TableStickyHeaderExample,
TableTextColumnAdvancedExample,
TableTextColumnExample,
TableWithRipplesExample,
TableWrappedExample,
WrapperTable,
];

@NgModule({
imports: [
CommonModule,
MatLegacyButtonModule,
MatButtonToggleModule,
MatLegacyCheckboxModule,
MatIconModule,
MatLegacyInputModule,
MatLegacyPaginatorModule,
MatLegacyProgressSpinnerModule,
MatRippleModule,
MatSortModule,
MatLegacyTableModule,
CdkTableModule,
DragDropModule,
],
declarations: EXAMPLES,
exports: EXAMPLES,
})
export class TableExamplesModule {}
Expand Up @@ -2,6 +2,6 @@ table {
width: 100%;
}

tr.mat-mdc-footer-row td {
tr.mat-footer-row {
font-weight: bold;
}
Expand Up @@ -8,6 +8,6 @@
</td>
</ng-container>

<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
Expand Up @@ -42,5 +42,5 @@
</table>
</div>

<mat-paginator [length]="resultsLength" [pageSize]="30"></mat-paginator>
<mat-paginator [length]="resultsLength" [pageSize]="30" aria-label="Select page of GitHub search results"></mat-paginator>
</div>
Expand Up @@ -39,6 +39,5 @@
</tr>
</table>

<mat-paginator [pageSizeOptions]="[5, 10, 25, 100]"></mat-paginator>
<mat-paginator [pageSizeOptions]="[5, 10, 25, 100]" aria-label="Select page of users"></mat-paginator>
</div>

Expand Up @@ -29,5 +29,8 @@
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>

<mat-paginator [pageSizeOptions]="[5, 10, 20]" showFirstLastButtons></mat-paginator>
<mat-paginator [pageSizeOptions]="[5, 10, 20]"
showFirstLastButtons
aria-label="Select page of periodic elements">
</mat-paginator>
</div>
Expand Up @@ -2,13 +2,13 @@
width: 100%;
}

.mat-mdc-row .mat-mdc-cell {
.mat-row .mat-cell {
border-bottom: 1px solid transparent;
border-top: 1px solid transparent;
cursor: pointer;
}

.mat-mdc-row:hover .mat-mdc-cell {
.mat-row:hover .mat-cell {
border-color: currentColor;
}

Expand Down
@@ -1,26 +1,35 @@
<table mat-table [dataSource]="dataSource" matSort class="mat-elevation-z8">
<table mat-table [dataSource]="dataSource" matSort (matSortChange)="announceSortChange($event)"
class="mat-elevation-z8">

<!-- Position Column -->
<ng-container matColumnDef="position">
<th mat-header-cell *matHeaderCellDef mat-sort-header> No. </th>
<th mat-header-cell *matHeaderCellDef mat-sort-header sortActionDescription="Sort by number">
No.
</th>
<td mat-cell *matCellDef="let element"> {{element.position}} </td>
</ng-container>

<!-- Name Column -->
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Name </th>
<th mat-header-cell *matHeaderCellDef mat-sort-header sortActionDescription="Sort by name">
Name
</th>
<td mat-cell *matCellDef="let element"> {{element.name}} </td>
</ng-container>

<!-- Weight Column -->
<ng-container matColumnDef="weight">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Weight </th>
<th mat-header-cell *matHeaderCellDef mat-sort-header sortActionDescription="Sort by weight">
Weight
</th>
<td mat-cell *matCellDef="let element"> {{element.weight}} </td>
</ng-container>

<!-- Symbol Column -->
<ng-container matColumnDef="symbol">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Symbol </th>
<th mat-header-cell *matHeaderCellDef mat-sort-header sortActionDescription="Sort by symbol">
Symbol
</th>
<td mat-cell *matCellDef="let element"> {{element.symbol}} </td>
</ng-container>

Expand Down
@@ -1,5 +1,6 @@
import {LiveAnnouncer} from '@angular/cdk/a11y';
import {AfterViewInit, Component, ViewChild} from '@angular/core';
import {MatSort} from '@angular/material/sort';
import {MatSort, Sort} from '@angular/material/sort';
import {MatLegacyTableDataSource} from '@angular/material/legacy-table';

export interface PeriodicElement {
Expand Down Expand Up @@ -34,9 +35,24 @@ export class TableSortingExample implements AfterViewInit {
displayedColumns: string[] = ['position', 'name', 'weight', 'symbol'];
dataSource = new MatLegacyTableDataSource(ELEMENT_DATA);

constructor(private _liveAnnouncer: LiveAnnouncer) {}

@ViewChild(MatSort) sort: MatSort;

ngAfterViewInit() {
this.dataSource.sort = this.sort;
}

/** Announce the change in sort state for assistive technology. */
announceSortChange(sortState: Sort) {
// This example uses English messages. If your application supports
// multiple language, you would internationalize these strings.
// Furthermore, you can customize the message to add additional
// details about the values being sorted.
if (sortState.direction) {
this._liveAnnouncer.announce(`Sorted ${sortState.direction}ending`);
} else {
this._liveAnnouncer.announce('Sorting cleared');
}
}
}
Expand Up @@ -18,10 +18,10 @@ th.mat-column-position, td.mat-column-position {
padding-left: 8px;
}

.mat-mdc-table-sticky-border-elem-right {
.mat-table-sticky-border-elem-right {
border-left: 1px solid #e0e0e0;
}

.mat-mdc-table-sticky-border-elem-left {
.mat-table-sticky-border-elem-left {
border-right: 1px solid #e0e0e0;
}
Expand Up @@ -3,7 +3,7 @@
overflow: auto;
}

.mat-mdc-table-sticky {
.mat-table-sticky {
background: #59abfd;
opacity: 1;
}
Expand All @@ -18,27 +18,27 @@
text-align: center;
}

.mat-mdc-header-cell, .mat-mdc-footer-cell, .mat-mdc-cell {
.mat-header-cell, .mat-footer-cell, .mat-cell {
min-width: 80px;
box-sizing: border-box;
}

.mat-mdc-header-row, .mat-mdc-footer-row, .mat-mdc-row {
.mat-header-row, .mat-footer-row, .mat-row {
min-width: 1920px; /* 24 columns, 80px each */
}

.mat-mdc-table-sticky-border-elem-top {
.mat-table-sticky-border-elem-top {
border-bottom: 2px solid midnightblue;
}

.mat-mdc-table-sticky-border-elem-right {
.mat-table-sticky-border-elem-right {
border-left: 2px solid midnightblue;
}

.mat-mdc-table-sticky-border-elem-bottom {
.mat-table-sticky-border-elem-bottom {
border-top: 2px solid midnightblue;
}

.mat-mdc-table-sticky-border-elem-left {
.mat-table-sticky-border-elem-left {
border-right: 2px solid midnightblue;
}
Expand Up @@ -3,7 +3,7 @@
overflow: auto;
}

.mat-mdc-table-sticky {
.mat-table-sticky {
background: #59abfd;
opacity: 1;
}
Expand All @@ -18,23 +18,23 @@
text-align: center;
}

.mat-mdc-header-cell, .mat-mdc-footer-cell, .mat-mdc-cell {
.mat-header-cell, .mat-footer-cell, .mat-cell {
min-width: 80px;
box-sizing: border-box;
}

.mat-mdc-table-sticky-border-elem-top {
.mat-table-sticky-border-elem-top {
border-bottom: 2px solid midnightblue;
}

.mat-mdc-table-sticky-border-elem-right {
.mat-table-sticky-border-elem-right {
border-left: 2px solid midnightblue;
}

.mat-mdc-table-sticky-border-elem-bottom {
.mat-table-sticky-border-elem-bottom {
border-top: 2px solid midnightblue;
}

.mat-mdc-table-sticky-border-elem-left {
.mat-table-sticky-border-elem-left {
border-right: 2px solid midnightblue;
}

0 comments on commit a8f847c

Please sign in to comment.