-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #756 from HealthCatalyst/dev
dev -> master
- Loading branch information
Showing
21 changed files
with
921 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
...ects/cashmere-examples/src/lib/resizable-columns/resizable-columns-example.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<table hc-table [dataSource]="dataSource"> | ||
<!-- Position Column --> | ||
<ng-container hcColumnDef="position"> | ||
<th hc-header-cell *hcHeaderCellDef [style.width]="columnObjects[0].width + 'px'"> | ||
<span>{{ columnObjects[0].title }}</span> | ||
<hc-cell-resizer | ||
[width]="columnObjects[0].width" | ||
(resized)="columnResized(0, $event)" | ||
(resizing)="isResizing = $event" | ||
></hc-cell-resizer> | ||
</th> | ||
<td hc-cell *hcCellDef="let element" [style.width]="columnObjects[0].width + 'px'"> | ||
<span>{{ element.position }}</span> | ||
<hc-cell-resizer | ||
[width]="columnObjects[0].width" | ||
(resized)="columnResized(0, $event)" | ||
(resizing)="isResizing = $event" | ||
></hc-cell-resizer> | ||
</td> | ||
<td hc-footer-cell *hcFooterCellDef [style.width]="columnObjects[0].width + 'px'"> | ||
<span>{{ totalPositions }}</span> | ||
<hc-cell-resizer | ||
[width]="columnObjects[0].width" | ||
(resized)="columnResized(0, $event)" | ||
(resizing)="isResizing = $event" | ||
></hc-cell-resizer> | ||
</td> | ||
</ng-container> | ||
|
||
<!-- Name Column --> | ||
<ng-container hcColumnDef="name"> | ||
<th hc-header-cell *hcHeaderCellDef [style.width]="columnObjects[1].width + 'px'"> | ||
<span>{{ columnObjects[1].title }}</span> | ||
<hc-cell-resizer | ||
[width]="columnObjects[1].width" | ||
(resized)="columnResized(1, $event)" | ||
(resizing)="isResizing = $event" | ||
></hc-cell-resizer> | ||
</th> | ||
<td hc-cell *hcCellDef="let element" [style.width]="columnObjects[1].width + 'px'"> | ||
<span>{{ element.name }}</span> | ||
<hc-cell-resizer | ||
[width]="columnObjects[1].width" | ||
(resized)="columnResized(1, $event)" | ||
(resizing)="isResizing = $event" | ||
></hc-cell-resizer> | ||
</td> | ||
<td hc-footer-cell *hcFooterCellDef [style.width]="columnObjects[1].width + 'px'"> | ||
<span>{{ totalNames }}</span> | ||
<hc-cell-resizer | ||
[width]="columnObjects[1].width" | ||
(resized)="columnResized(1, $event)" | ||
(resizing)="isResizing = $event" | ||
></hc-cell-resizer> | ||
</td> | ||
</ng-container> | ||
|
||
<!-- Weight Column --> | ||
<ng-container hcColumnDef="weight"> | ||
<th hc-header-cell *hcHeaderCellDef [style.width]="columnObjects[2].width + 'px'"> | ||
<span>{{ columnObjects[2].title }}</span> | ||
<hc-cell-resizer | ||
[width]="columnObjects[2].width" | ||
(resized)="columnResized(2, $event)" | ||
(resizing)="isResizing = $event" | ||
></hc-cell-resizer> | ||
</th> | ||
<td hc-cell *hcCellDef="let element" [style.width]="columnObjects[2].width + 'px'"> | ||
<span>{{ element.weight }}</span> | ||
<hc-cell-resizer | ||
[width]="columnObjects[2].width" | ||
(resized)="columnResized(2, $event)" | ||
(resizing)="isResizing = $event" | ||
></hc-cell-resizer> | ||
</td> | ||
<td hc-footer-cell *hcFooterCellDef [style.width]="columnObjects[2].width + 'px'"> | ||
<span>{{ totalWeight }}</span> | ||
<hc-cell-resizer | ||
[width]="columnObjects[2].width" | ||
(resized)="columnResized(2, $event)" | ||
(resizing)="isResizing = $event" | ||
></hc-cell-resizer> | ||
</td> | ||
</ng-container> | ||
|
||
<!-- Symbol Column --> | ||
<ng-container hcColumnDef="symbol"> | ||
<th hc-header-cell *hcHeaderCellDef [style.width]="columnObjects[3].width + 'px'"> | ||
<span>{{ columnObjects[3].title }}</span> | ||
<hc-cell-resizer | ||
[width]="columnObjects[3].width" | ||
(resized)="columnResized(3, $event)" | ||
(resizing)="isResizing = $event" | ||
></hc-cell-resizer> | ||
</th> | ||
<td hc-cell *hcCellDef="let element" [style.width]="columnObjects[3].width + 'px'"> | ||
<span>{{ element.symbol }}</span> | ||
<hc-cell-resizer | ||
[width]="columnObjects[3].width" | ||
(resized)="columnResized(3, $event)" | ||
(resizing)="isResizing = $event" | ||
></hc-cell-resizer> | ||
</td> | ||
<td hc-footer-cell *hcFooterCellDef [style.width]="columnObjects[3].width + 'px'"> | ||
<span>{{ totalSymbols }}</span> | ||
<hc-cell-resizer | ||
[width]="columnObjects[3].width" | ||
(resized)="columnResized(3, $event)" | ||
(resizing)="isResizing = $event" | ||
></hc-cell-resizer> | ||
</td> | ||
</ng-container> | ||
|
||
<tr hc-header-row *hcHeaderRowDef="displayedColumns"></tr> | ||
<tr hc-row *hcRowDef="let row; columns: displayedColumns"></tr> | ||
<tr hc-footer-row *hcFooterRowDef="displayedColumns"></tr> | ||
</table> |
File renamed without changes.
67 changes: 67 additions & 0 deletions
67
projects/cashmere-examples/src/lib/resizable-columns/resizable-columns-example.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import {Component} from '@angular/core'; | ||
import {CellResizeEvent} from '@healthcatalyst/cashmere'; | ||
|
||
export interface PeriodicElement { | ||
name: string; | ||
position: number; | ||
weight: number; | ||
symbol: string; | ||
} | ||
|
||
export interface ColumnModel { | ||
title: string; | ||
width: number; | ||
minWidth: number; | ||
} | ||
|
||
const ELEMENT_DATA: PeriodicElement[] = [ | ||
{position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, | ||
{position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, | ||
{position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, | ||
{position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, | ||
{position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, | ||
{position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, | ||
{position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, | ||
{position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, | ||
{position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, | ||
{position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'} | ||
]; | ||
|
||
/** | ||
* @title Table with Resizeable Columns | ||
*/ | ||
@Component({ | ||
selector: 'hc-resizable-columns-example', | ||
templateUrl: 'resizable-columns-example.component.html', | ||
styleUrls: ['resizable-columns-example.component.scss'] | ||
}) | ||
export class ResizableColumnsExampleComponent { | ||
columnObjects: ColumnModel[] = [ | ||
{title: 'No.', width: 200, minWidth: 40}, | ||
{title: 'Name', width: 328, minWidth: 70}, | ||
{title: 'Weight', width: 200, minWidth: 60}, | ||
{title: 'Symbol', width: 200, minWidth: 60} | ||
]; | ||
displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; | ||
dataSource = ELEMENT_DATA; | ||
|
||
totalPositions = 'Totals'; | ||
totalNames = ELEMENT_DATA.length; | ||
totalWeight = ELEMENT_DATA.reduce((sum, el) => sum + el.weight, 0); | ||
totalSymbols = 'N/A'; | ||
|
||
isResizing = false; | ||
|
||
columnResized(column: number, cellChange: CellResizeEvent): void { | ||
let sizeChange = this.columnObjects[column].width - cellChange.width; | ||
let direction = cellChange.directionLeft ? -1 : 1; | ||
|
||
if ( | ||
cellChange.width >= this.columnObjects[column].minWidth && | ||
this.columnObjects[column + direction].width + sizeChange >= this.columnObjects[column + direction].minWidth | ||
) { | ||
this.columnObjects[column + direction].width += sizeChange; | ||
this.columnObjects[column].width = cellChange.width; | ||
} | ||
} | ||
} |
34 changes: 0 additions & 34 deletions
34
projects/cashmere-examples/src/lib/table-overview/table-overview-example.component.html
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.