Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: added onMenuToggled event emitter, closes #35 #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion projects/angular-material-extensions/fab-menu/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@angular-material-extensions/fab-menu",
"description": "Angular Material component that allow users to select a county or nationality ",
"version": "6.1.0",
"version": "6.2.0",
"homepage": "https://angular-material-extensions.github.io/fab-menu",
"author": {
"name": "anthonynahas",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div [fxLayout]="layout" class="container" fxLayoutAlign="center center" fxLayoutGap="16px">
<div fxLayoutAlign="center">
<button (click)="isActive = !isActive"
<button (click)="toggle()"
[color]="color" [disabled]="disabled"
type="button"
[ngClass]="{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export class MatFabMenuComponent implements OnInit, OnChanges {
@Output()
onFabMenuItemSelected: EventEmitter<string | number> = new EventEmitter<string | number>();

// tslint:disable-next-line:no-output-on-prefix
@Output()
onFabMenuToggled: EventEmitter<boolean> = new EventEmitter<boolean>();

layout: any;
layout2: any;

Expand Down Expand Up @@ -98,12 +102,14 @@ export class MatFabMenuComponent implements OnInit, OnChanges {

toggle() {
this.isActive = !this.isActive;
this.onFabMenuToggled.emit(this.isActive);
}

selectFabMenu(fab: MatFabMenu) {
this.onFabMenuItemSelected.emit(fab.id);
if (this.closeAfterSelection) {
this.isActive = false;
this.onFabMenuToggled.emit(false);
}
}
}
9 changes: 8 additions & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,14 @@ <h2>Usage</h2>
</mat-card>

<!-- <mat-fab-menu color="primary" [fabButtons]="fabButtons" direction="top"></mat-fab-menu>-->
<mat-fab-menu class="fix-bottom-right" color="primary" [fabButtons]="fabCountries" direction="top"></mat-fab-menu>
<mat-fab-menu class="fix-bottom-right"
[icon]="icon"
color="primary"
[fabButtons]="fabCountries"
direction="top"
(onFabMenuToggled)="onFabMenuToggled($event)"
(onFabMenuItemSelected)="onFabMenuItemSelected($event)">
</mat-fab-menu>


<markdown src="assets/md/html.md"></markdown>
Expand Down
17 changes: 16 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, OnInit} from '@angular/core';
import {MatFabMenu, MatFabMenuDirection} from '@angular-material-extensions/fab-menu';
import {MatFabMenu, MatFabMenuDirection} from '../../projects/angular-material-extensions/fab-menu/src/lib/mat-fab-menu.component';
import { ThemePalette } from '@angular/material/core';

@Component({
Expand All @@ -16,6 +16,7 @@ export class AppComponent implements OnInit {
exampleIndex = 1;
exampleFabButtons: MatFabMenu[];
layout = 'end end';
icon: string = 'menu';

fabButtonsRandom: MatFabMenu[] = [
{
Expand Down Expand Up @@ -119,6 +120,20 @@ export class AppComponent implements OnInit {
}
}

onFabMenuToggled(open: boolean) {
console.log('on menu toggled', open);

if (open) {
this.icon = "add";
} else {
this.icon = "menu";
}
}

onFabMenuItemSelected(item: any) {
console.log('on menu item selected', item);
}

onExampleChanged($event: number) {
console.log('on example changed', $event);
switch ($event) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Angulartics2Module} from 'angulartics2';
import {MarkdownModule} from 'ngx-markdown';
import {FlexLayoutModule} from '@angular/flex-layout';
import {HttpClientModule} from '@angular/common/http';
import {MatFabMenuModule} from '@angular-material-extensions/fab-menu';
import {MatFabMenuModule} from '../../projects/angular-material-extensions/fab-menu/src/lib/mat-fab-menu.module';
import {FormsModule} from '@angular/forms';
import {MatRadioModule} from '@angular/material/radio';
import {MatSlideToggleModule} from '@angular/material/slide-toggle';
Expand Down