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

flex-gallery

v0.1.10

Published

A responsive lightbox gallery with flexbox and progressive image loading.

Downloads

2

Readme

flex-gallery

npm version

A responsive lightbox gallery with flexbox and progressive image loading.

Installation

npm install flex-gallery

Usage

HTML:

<div class="gallery">
  <div class="gallery-item">
    <img
      class="thumb placeholder"
      src="[email protected]"
      data-src="image-1.jpg"
      data-srcset="image-1.jpg 1x, [email protected] 2x"
      data-image="image-1.jpg"
      data-image-srcset="image-1.jpg 500w, [email protected] 1000w, [email protected] 2000w"
      data-title="Image 1"
      alt="Image 1"
    />
    <div class="caption" title="Image 1">Image 1</div>
  </div>

  <div class="gallery-item">
    <img
      class="thumb placeholder"
      src="[email protected]"
      data-src="image-2.jpg"
      data-srcset="image-2.jpg 1x, [email protected] 2x"
      data-image="image-2.jpg"
      data-image-srcset="image-2.jpg 500w, [email protected] 1000w, [email protected] 2000w"
      data-title="Image 2"
      alt="Image 2"
    />
    <div class="caption" title="Image 2">Image 2</div>
  </div>
</div>

| Attribute | Description | | ----------------- | ------------------------------------------ | | src | Placeholder until data-src is lazy loaded | | data-src | Gallery item image | | data-srcset | Gallery item srcset | | data-image | Lightbox image | | data-image-srcset | Lightbox image srcset | | data-title | Title for the lightbox header |

JS:

import flexGallery from "flex-gallery";

flexGallery();

or with options:

flexGallery({
  transitionDuration: 400,
  swipingThreshold: 5,
  slideChangeThreshold: 150,
});

| Property | Description | | -------------------- | ----------------------------------------------------------------- | | transitionDuration | Time of a slide transition (in milliseconds) | | swipingThreshold | Threshold for a swipe gesture to be recognized as swiping (in px) | | slideChangeThreshold | Threshold for a swipe to trigger a slide change (in px) |

SCSS:

@use "flex-gallery";

Customize

Example for overriding variables:

@use "flex-gallery" with (
  $gallery-item-height: 250px,
  $gallery-item-overlay-bg: url("path/to/your/custom-bg-image.png"),
  $lightbox-bg-color: #222,
  $lightbox-header-bg-color: #999,
  $lightbox-header-font-weight: 600
);

All default variables:

// --------------------------------
// SVG Icons
// --------------------------------
$icon-enlarge-color: white !default;
$icon-chevron-color: white !default;
$icon-close-color: white !default;
$icons-stroke-width: 2 !default;
$icon-enlarge-svg: '<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="none"><path stroke="#{$icon-enlarge-color}" stroke-width="#{$icons-stroke-width}" d="M27.2083 27.2267C28.9329 25.5068 30 23.128 30 20.5C30 15.2533 25.7467 11 20.5 11C15.2533 11 11 15.2533 11 20.5C11 25.7467 15.2533 30 20.5 30C23.1187 30 25.4899 28.9405 27.2083 27.2267ZM27.2083 27.2267L37 37.0183"/></svg>' !default;
$icon-chevron-left-svg: '<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="none"><path stroke="#{$icon-chevron-color}" stroke-width="#{$icons-stroke-width}" d="M32 43L16 24L32 5"/></svg>' !default;
$icon-chevron-right-svg: '<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="none"><path stroke="#{$icon-chevron-color}" stroke-width="#{$icons-stroke-width}" d="M16 43L32 24L16 5"/></svg>' !default;
$icon-close-svg: '<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="none"><path stroke="#{$icon-close-color}" stroke-width="#{$icons-stroke-width}" d="M14 14L34 34M34 14L14 34"/></svg>' !default;

// --------------------------------
// Gallery Settings
// --------------------------------
$gallery-gap: 1em !default;
$gallery-item-height: 100px !default;
$gallery-item-height-sm: 150px !default;
$gallery-item-height-lg: 200px !default;
$gallery-item-border-radius: 0 !default;
$gallery-item-overlay-bg-color: rgba(#000, 0.4) !default;
$gallery-item-overlay-bg-image: url(utils.svg-encode($icon-enlarge-svg)) !default;
$gallery-item-overlay-bg: $gallery-item-overlay-bg-color $gallery-item-overlay-bg-image center / 3rem no-repeat !default;
$gallery-item-caption-bg-color: rgba(#000, 0.6) !default;
$gallery-item-thumb-bg-color: #333 !default;

// --------------------------------
// Lightbox Settings
// --------------------------------
$lightbox-bg-color: #2e2e35 !default;
$lightbox-z-index: 9999 !default;
$lightbox-text-color: white !default;
$lightbox-close-color: white !default;
$lightbox-header-bg-color: rgba(#000, 0.3) !default;
$lightbox-header-padding: 0.5em !default;
$lightbox-header-font-weight: 400 !default;
$lightbox-arrow-left-bg-image: url(utils.svg-encode($icon-chevron-left-svg)) !default;
$lightbox-arrow-right-bg-image: url(utils.svg-encode($icon-chevron-right-svg)) !default;
$lightbox-close-bg-image: url(utils.svg-encode($icon-close-svg)) !default;

TODO

  • Provide method for adding gallery items programmatically
  • Fire events when opening/closing lightbox and on slide change

License

MIT