npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-mat-menu

v1.2.7

Published

⚡ Try it on [StackBlitz](https://stackblitz.com/edit/angular-lnjubx)!

Downloads

125

Readme

Angular Material Menu

⚡ Try it on StackBlitz!

Menu

Getting started

Installation:

Install via npm package manager

npm i ngx-mat-menu

Prerequisites:

  npm i -s @angular/flex-layout
 ng add @angular/material

Usage:

Inputs:

  @Input() themeSidebar: Theme; // {background: 'white', color: 'black'};
  @Input() themeHeader: Theme; // {background: 'white', color: 'black'};
  @Input() arrMenuOptions: Array<MenuOptions>; // required. List of menu items.
  @Input() headerText: string; // required, Header text e.g. current user. 
  @Input() headerIcon: string; // optional, Header icon next to header text.
  @Input() logoutIcon: string; // optional, lgout icon next to logout text.
  @Input() badgeColor: string; // optional, default is black, color of menu item selects
  @Input() srcLogo: string; // optional, logo at teh top line.
  @Input() heightLogo: string; // optional, height of the logo.
  @Input() widthLogo: string; // optional, width of the logo.
  @Input() lang: string; // optional default is en (see below in switch)
  @Input() visibleNotif: boolean; // optional, default is false/undefined, notification badge
  @Input() badge: number; // number of notifications
  @Input() defaultWidth: string; // default width of the menu sidebar
  @Input() colorSidebarHeader: string; // sidebar header text color
  @Input() borderHeader: string; // border style of the header line(top)
  @Input() borderSidebar: string; // border style of the sidebar(left)
  @Input() borderSidebarHeader: string; // border style of the sidebar header(left)
  @Input() borderSidebarFooter: string; // border style of the sidebar footer(left)
  @Input() borderMenuItems: string; // border style of the sidebar menu items(left)

  @Output() openNotif = new EventEmitter(); // event on notifications click()
  @Output() logoutEvent = new EventEmitter(); // event on logout click()

Module:

Import ngx-mat-menu


import { NgxMatMenuModule } from  'ngx-mat-menu';

@NgModule({

imports: [ NgxMatMenuModule ]

})

HTML:

Add ngx-mat-menu

<ngx-mat-menu
  style="height: 100%;width: 100%;"
  [arrMenuOptions]="arrMenuOptions"
  [headerText]="headerText"
  [badgeColor]="badgeColor"
  [headerIcon]="headerIcon"
  [logoutIcon]="logoutIcon"
  [srcLogo]="srcLogo"
  [heightLogo]="heightLogo"
  [widthLogo]="widthLogo"
  [lang]="lang"
  [themeSidebar]="themeSidebar"
  [themeHeader]="themeHeader"
  [visibleNotif]="visibleNotif"
  [badge]="badge"
  [colorSidebarHeader]="'white'"
  [defaultWidth]="'400px'"
  (openNotif)="openNotif($event)"
  (logoutEvent)="logout()"
>
  <router-outlet></router-outlet>
</ngx-mat-menu>

TypeScript:


import { Component } from "@angular/core";
import { Router } from "@angular/router";
import { MenuOptions, Theme } from "ngx-mat-menu";
...
themeSidebar: Theme;
themeHeader: Theme;
arrMenuOptions: MenuOptions[];
headerText: string;
badgeColor: any;
loginRoute: string;
headerIcon: string;
logoutIcon: any;
srcLogo: string;
heightLogo: string;
widthLogo: string;
lang: string;
visibleNotif: boolean;
badge: number = 1;

constructor() {
    this.themeSidebar = { background: "#e53935", color: "white" };
    this.themeHeader = { background: "white", color: "gray" };
    this.arrMenuOptions = [
      { id: 0, title: "HOME", icon: null, route: "home" }, // example component to navigate
      { id: 1, title: "SETTINGS", icon: null, route: "settings" }, // example component to navigate
    ];
    this.headerText = "current_user";
    this.badgeColor = "white";
    this.headerIcon = "person";
    this.logoutIcon = "reply";
    this.srcLogo = "https://imgur.com/rNZ9Ncz.png";
    this.lang = "en";
    this.visibleNotif = true;
}

openNotif(event) {
  this.badge = 0;
}

logout() {
  this.router.navigate(['']);
}

Models:

MenuOptions:

export interface MenuOptions {
  id: number;
  title: string;
  icon?: string;
  route: string;
}

Theme:

export interface Theme {
  background: string;
  color: string;
}

Show/hide menu in components (e.g. LoginComponent):


// LoginComponent (hide on login)
import { Component, OnInit } from '@angular/core';
import { NgxMatMenuService } from 'ngx-mat-menu';
import { Router } from '@angular/router';

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {

  constructor(
    private menuService: NgxMatMenuService,
    private router: Router
  ) {
    menuService.changeMenu(false);
  }

  ngOnInit() {
  }

  btnLogin_Click() {
    this.router.navigate(['home']); // example component to navigate
  }

}