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

modal-basis

v0.2.4

Published

Simple modal component

Downloads

3

Readme

Modal Basis

Simple modal component

Works on modern browsers only (uses es6 modules and css custom properties)

Usage

The triggering element (button or anchor) needs to contain data-toggle="modal" attribute.

An eventual closing element needs to have the .dismiss class and to be inside the .modal element. It can only be triggered with a 'click' event.

Options

.--no-overlay

By default, triggering a .modal element will also trigger the page's #overlay element*. This behaviour can been changed by adding a .--no-overlay class on the .modal element.

<div class="modal --no-overlay">Lorem ipsum...</div>

*overlay element is dynamically included through Overlay Basis dependency.

.--lock-overlay

The .modal element is dismissed when the page's #overlay is clicked. To change this behaviour, just add a .--lock-overlay class on the .modal element.

<div class="modal --lock-overlay">Lorem ipsum...</div>

Let's see some 'core' examples (just wait for the 'modifier' section for funnier stuff):

Trigger a .modal with a button, through a [data-target] attribute

<!-- this button will toggle a '.modal' element which 'id' is 'targeted-modal' -->
<button data-toggle="modal" data-target="#targeted-modal">Show</button>

<!-- this is the '.modal' element that will be triggered -->
<div id="targeted-modal" class="modal">
    <button class="dismiss">Hide</button>
    <p>Lorem ipsum dolor sit amet...</p>
</div>

Trigger a .modal with an anchor, through a [href] attribute

<!-- this anchor tag will toggle a '.modal' element which 'id' is 'targeted-modal' -->
<a data-toggle="modal" href="#targeted-modal">Show</a>

<!-- this is the '.modal' element that will be triggered -->
<div id="targeted-modal" class="modal">
    <button class="dismiss">Hide</button>
    <p>Lorem ipsum dolor sit amet...</p>
</div>

Trigger a .modal with a button inside a .modal-group element

No need for a data-target or a href attributes on the triggering element here, but data-toggle="modal" is still mandatory.

<div class="modal-group">

    <!-- trigger and '.modal' are enclosed by a '.modal-group' element,
    no need for a [data-target] or a [href] attributes here -->
    <button data-toggle="modal">Show</button>

    <div class="modal">
        <button class="dismiss">Hide</button>
        <p>Lorem ipsum dolor sit amet...</p>
    </div>

</div>

Modifiers

Default .modal behaviour can be extended by adding some modifier classes.

Transitions

Modal Basis has a few bonus classes to make a .modal element slide from one side of the screen: .--transition-top, .--transition-right, .--transition-bottom, .--transition-left:

<div class="modal --transition-left">

There is also a .--transition-scale modifier:

<div class="modal --transition-scale">

Modal dialog box

The .--type-dialog class constrains the .modal element to the center of the view (horizontally and vertically).

Its dimensions are reduced to half its width by default: <div class="modal --type-dialog">

It can also leverage a transition modifier: <div class="modal --type-dialog --transition-top">