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

launchy-modal-window

v0.9.2

Published

Launchy! – An Accessible Modal Window

Downloads

11

Readme

Build Status npm version

Launchy! 🚀

An accessible modal window! — https://launchy.io

Features include:

  • Easy to use and implement!
  • On launch, keyboard focus shifts to the modal window container
  • The modal window is described via optional modal heading
  • Traps the keyboard focus within the modal when active/visible
  • Closes the window on esc key press
  • Closes the window on overlay mouse click
  • Sets keyboard focus back to the launcher element on window close
  • Add your own custom close controls!
  • Add your own custom controls which send focus to somewhere else on the page!
  • Transparent border for Windows High Contrast themes

For more details on the accessibility of modal windows:

  • WCAG 2.4.3: https://www.w3.org/TR/UNDERSTANDING-WCAG20/navigation-mechanisms-focus-order.html#navigation-mechanisms-focus-order-examples-head
  • WAI-ARIA Authoring Practices 1.1: https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal

Demo

  • Check out the demo! 👈
  • Try your own HTML with the CodePen demo!

Usage

Launchy! is very easy to install and use:

HTML

Wherever you want to have a Launchy! control + window appear in your HTML content, simply wrap your content with a <div> and add the data-launchy attribute.

Example:

<div data-launchy data-launchy-text="Launch window!" data-launchy-title="My modal window">
    <p>This content will appear in the modal window.</p>
</div>
  • Required: data-launchy -- Attribute is required but the value can be anything
  • Required: data-launchy-text -- This is the text that will be output to the launcher control
  • Optional: data-launchy-title -- The text which appears in the heading of the modal window, recommended for greater a11y context 👍
  • Optional: data-launchy-button -- If you'd rather have button elements instead of the default a elements as launcher and close controls

Custom Close Controls

You can add your own custom close controls to any Launchy! modal window!

  1. Add the HTML element you wish to use for the control within your content
  2. Apply the data-launchy-close attribute

Example:

<div data-launchy data-launchy-text="Launch window!" data-launchy-title="My modal window">
    <p>This content will appear in the modal window.</p>
    <a href="#" data-launchy-close="🔥">Ok!</a>
</div>

Clicking on the "Ok!" link will hide the modal window and send focus back to the launcher control!

Custom Refocus Controls

You can add your own custom "refocus" controls to any Launchy! modal window!

  1. Add the HTML element you wish to use for the control within your content
  2. Apply the data-launchy-refocus attribute
  3. Set the value of the data-launchy-refocus attribute to the id of the element you wish to send focus to

Example:

<div data-launchy data-launchy-text="Launch window!" data-launchy-title="My modal window">
    <p>This content will appear in the modal window.</p>
    <a href="#" data-launchy-refocus="post-title">Send me to the article headline!</a>
</div>

<!-- Somewhere else in your page… -->
<h1 id="post-title" tabindex="-1">My perfect sundae…</h1>

Clicking on the "Send me to the article headline!" link will hide the modal window and shift keyboard focus to the <h1 id="post-title"/> element!

CSS

Launchy! has many CSS classes available on its generated elements for custom styles. Check out the style.scss file for class names and an example on how you might want to style your modal windows!

JavaScript

For any site, grab the /dist/launchy.js file and include it at the bottom of your HTML page/template:

<script src="js/launchy.js"></script>

Launchy! will run automatically and generate all the modal windows for you!

npm Package

Launchy! is also available as an npm package!

Install

npm i launchy-modal-window

Usage

Include the launchy.js directly in your app or site template.

<script src="node_modules/launchy-modal-window/launchy.js"></script>

Contributions

See the CONTRIBUTING file.

License

See the LICENSE file.