Skip to content

Commit 9e0b1ea

Browse files
authored
Added an ability to define a preview (#34)
1 parent 39484a1 commit 9e0b1ea

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,15 @@ import styles from 'vue-pure-lightbox/dist/VuePureLightbox.css'
126126
| open-at-index | integer | **(Optional)** index of an image to show when opening the modal |
127127

128128
### Available slots:
129+
129130
| Slot | Description | Default |
130131
| ------------- | ---------------------------------------------------- | ----------------------------------------- |
131132
| content | DOM to be used in place of an image in the lightbox | <img> tag with src set to path |
132133
| loader | DOM to be used when there is an image loading | LightboxDefaultLoader |
133134
| icon-close | Icon to be used as a close button | × (×) |
134135
| icon-previous | Icon to be used as the "next" arrow button | ![](https://i.imgur.com/HcdxJmd.png)(svg) |
135136
| icon-next | Icon to be used as the "previous" arrow button | ![](https://i.imgur.com/oErSVk3.png)(svg) |
137+
| preview | DOM to be used in place of the default thumbnail | Clickable link with a thumbnail |
136138

137139
## Contents
138140
This package consists of just one `.vue` file. It is meant to be as small and simple as possible.

src/App.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
/>
1818
<img v-else :src="url">
1919
</div>
20+
<button slot="preview" slot-scope="{ show }" @click="show">
21+
Open
22+
</button>
2023
</Lightbox>
2124
</template>
2225

src/Components/Lightbox.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<template>
22
<div>
3-
<a :href="images[0]" target="_blank" @click.prevent="show" class="lightbox__thumbnail">
4-
<img :src="thumbnail" :alt="alternateText">
5-
</a>
3+
<slot name="preview" :show="show">
4+
<a v-if="thumbnail" :href="images[0]" target="_blank" @click.prevent="show" class="lightbox__thumbnail">
5+
<img :src="thumbnail" :alt="alternateText">
6+
</a>
7+
</slot>
68
<div class="lightbox" v-if="visible" @click="hide">
79
<div class="lightbox__close" @click="hide">
810
<slot name="icon-close">&times;</slot>
@@ -53,6 +55,7 @@
5355
props: {
5456
thumbnail: {
5557
type: String,
58+
default: null,
5659
},
5760
images: {
5861
type: Array,

0 commit comments

Comments
 (0)