Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
vue-tinybox
Advanced tools
Readme
A slick, yet tiny lightbox gallery for Vue 3.
Observe the live demo here: os.karamoff.dev/vue-tinybox
<Tinybox v-model:index="index" :images="images" loop no-thumbs />
In modern browsers, you can import Tinybox from a CDN URL along with the Vue import:
<script type="module">
import { createApp } from "https://cdn.jsdelivr.net/npm/vue@3/dist/vue.esm-browser.js";
import Tinybox from "https://cdn.jsdelivr.net/npm/vue-tinybox@2/dist/vue-tinybox.es.js";
// ...
</script>
In Node, install the vue-tinybox
package:
pnpm add vue-tinybox
npm install vue-tinybox
yarn add vue-tinybox
...and then import Tinybox like you usually would:
import Tinybox from "vue-tinybox";
// or const Tinybox = require("vue-tinybox");
After you have imported Tinybox, you can bind it to your application instance like you usually do:
const app = createApp({
components: {
Tinybox,
},
});
// or app.component("Tinybox", Tinybox);
// or app.use(Tinybox);
If you need to use the component in a browser without ESM support, include the IIFE version:
<script src="https://cdn.jsdelivr.net/npm/vue-tinybox@2/dist/vue-tinybox.iife.js"></script>
This exposes the Tinybox
component in the global scope. Include it in your app:
<script>
app = createApp({
// ...
});
app.component("Tinybox", Tinybox);
</script>
An Image
object is an object with following fields:
Field name | Type | Description |
---|---|---|
src | String | Image URL |
thumbnail | String | (optional) Thumbnail URL. If omitted, the image URL will be used |
caption | String | (optional) Caption text to be overlayed on the image |
alt | String | (optional) Alt text. If omitted, the caption will be used |
Prop name | Type | Default | Description |
---|---|---|---|
images | Array | [] | List of either image URLs or Image objects |
loop | Boolean | false | Indicates whether the images should loop |
no-thumbs | Boolean | false | When enabled, the thumbnails are hidden |
v-model
You can use v-model
on a Number
variable, which will hold the index of the
image currently open. If no image is open (i.e. Tinybox is closed), the value
becomes null
.
Instead of v-model
you can use the index
prop and change
event:
<Tinybox v-model:index="index" :images="images" />
<!-- is equivalent to -->
<Tinybox :images="images" :index="index" @update:index="(i) => {index = i}" />
Event name | Payload | Description |
---|---|---|
change | index of the image changed to | Is emitted on any image change (thumbnail navigation, prev/next, close) |
prev /next | index of the image changed to | Is emitted specifically when the user clicks "Prev"/"Next" or presses Left/Right arrow key |
close | index of the image Tinybox was closed at | Is emitted specifically when the user clicks "Close" or presses the Esc key |
Events can come in handy for business logic cases:
<Tinybox
:images="images"
v-model:index="index"
@update:index="onChange"
@prev="onPrevious"
@next="onNext"
@close="onClose"
/>
export default {
// ...
methods: {
onChange(index) {
console.log("User navigated to the photo: ", index);
},
onPrevious(index) {
console.log("User clicked 'previous' to switch to: ", index);
},
onNext(index) {
console.log("User clicked 'previous' to switch to: ", index);
},
onClose(index) {
console.log("User closed TinyBox on this photo: ", index);
},
},
};
51+ | 28+ | 10+ | 16+ |
FAQs
A slick, yet tiny lightbox gallery for Vue.js
The npm package vue-tinybox receives a total of 709 weekly downloads. As such, vue-tinybox popularity was classified as not popular.
We found that vue-tinybox demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.