Skip to content

Commit

Permalink
Merge pull request #756 from HealthCatalyst/dev
Browse files Browse the repository at this point in the history
dev -> master
  • Loading branch information
benjanderson authored Mar 4, 2019
2 parents df030b6 + 52b6cbe commit c1465f6
Show file tree
Hide file tree
Showing 21 changed files with 921 additions and 113 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ An Angular component library that makes any task feel luxurious.
- [Submit an Issue](http://cashmere.healthcatalyst.net/guides/submit-an-issue)
- [Supported Browsers](http://cashmere.healthcatalyst.net/guides/supported-browsers)

## Installing
## Installing to an Existing Project

Run `npm i --save @healthcatalyst/cashmere`.
- Run `npm i --save @healthcatalyst/cashmere`

## Running the Demo App
## Running the Demo Application

Run `npm run build && ng serve user-guide` to serve the demo application on port 4200.
- Clone the repository `git clone https://github.com/HealthCatalyst/Fabric.Cashmere.git`
- Run `cd Fabric.Cashmere && npm install && npm run build && npx ng serve user-guide`
- View the demo application at `http://localhost:4200`

## Sponsors

Thanks to [BrowserStack](http://www.browserstack.com) for kindly providing the project with free of charge automatic testing time.

![BrowserStack](https://raw.githubusercontent.com/HealthCatalyst/Fabric.Cashmere/master/Browserstack-logo@2x.png)
60 changes: 29 additions & 31 deletions guides/contribution-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
##### All May Contribute

We would love for you to contribute to Cashmere and be part of the community making this project better! To get started, follow the [Getting Started guide](http://cashmere.healthcatalyst.net/guides/getting-started).

:::

:::
Expand All @@ -15,12 +16,10 @@ We would love for you to contribute to Cashmere and be part of the community mak

1. Install the latest version of `node` with at _least_ version 8.9.
2. Fork the `@healthcatalyst/cashmere` repo.
3. Run `npm install -g commitizen`, which helps you with writing angular style commit messages.
4. Clone your fork.
Recommendation: name your git remotes `upstream` for `@healthcatalyst/cashmere`
5. From the root of the project, run `npm install`.
6. Running `npm run build` will build the entire project
7. `ng serve` will serve the default project which is `user-guide`
3. Clone your fork. Recommendation: name your git remotes `upstream` for `@healthcatalyst/cashmere`
4. From the root of the project, run `npm install`
5. Running `npm run build` will build the entire project.
6. `npx ng serve` will serve the default project which is `user-guide`

:::

Expand All @@ -30,27 +29,27 @@ We would love for you to contribute to Cashmere and be part of the community mak

### While Developing

1. First, run `npm run build`. (For windows users, sometimes you'll need to manually clear out the `/dist` folder first)
1. First, run `npm run build`. (For windows users, sometimes you'll need to manually clear out the `/dist` folder first).
2. Run `ng build cashmere --watch`. This will build the cashmere library, and fire off incremental builds when changes to library files are made.
3. In a separate console, run `ng serve`. Will fire up the user guide website, and rebuild/reload when changes are made to the user guide site or the Cashmere library.
4. If you makes changes to example files in `/projects/cashmere-examples/src/lib/` while developing, you'll need to manually rebuild these with `npm run build:examples`.
3. In a separate console, run `npx ng serve`. This will fire up the user guide website, and rebuild/reload when changes are made to the user guide site or the Cashmere library.
4. If you make changes to example files in `/projects/cashmere-examples/src/lib/` while developing, you'll need to manually rebuild these with `npm run build:examples`.

### PR's

Before you submit your pull request (PR), consider the following guidelines:

- Search [GitHub](https://github.com/HealthCatalyst/Fabric.Cashmere/pulls) for an open or closed PR that relates to your submission. You don't want to duplicate effort.
- Development happens on the `dev` branch and `master` is used to create a new release
- Development happens on the `dev` branch and `master` is used to create a new release.
- From the dev branch create a new branch. Here is a good [guide](https://gist.github.com/Chaser324/ce0505fbed06b947d962) if you're just getting started.
- Verify all changes look and function properly in different browsers and at different resolutions.
- Run the following commands:
- `ng lint` should result in `All files pass linting`
- `npx ng lint` should result in `All files pass linting`
- If there are problems with prettier linting rules, running `npm run prettier` can be helpful. This will automatically make needed formatting changes based on our prettier rules. For Windows users, runs best in bash.
- `ng test` should result in `All tests passing`
- `npm run build` should pass and build the library successfully
- `npx ng test` should result in `All tests passing`
- `npm run build` should pass and build the library successfully.
- New components and directives must be accompanied by:
- A component demonstrating the functionality; this component should be added to the demo app's routes
- Unit tests demonstrating that it functions as intended
- A component demonstrating the functionality; this component should be added to the demo app's routes.
- Unit tests demonstrating that it functions as intended.
- A new component should adhere to the [Health Catalyst style](http://cashmere.healthcatalyst.net).
- When creating a PR you must set the base branch to dev(master is for release only)
- "Squash and merge" a PR to complete it.
Expand All @@ -65,7 +64,7 @@ We have very precise rules over how our git commit messages can be formatted. Th
readable messages** that are easy to follow when looking through the **project history**. But also,
we use the git commit messages to **generate the Angular Material change log**.

(To help with creating commit messages you can use the tool `commitizen` and using `git cz` when you want to commit)
(To help with creating commit messages you can use the tool `commitizen` and run `npx git-cz` when you want to commit)

### Commit Message Format

Expand All @@ -82,7 +81,7 @@ format that includes a **type**, a **scope** and a **subject**:

The **header** is mandatory and the **scope** of the header is optional.

Any line of the commit message cannot be longer 100 characters! This allows the message to be easier
Any line of the commit message cannot be longer than 100 characters! This makes the message easier
to read on GitHub as well as in various git tools.

### Revert
Expand All @@ -95,30 +94,29 @@ the SHA of the commit being reverted.

Must be one of the following:

- **feat**: A new feature
- **fix**: A bug fix
- **docs**: Documentation only changes
- **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing
semi-colons, etc)
- **refactor**: A code change that neither fixes a bug nor adds a feature
- **perf**: A code change that improves performance
- **test**: Adding missing tests or correcting existing tests
- **feat**: A new feature.
- **fix**: A bug fix.
- **docs**: Documentation only changes.
- **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc).
- **refactor**: A code change that neither fixes a bug nor adds a feature.
- **perf**: A code change that improves performance.
- **test**: Adding missing tests or correcting existing tests.
- **build**: Changes that affect the build system, CI configuration or external dependencies
(example scopes: gulp, broccoli, npm)
- **chore**: Other changes that don't modify `src` or `test` files
(example scopes: gulp, broccoli, npm).
- **chore**: Other changes that don't modify `src` or `test` files.

### Scope

The scope could be anything specifying place of the commit change. For example
The scope could be anything specifying the place of the commit change. For example
`button`, `dialog`, etc.

### Subject

The subject contains succinct description of the change:

- use the imperative, present tense: "change" not "changed" nor "changes"
- don't capitalize first letter
- no dot (.) at the end
- use the imperative, present tense: "change" not "changed" nor "changes".
- don't capitalize first letter.
- no dot (.) at the end.

### Body

Expand Down
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>
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;
}
}
}

This file was deleted.

Loading

0 comments on commit c1465f6

Please sign in to comment.