Giter Club home page Giter Club logo

mat-snackbar-severity's Introduction

MatSnackbarSeverity

Angular Library that adds severity (inspired by bootstrap alerts) to Material Design's mat-snack-bar.

This Angular library is a functional extension of the mat-snack-bar component since it only applies its own design (but respecting the material design guideline) encapsulating the applied customization. Being an extension it supports all the native functionality of mat-snack-bar.

Examples

This bookstore has two appearances

  • filled
  • outlined

Filled in the light theme:

Filled in the dark theme:

Outlined in the light theme:

Outlined in the dark theme:

Outlined Dark in the light theme:

Install

/* Be sure to import the material modules */
npm i @angular/cdk@currentVersion
npm i @angular/material@currentVersion

/* Import library */
npm i mat-snackbar-severity

Examples code

Import into the module to use:

import { MatSnackbarSeverityModule } from 'mat-snackbar-severity';

@NgModule({
  declarations: [
    ...
  ],
  imports: [
    ...

    MatSnackbarSeverityModule
  ],
  bootstrap: [...]
})
export class AppModule { }

Defined scss in global styles:

/* Make sure you are importing the global mixin of material: */
@include angular-material-theme($candy-app-theme);

/* or in the case of using another theme then specify the following mixins: */
@include mat-snack-bar-theme($candy-app-theme);
@include mat-button-theme($candy-app-theme);

/* design filled */
@import '~mat-snackbar-severity/mat-snackbar-severity-filled';

/* design light outlined */
@import '~mat-snackbar-severity/mat-snackbar-severity-outlined';

/* design dark outlined */
$severity-is-dark-theme: true;
@import '~mat-snackbar-severity/mat-snackbar-severity-outlined';

Use:

import { Component, OnInit } from '@angular/core';
import { MatSnackbarSeverity, SnackbarSeverity } from 'mat-snackbar-severity';

@Component({
  ...
})
export class AppComponent implements OnInit {

  constructor(
    ...
    private snackBarSeverity: MatSnackbarSeverity
  ) { }

  openSnackbarSeverity() {

    const severity: SnackbarSeverity = 'success';

    this.snackBarSeverity.open(severity, 'Success Message', 'Ok', {
        verticalPosition: 'top',
        horizontalPosition: 'right'
      });

    // this.snackBarSeverity.open('error', 'Error Message', 'Ok');
    // this.snackBarSeverity.open('warning', 'Warning Message', 'Ok');
    // this.snackBarSeverity.open('info', 'Info Message', 'Ok');
  }

}

Options severity

export declare type SnackbarSeverity = 'error' | 'warning' | 'info' | 'success';

mat-snackbar-severity's People

Contributors

j1myx avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

mat-snackbar-severity's Issues

Missing License

Can you add a license for this project ?
I can not use it without a license.
Also can you tell me if it is possible to customize the icon used in the snackbar ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.