Coder Social home page Coder Social logo

brookesb91 / dismissible Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 5.0 305 KB

:mega: Animated dismissible alerts.

License: MIT License

CSS 46.05% JavaScript 53.95%
css html javacript vanilla-javascript alerts customisable dismissible-notices dismissible

dismissible's Introduction

Dismissible

dismissible

Dismissible animated alert banners written in plain ol' JavaScript.

Quick Start

Install with Node

$ npm i https://github.com/brookesb91/dismissible/releases/download/v1.0.0/dismissible-1.0.0.tgz

Include the dismissible styles in your HEAD tag

<head>
  <!-- Other head stuff... -->
  <link rel="stylesheet" href="path/to/dismissible.css" />
</head>

Include the dismissible script at the bottom of your BODY tag

<body>
  <!-- Other body stuff... -->
  <script src="path/to/dismissible.js"></script>
</body>

Add an element that will be used as the root container for dismissibles

<body>
  <div id="dismissible-container"></div>
  <!-- Rest of body -->
</body>

Create a Dismissible instance

const container = document.querySelector('#dismissible-container');
const dismissible = new Dismissible(container);

Show dismissibles

// Show informational prompt
dismissible.info('This is an informational alert.');

// Show successful action prompt
dismissible.success('This is a success alert.');

// Show error prompt
dismissible.error('This is an error alert.');

Info

Success

Error

Hide dismissibles

Dismissibles are dismissed when their dismiss button is clicked. However it is possible to dismiss them on demand.

dismissible.dismiss();

Custom icons

By default, dismissible use Lineicons library. You can easily replace the icons for a library of your preference.

Include your custom css icons library in your HEAD tag

<head>
  <!-- Other head stuff... -->
  <link rel="stylesheet" href="path/to/your/css/icons/library.css" />
</head>

Add an object with icons classes array to replace the default values

const container = document.querySelector('#dismissible-container');
const dismissible = new Dismissible(container,
  {
    icons: {
      dismiss: ["fas", "fa-times"], // Close icon classes
      info: ["fas", "fa-info"], // Info icon classes
      success: ["fas", "fa-check"], // Success icon classes
      error: ["fas", "fa-exclamation"], // Error icon classes
    },
  }
);

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.