This repository has been archived by the owner on Feb 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
1,296 additions
and
539 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
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
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,24 @@ | ||
# Material | ||
|
||
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.2.0. | ||
|
||
## Code scaffolding | ||
|
||
Run `ng generate component component-name --project material` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project material`. | ||
> Note: Don't forget to add `--project material` or else it will be added to the default project in your `angular.json` file. | ||
## Build | ||
|
||
Run `ng build material` to build the project. The build artifacts will be stored in the `dist/` directory. | ||
|
||
## Publishing | ||
|
||
After building your library with `ng build material`, go to the dist folder `cd dist/material` and run `npm publish`. | ||
|
||
## Running unit tests | ||
|
||
Run `ng test material` to execute the unit tests via [Karma](https://karma-runner.github.io). | ||
|
||
## Further help | ||
|
||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). |
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,32 @@ | ||
// Karma configuration file, see link for more information | ||
// https://karma-runner.github.io/1.0/config/configuration-file.html | ||
|
||
module.exports = function (config) { | ||
config.set({ | ||
basePath: '', | ||
frameworks: ['jasmine', '@angular-devkit/build-angular'], | ||
plugins: [ | ||
require('karma-jasmine'), | ||
require('karma-chrome-launcher'), | ||
require('karma-jasmine-html-reporter'), | ||
require('karma-coverage-istanbul-reporter'), | ||
require('@angular-devkit/build-angular/plugins/karma') | ||
], | ||
client: { | ||
clearContext: false // leave Jasmine Spec Runner output visible in browser | ||
}, | ||
coverageIstanbulReporter: { | ||
dir: require('path').join(__dirname, '../../coverage/material'), | ||
reports: ['html', 'lcovonly'], | ||
fixWebpackSourcePaths: true | ||
}, | ||
reporters: ['progress', 'kjhtml'], | ||
port: 9876, | ||
colors: true, | ||
logLevel: config.LOG_INFO, | ||
autoWatch: true, | ||
browsers: ['Chrome'], | ||
singleRun: false, | ||
restartOnFileChange: true | ||
}); | ||
}; |
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,7 @@ | ||
{ | ||
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json", | ||
"dest": "../../dist/material", | ||
"lib": { | ||
"entryFile": "src/public_api.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,10 @@ | ||
{ | ||
"name": "@ng-action-outlet/material", | ||
"version": "0.0.0-development", | ||
"peerDependencies": { | ||
"@angular/common": "^7.2.0", | ||
"@angular/core": "^7.2.0", | ||
"@angular/material": "^7.2.0", | ||
"@ng-action-outlet/core": "^0.0.0-development" | ||
} | ||
} |
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,62 @@ | ||
import { Component, Input, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core'; | ||
import { ActionButton, ActionButtonComponentImpl, ActionGroup } from '@ng-action-outlet/core'; | ||
|
||
import { isMenuItem } from './common'; | ||
|
||
@Component({ | ||
selector: 'action-mat-button', | ||
template: ` | ||
<ng-container *ngIf="action.visible$ | async"> | ||
<ng-container *ngIf="action && isMenuItem(); then menuItem else button"></ng-container> | ||
</ng-container> | ||
<ng-template #button> | ||
<ng-container *ngIf="action.title$ | async; then titleButton else iconButton"></ng-container> | ||
</ng-template> | ||
<ng-template #titleButton> | ||
<button | ||
type="button" | ||
mat-button | ||
(click)="action.trigger()" | ||
[disabled]="action.disabled$ | async"> | ||
<ng-container [ngTemplateOutlet]="content"></ng-container> | ||
</button> | ||
</ng-template> | ||
<ng-template #iconButton> | ||
<button | ||
type="button" | ||
mat-icon-button | ||
(click)="action.trigger()" | ||
[disabled]="action.disabled$ | async"> | ||
<ng-container [ngTemplateOutlet]="content"></ng-container> | ||
</button> | ||
</ng-template> | ||
<ng-template #menuItem> | ||
<button | ||
type="button" | ||
mat-menu-item | ||
(click)="action.trigger()" | ||
[disabled]="action.disabled$ | async"> | ||
<ng-container [ngTemplateOutlet]="content"></ng-container> | ||
</button> | ||
</ng-template> | ||
<ng-template #content> | ||
<mat-icon *ngIf="action.icon$ | async; let icon">{{ icon }}</mat-icon> | ||
{{ action.title$ | async }} | ||
</ng-template> | ||
`, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
encapsulation: ViewEncapsulation.None | ||
}) | ||
export class ActionMatButtonComponent implements ActionButtonComponentImpl { | ||
@Input() | ||
readonly action: ActionButton; | ||
|
||
isMenuItem() { | ||
return isMenuItem(this.action.getParent()); | ||
} | ||
} |
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,58 @@ | ||
import { Component, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core'; | ||
import { ActionGroup, ActionGroupComponentImpl } from '@ng-action-outlet/core'; | ||
|
||
import { isMenuItem } from './common'; | ||
|
||
@Component({ | ||
selector: 'action-mat-group', | ||
template: ` | ||
<ng-container *ngIf="action.visible$ | async"> | ||
<ng-container *ngIf="action.dropdown$ | async; then dropdown else group"></ng-container> | ||
</ng-container> | ||
<ng-template #group> | ||
<mat-divider *ngIf="showDivider()"></mat-divider> | ||
<ng-container *ngFor="let child of action.children$ | async" [actionOutlet]="child"></ng-container> | ||
</ng-template> | ||
<ng-template #dropdown> | ||
<mat-menu #menu="matMenu"> | ||
<ng-template matMenuContent> | ||
<ng-container *ngFor="let child of action.children$ | async" [actionOutlet]="child"></ng-container> | ||
</ng-template> | ||
</mat-menu> | ||
<ng-container *ngIf="isMenuItem(); then menuItem else menuButton"></ng-container> | ||
<ng-template #menuItem> | ||
<button | ||
type="button" | ||
mat-menu-item | ||
[matMenuTriggerFor]="menu" | ||
[disabled]="action.disabled$ | async"> | ||
<mat-icon *ngIf="action.icon$ | async; let icon">{{ icon }}</mat-icon> | ||
{{ action.title$ | async }} | ||
</button> | ||
</ng-template> | ||
<ng-template #menuButton> | ||
<action-mat-button *ngIf="action.disabled$ | async" [action]="action"></action-mat-button> | ||
<action-mat-button *ngIf="!(action.disabled$ | async)" [matMenuTriggerFor]="menu" [action]="action"></action-mat-button> | ||
</ng-template> | ||
</ng-template> | ||
`, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
encapsulation: ViewEncapsulation.None | ||
}) | ||
export class ActionMatGroupComponent implements ActionGroupComponentImpl { | ||
readonly action: ActionGroup; | ||
|
||
isMenuItem() { | ||
return isMenuItem(this.action.getParent()); | ||
} | ||
|
||
showDivider() { | ||
const parent = this.action.getParent(); | ||
return parent && parent.isDropdown() && parent.getChild(0) !== this.action; | ||
} | ||
} |
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,38 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { ActionOutletModule, ActionButton, ActionGroup } from '@ng-action-outlet/core'; | ||
import { MatButtonModule, MatMenuModule, MatIconModule, MatDividerModule } from '@angular/material'; | ||
|
||
import { ActionMatButtonComponent } from './action-mat-button.component'; | ||
import { ActionMatGroupComponent } from './action-mat-group.component'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
ActionOutletModule, | ||
MatButtonModule, | ||
MatMenuModule, | ||
MatIconModule, | ||
MatDividerModule | ||
], | ||
declarations: [ | ||
ActionMatButtonComponent, | ||
ActionMatGroupComponent | ||
], | ||
entryComponents: [ | ||
ActionMatButtonComponent, | ||
ActionMatGroupComponent | ||
], | ||
exports: [ | ||
ActionMatButtonComponent, | ||
ActionMatGroupComponent | ||
], | ||
providers: [{ | ||
provide: ActionButton, | ||
useValue: ActionMatButtonComponent | ||
}, { | ||
provide: ActionGroup, | ||
useValue: ActionMatGroupComponent | ||
}] | ||
}) | ||
export class ActionMatModule { } |
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,5 @@ | ||
import { AnyAction, ActionGroup } from '@ng-action-outlet/core'; | ||
|
||
export const isMenuItem = (action: AnyAction) => { | ||
return action && (action instanceof ActionGroup && action.isDropdown() || isMenuItem(action.getParent())); | ||
}; |
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,7 @@ | ||
/* | ||
* Public API Surface of material | ||
*/ | ||
|
||
export * from './lib/action-mat-button.component'; | ||
export * from './lib/action-mat-group.component'; | ||
export * from './lib/action-mat.module'; |
Oops, something went wrong.