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

lightningbox

v1.0.2

Published

A small and blazing fast vanilla javascript image viewer.

Downloads

6

Readme

Travis Build npm version

Lightningbox

A small (2.2kB gzipped) and blazing fast vanilla javascript image viewer. View Demo

Lightningbox - A small and blazing fast vanilla javascript image viewer.

Install

$ npm install --save lightningbox

Usage

API

/**
* Takes a selector and initialises the image-viewer for the matched element(s).
* The selector needs to point to a single or multiple <a> elements.
* Whenever the <a> elements are clicked the image-viewer will open.
* Required <a> parameters:
*
*    href="..." => the URL of the image that will be displayed in the modal
*
* @param {string} selector The selector of the <a> element(s)
*/
function lightningbox (selector) {
    // ...
}

Single Image

import lightningbox from 'lightningbox';

lightningbox('.gallery > a');
<div class="gallery">
    <a href="/images/1.jpg" title="First"><img src="/images/1-small.jpg" alt="First" /></a>
</div>

Multiple Images

import lightningbox from 'lightningbox';

lightningbox('.gallery > a');
<div class="gallery">
    <a href="/images/1.jpg" title="First"><img src="/images/1-small.jpg" alt="First" /></a>
    <a href="/images/2.jpg" title="Second"><img src="/images/2-small.jpg" alt="Second" /></a>
    <a href="/images/3.jpg" title="Third"><img src="/images/3-small.jpg" alt="Third" /></a>
</div>

Using CDN

<head>
    <!-- Stylesheet -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightningbox@latest/dist/lightningbox.min.css" />
</head>
<body>
    <div class="gallery">
        <a href="/images/1.jpg" title="First"><img src="/images/1-small.jpg" alt="First" /></a>
        <a href="/images/2.jpg" title="Second"><img src="/images/2-small.jpg" alt="Second" /></a>
        <a href="/images/3.jpg" title="Third"><img src="/images/3-small.jpg" alt="Third" /></a>
    </div>
    <!-- Javascript -->
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lightningbox@latest/dist/lightningbox.min.js"></script>
    <script>
        window.lightningbox('.gallery > a');
    </script>
</body>

Using NPM

The lightningbox module exposes the lightningbox() function only which you can start using right away.

import lightningbox from 'lightningbox';

lightningbox('.gallery > a');

Styling

You can either use the compiled lightningbox.min.css file or you can require in the SASS file from node_modules/lightningbox/src/style.scss.

Customizable SASS variables:

$gutter                 // The default spacing used
$color                  // Text color
$font-family            // Font family
$background             // Background color of the modal
$nav-background         // Background color of the close button
$pagination-background  // Background color of the pagination
$border-radius:         // Default border radius
$transition-time:       // Default transition times

CDN

Just use the following code to make window.lightningbox available on your site.

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lightningbox@latest/dist/lightningbox.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightningbox@latest/dist/lightningbox.min.css" />

Development

# Run webpack-dev-server and example page on http://localhost:8080/
$ yarn dev

# Run a production build
$ yarn build

# Run the tests
$ yarn test

# Play some TDD!
$ yarn tdd