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

vue-it-bigger

v0.3.2

Published

A simple image / (YouTube) video lightbox component for Vue.js. Based on vue-image-lightbox.

Downloads

2,626

Readme

Vue It Bigger!

npm Build Status codecov Depfu

A simple image / (YouTube) video lightbox component for Vue.js 2. Based on vue-image-lightbox.

Vue It Bigger Screenshot

Click on the screenshot above for a demo.

Features

  • Unobtrusive interface that disappears after a few seconds, reappears on mouse activity
  • Optional thumbnail strip with all of the gallery's media
  • Can show an HTML enabled caption under each image or video
  • Can play the slideshow automatically
  • All of the graphics (previous, next and close buttons) can be customized via slots
  • Can skip to next / previous media programatically

Improvements over vue-image-lightbox

  • Allows embedding YouTube videos
  • Lightbox opens and closes with a short fade
  • Media's width is no longer limited (stretches to the full width / height of the window)
  • When opening the lightbox the media doesn't flicker
  • Moved caption bar and image counter off the media to the bottom of the screen
  • Moved thumbnails to the top of the screen (as the bottom is now used by the caption bar)
  • All interface elements have a background for better visibility
  • Simplified CSS

Installation

You know the drill:

npm install vue-it-bigger
# or
yarn add vue-it-bigger

Usage

You can view App.vue or the demo for an usage example.

In the <script> section of your component import it:

import LightBox from 'vue-it-bigger'
import('vue-it-bigger/dist/vue-it-bigger.min.css') // when using webpack

Add it to the list of used components:

export default {
  components: {
    LightBox,
  },
}

And use it in the <template> section:

<LightBox :media="media"></LightBox>

The media prop has the following structure:

[
  { // For an image
    type: 'image', // Can be omitted for image
    thumb: 'http://example.com/thumb.jpg',
    src: 'http://example.com/image.jpg',
    caption: 'Caption to display. HTML <b>enabled</b>', // Optional
    srcset: '...' // Optional for displaying responsive images
  },
  { // For a YouTube video
    type: 'youtube',
    thumb: 'https://img.youtube.com/vi/WsptdUFthWI/hqdefault.jpg',
    id: 'WsptdUFthWI',
    caption: 'HTML <b>enabled</b> caption to display' // Optional
  },
  { // For a video that can be played in the <video> tag
    type: 'video',
    thumb: 'https://s3-us-west-1.amazonaws.com/powr/defaults/image-slider2.jpg',
    sources: [
      {
        src: 'https://www.w3schools.com/html/mov_bbb.mp4',
        type: 'video/mp4'
      }
    ],
    caption: '<h4>Monsters Inc.</h4>',
    width: 800, // Required
    height: 600, // Required
    autoplay: true // Optional: Autoplay video when the lightbox opens
  }
]

Using it with NuxtJs

Create a file named lightbox.js under the plugins directory with following contents:

import Vue from 'vue'

import LightBox from 'vue-it-bigger'
import('vue-it-bigger/dist/vue-it-bigger.min.css')

const plugin = {
  install() {
    Vue.component('LightBox', LightBox)
  },
}

Vue.use(plugin)

Add the plugin in nuxt.config.js:

plugins: [
  {
    src: '~/plugins/lightbox.js',
    ssr: false
  }
]

Use it in any of your components:

<no-ssr placeholder="Loading...">
  <!-- this component will only be rendered on client-side -->
  <LightBox
    :media="lightBoxMedia"
  ></LightBox>
</no-ssr>

Options

Properties

Methods

Slots

close

The content of the close button.

footer

The content of the footer under the image.

Slot props

previous

The previous button on the main image.

next

The next button on the main image.

customCaption

The caption of the current image.

Slot props

Usage example:

<LightBox
  ref="customCaptionLightbox"
  :media="media"
  :show-caption="true"
>
  <template v-slot:customCaption="slotProps">
    {{ slotProps.currentMedia.caption }}<br>
    There could be some description here.
  </template>
</LightBox>

videoIcon

The Icon used for videos

Events

  • onOpened: Emit when the lightbox is opened.
  • onClosed: Emit when the lightbox is closed.
  • onLastIndex: Emit when the current image is the last one of the list.
  • onFirstIndex: Emit when the current image is the first one of the list.
  • onStartIndex: Emit when the current image is at the startAt index (specified in the properties).
  • onLoad: Emit when there are lengthToLoadMore images left in the array (specified in the properties). For example, if lengthToLoadMore = 2 and there are 7 images in your array, when you reach index 4 (which means there are 2 images left which are not discovered yet), this event will be emitted. After that, if the image array are updated and there are totally 15 images, the event will be emitted at index 12.

Development (NPM / Yarn)

Clone the repository, cd into it and run:

npm run dev
yarn dev

After you add or modify something make sure the tests still pass:

npm run test
yarn test

Release

  1. Make sure everything works locally by running yarn dev
  2. Bump the version in package.json
  3. Draft a new release on the releases page
    • Create a tag with the prefix v and the version, eg: v0.3.0
    • Prefix the release title with the tag, eg: v0.3.0 - An awesome release
  4. Publish the release

Credits

License

This project is licensed under the the Apache License, Version 2.0.