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

@sitelintcode/accessible-gallery

v1.2.16

Published

Create accessible gallery from a given images

Downloads

124

Readme

Accessible Gallery

Accessible Gallery allows you to create an image gallery automatically directly from the HTML.

Demo

Accessible Images Gallery

Getting started

  1. First download the package:
npm install @sitelintcode/accessible-gallery --save
  1. Setup HTML structure:
  <ul class="accessible-gallery" data-accessible-gallery
      data-accessible-gallery-config='{"galleryTitle":"Gallery of images in a modal dialog","loadingMessage":"The image is being loaded","closeButtonMessage":"Close gallery", "previousImage":"Previous","nextImage":"Next", "closeButton":"Close dialog"}'>

      <li class="accessible-gallery__item" data-accessible-gallery-item>
        <a href="#no_image" data-accessible-gallery-link>
          <img loading="lazy" alt="Placeholder" data-accessible-gallery-thumbnail="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdjOHPmzH8ACDADZKt3GNsAAAAASUVORK5CYII=" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdjOHPmzH8ACDADZKt3GNsAAAAASUVORK5CYII=">
        </a>
      </li>

      <li class="accessible-gallery__item" data-accessible-gallery-item>
        <a href="images/castelmezzano-1979546_1920.jpeg" data-accessible-gallery-link>
          <img loading="lazy" alt="Castelmezzano by night" src="images/castelmezzano-1979546_1920_thumbnail.jpeg" data-accessible-gallery-thumbnail="images/castelmezzano-1979546_1920_thumbnail.jpeg">
        </a>
      </li>

      <li class="accessible-gallery__item" data-accessible-gallery-item>
        <a href="images/sunset-3325080_1920.jpeg" data-accessible-gallery-link>
          <img loading="lazy" alt="Sunset in mountains" src="images/sunset-3325080_1920_thumbnail.jpeg" data-accessible-gallery-thumbnail="images/sunset-3325080_1920_thumbnail.jpeg">
        </a>
      </li>

  </ul>
  1. Use:
  import AccessibleGallery from '@sitelint/accessible-gallery';

  const accessibleGallery = new AccessibleGallery();

  accessibleGallery.init();

Notes

Features

  1. The gallery supports image preloding for previous / next image using.
  2. While loading the image the message is being displayed to give a feedback when loading image takes more than 1 second. The message appears with 1 second delay to avoid "blinking" when the image is loaded faster than 1 second.
  3. The gallery should be fully responsive and adapt to all viewport sizes.
  4. Gallery supports base64 encoded images. Example: src="data:image/png;base64,...".
  5. The left/right swipe gesture is supported. Very useful on mobile devices.

Technical

  1. import { terser } from "rollup-plugin-terser"; was replaced with import { terser } from "rollup-plugin-minification"; because rollup-plugin-terser is not compatible with Rollup 3.x version. See: https://github.com/TrySound/rollup-plugin-terser/issues/119
  2. At the moment the gallery code is being executed on DOMContentLoaded event automatically. Eventually, if event DOMContentLoaded was called after Accessible Gallery code was loaded then the gallery will run immediately.

Options

Localisation

Optionally you may want to set custom messages, e.g. for localisation purpose. An attribute data-accessible-gallery-config contains config for all strings.

{
  "galleryTitle": "Gallery of images in a modal dialog",
  "loadingMessage": "The image is being loaded",
  "closeButtonMessage": "Close gallery",
  "previousImage": "Previous",
  "nextImage": "Next",
  "closeButton": "Close dialog"
}

Note: above config is being stored as a valid JSON string under attribute data-accessible-gallery-config.

Mini thumbnails (tiny image preview)

The data-accessible-gallery-thumbnail attribute allow you to specify a custom small thumbnail generated at the very bottom of the page. Keep the value empty when you want to pick the image src.

Examples

This <img loading="lazy" alt="Castelmezzano by night" src="images/castelmezzano-1979546_1920_thumbnail.jpeg" data-accessible-gallery-thumbnail="images/castelmezzano-1979546_1920_bottom_thumbnail.jpeg"> will pick images/castelmezzano-1979546_1920_bottom_thumbnail.jpeg when rendering mini thumbnails at the very bottom of the page.

This <img loading="lazy" alt="Castelmezzano by night" src="images/castelmezzano-1979546_1920_thumbnail.jpeg" data-accessible-gallery-thumbnail> will pick images/castelmezzano-1979546_1920_thumbnail.jpeg when rendering mini thumbnails at the very bottom of the page.

Can I use other languages than english?

Yes. See above "Options".

Contributing

Contributions are welcome, and greatly appreciated! Contributing doesn't just mean submitting pull requests. There are many different ways for you to get involved, including answering questions on the issues, reporting or triaging bugs, and participating in the features evolution process.

Acknowledgments

Images coming from Pixabay

License

MIT