Giter Club home page Giter Club logo

vue-pure-lightbox's Introduction

Pure JS lightbox component for Vue.js

Downloads Version License

Table of contents

Demo

The live demo is available here: https://codepen.io/DCzajkowski/pen/rzOErW.

Installation

With NPM:

npm i vue-pure-lightbox --save

With a CDN:

<!-- In <head> -->
<meta rel="stylesheet" href="https://unpkg.com/vue-pure-lightbox/dist/vue-pure-lightbox.css">
<!-- In <body>, after Vue import -->
<script src="https://unpkg.com/vue-pure-lightbox/dist/vue-pure-lightbox.js"></script>

Usage

With an ES6 bundler (via NPM)

In your index file

import Lightbox from 'vue-pure-lightbox'
Vue.use(Lightbox)

With a CDN

<script>
  Vue.use(Lightbox)

  new Vue({
    // ...
  })
</script>

Simple example

<lightbox
  thumbnail="/path/to/thumbnail.jpg"
  :images="['/path/to/image1.jpg', '/path/to/image1.jpg']"
>
  <lightbox-default-loader slot="loader"></lightbox-default-loader> <!-- If you want to use built-in loader -->
  <!-- <div slot="loader"></div> --> <!-- If you want to use your own loader -->
</lightbox>

Simple example with content slot

<lightbox
  thumbnail="https://via.placeholder.com/350x150"
  :images="[
    { link: 'https://placekitten.com/1080/910', alt: 'Cat 1' },
    { link: 'https://placekitten.com/1080/920', alt: 'Cat 2' },
  ]"
>
  <lightbox-default-loader slot="loader"></lightbox-default-loader>
  <div slot="content" slot-scope="{ url: { link, alt } }">
    <img :src="link" :alt="alt">
  </div>
</lightbox>

Available props:

Prop Type Value
thumbnail string Path to a file being your thumbnail
images string[] or array Array of paths to files visible in the lightbox
alternate-text string (Optional) alt="" text for your image
value boolean (Optional) reactive visibility prop

Available slots:

Slot Description Default
content Default value is hen you don't want a def <img> tag with src set to path
loader DOM to be used when there is an image loading No loader

Contents

This package consists of just one .vue file. It is meant to be as small and simple as possible. In return you get a <lightbox> Vue component that allows you to show images in a nice, responsive lightbox.

Supported keys:

  • Arrow right - Go to the next image
  • Arrow left - Go to the previous image
  • Escape key - Close the modal
  • Arrow up, Arrow down and a Space Bar - inactive when the lightbox is visible

CSS is being used in the component, but each class is prefixed with a lightbox keyword. You can overwrite them as you wish.

License

Just use it. For free. Forever.

Issues

If you find any bug or problem with the plugin please open an issue or create a pull request on the Github repo.

vue-pure-lightbox's People

Contributors

dczajkowski avatar jilizart avatar wat-aro avatar

Watchers

James Cloos avatar Kees van Lierop avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.