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
    },
  }
);

dismissible's People

Contributors

brookesb91 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dismissible's Issues

Banner Not Displayed Without a z-index

This seems to be caused when there's an absolute positioned (hidden) element on the page. In my case there's an element below the dismissible banner container with the following styles:

   position: absolute! important;
    overflow: hidden;
    clip: rect(0 0 0 0);
    height: 1px;
    width: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
}

When I add a z-index to the dismissible banner it is shown. When I remove the position property on the aforementioned element without adding a z-index to the dismissible banner it partially shows.

I know an example is key. I can email you a link. Just don't want to put the URL here as it's a publicly accessible test site.

npm package

I'm searching around the internet for dismissible alert libraries and this seems to be one of the only ones! I'm not sure if I'm going to use it yet or not, since it looks like it's brand new and not very popular yet, but for anyone who does, an npm package install would help a lot.

Don't Require LineIcons

One of the great things about this library is its size. Unfortunately it depends on LineIcons, whose CSS is larger that both this library's CSS and JS.

One can exclude LineIcons but then the X to close the banner is not visible. One must then add something like:

.lni-close::after {
    content: 'X';
}

I would be great to have defaults that don't require an external library.

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.