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

@miraidesigns/lightbox

v1.0.1

Published

Mirai Designs Framework: Lightbox module

Downloads

4

Readme

Lightbox

Lightbox creates a modal carousel from a set of media elements such as images or videos.


HTML

<a href="images/1.jpg" data-lightbox="id" data-lightbox-alt="Image alt description">
    <img src="images/1_thumbnail.jpg" alt="Image thumbnail">
</a>

Sass

// Include default styles without configuration
@forward '@miraidesigns/lightbox/styles';
// Configure appearance
@use '@miraidesigns/lightbox' with (
    $variable: value
);

@include lightbox.styles();

TypeScript

import { MDFLightbox } from '@miraidesigns/lightbox';

new MDFLightbox(document.querySelectorAll('[data-lightbox="id"]'), {
    icons: {
        type: 'svg',
        control: 'icons.svg#arrow-keyboard',
        close: 'icons.svg#clear'
    }
});

Implementation

Attributes

| Name | Element | Description | | --------------------------- | ------- | ---------------------------------------------------------- | | data-lightbox | <a> | Lightbox id. Use this attribute to group elements together | | data-lightbox-title | <a> | Set lightbox item title | | data-lightbox-description | <a> | Set lightbox item description | | data-lightbox-alt | <a> | Set alt attribute text for images | | data-lightbox-type | <a> | Content type. Allowed values are video or embed |

Classes

| Name | Type | Description | | --------------------------------------- | -------------- | ----------------------------------------------------------------------------------------------- | | mdf-lightbox-container | Parent | Contains the lightbox and backdrop | | mdf-lightbox-container--active | Modifier | 1. Prepares the lightbox to be visible | | mdf-lightbox-container--fade-in | Modifier | 2. Fades-in the lightbox and allows for interaction | | mdf-lightbox | Parent / Child | Contains the header, items and controls. Child to .mdf-lightbox-container | | mdf-lightbox__items | Parent / Child | Contains the lightbox items. Child to .mdf-lightbox | | mdf-lightbox__item | Parent / Child | Lightbox item. Contains the item info and media element. Child to .mdf-lightbox__items | | mdf-lightbox__item--scale | Modifier | Plays animation on item when opening the lightbox | | mdf-lightbox__info | Parent / Child | Contains the title and description. Child to .mdf-lightbox__item | | mdf-lightbox__title | Child | Item title. Child to .mdf-lightbox__info | | mdf-lightbox__description | Child | Item description. Child to .mdf-lightbox__info | | mdf-lightbox__media-wrapper | Parent / Child | Media wrapper element. Allows for scaling of videos and iframes. Child to .mdf-lightbox__item | | mdf-lightbox__media-wrapper--bordered | Modifier | Add border to media element, used for iframes | | mdf-lightbox__media | Child | Media element. Child to .mdf-lightbox__media-wrapper | | mdf-lightbox__control | Child | Lightbox control button element. Child to .mdf-lightbox | | mdf-lightbox__control--close | Modifier | Close button element | | mdf-lightbox__control--prev | Modifier | Previous button element | | mdf-lightbox__control--next | Modifier | Next button element | | mdf-lightbox-backdrop | Child | Lightbox backdrop. Child to .mdf-lightbox-container |

Events

| Name | Data | Description | | --------------------- | ------------------------------------ | --------------------------------------------------------------------------------------- | | MDFLightbox:opened | null | Fires when the lightbox opens | | MDFLightbox:changed | {index: number, item: HTMLElement} | Fires whenever the active lightbox item changes. Includes the item itself and its index | | MDFLightbox:closed | null | Fires when the lightbox closes |

Properties

| Name | Type | Description | | ----------------- | ------------------- | -------------------------------------------------------------------------------------- | | .activeItem | HTMLElement | Returns the current lightbox item on display | | .container | HTMLElement | Returns the lightbox container element | | .index | number | Returns the index of the current lightbox item | | .items | HTMLCollection | Returns a HTMLCollection holding all lightbox items | | .itemsContainer | HTMLElement | Returns the lightbox items container element | | .lightbox | HTMLElement | Returns the lightbox element | | .links | HTMLLinkElement[] | Returns an Array holding all lightbox links | | .refresh() | (): void | Refresh the lightbox, adding new items without re-creating the entire lightbox element |

Options

| Name | Type | Default | Description | | ----------------- | ------------ | -------- | ------------------------------------------------------------------------------------------- | | onOpen | () => void | null | Function will run when the lightbox is opened | | onChange | () => void | null | Function will run when the lightbox item changes | | onClose | () => void | null | Function will run when the lightbox is closed | | titlePos | string | bottom | Set title position. Allowed values are top or bottom | | titleAlign | string | center | Set title text alignment. Allowed values are left center or right | | iframeAddBorder | boolean | false | Add border to embedded iframes | | sandboxing | boolean | false | Enable sandboxing for iframes | | sandboxingRules | string | null | See: HTML iframe sandbox Attribute | | enableSwipe | boolean | true | Allow for navigation by swiping left and right on touch devices | | hideOnClick | boolean | true | Lightbox will be hidden when clicked outside of it's content |