1.0.0-alpha.7 • Published 1 year ago

shoka-gallery v1.0.0-alpha.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Shoka Gallery

Super simple a11y headless image gallery for Vue 3 users

Example

Open in StackBlitz

More examples: playground

Installation

# npm:
npm install shoka-gallery

# pnpm:
pnpm add shoka-gallery

Usage

Use as Vue plugin

import { createApp } from 'vue'
import { ShokaGallery } from 'shoka-gallery'
import App from './App.vue'

const app = createApp(App)

app.use(ShokaGallery)
app.mount('#app')

Direct import

<script setup>
import { Gallery, GalleryItem, GalleryPanel, GalleryImage, GalleryCaption } from 'shoka-gallery'
</script>
<template>
  <Gallery>
    <GalleryPanel>
      <GalleryImage> Loading.... </GalleryImage>
      <GalleryCaption />
    </GalleryPanel>

    <GalleryItem>
      <img src="..." />
    </GalleryItem>

    <GalleryItem>
      <img src="..." />
    </GalleryItem>

    <GalleryItem>
      <img src="..." />
    </GalleryItem>
  </Gallery>
</template>

Keyboard interaction

CommandDescription
EscCloses open Gallery Panels
TabCycles through an open Gallery Panels's contents
Shift + TabCycles backwards through an open Gallery Panels's contents
Arrow Right/UpGo to next Image
Arrow Left/DownGo to previous Image

Component API

Gallery

PropDefaultDescription
modelValuefalseWhether the Gallery is open or not.
as'div'The element or component the Gallery should render as.
Slot PropTypeDescription
open'Boolean'Whether the Gallery is open or not.
items'Array'Images
isLoading'Boolean'Image is loading
currentIndex'Number'Current image index
isStartIndex'Boolean'Current image is first
isEndIndex'Boolean'Current image is last
currentItem'Object'Current image object
direction'PREV/NEXT'Direction of image change
close'event'Call for closing gallery panel
next'event'Call for step next image
prev'event'Call for step previous image

GalleryItem

PropDefaultDescription
as'div'The element or component the Gallery should render as.
src''The image URL
srcset''Possible image sources
sizes''Set of source sizes
alt''Alternative text for accessibility
title''Caption of image
Slot PropTypeDescription
selected'Boolean'Selected/active Image

GalleryPanel

PropDefaultDescription
as'figure'The element or component the Gallery should render as.
Slot PropTypeDescription
isLoading'Boolean'Image is loading
items'Array'Images
currentIndex'Number'Current image index
isStartIndex'Boolean'Current image is first
isEndIndex'Boolean'Current image is last
currentItem'Object'Current image object
direction'PREV/NEXT'Direction of image change
close'event'Call for closing gallery panel
next'event'Call for step next image
prev'event'Call for step previous image

GalleryImage

EventsDescription
loadImage is loaded
errorAn error occurs while loading or rendering an image

GalleryCaption

PropDefaultDescription
as'figcaption'The element or component the Gallery should render as.

GallerySwipe

PropDefaultDescription
as'div'The element or component the Gallery should render as.
Slot PropTypeDescription
items'Boolean'Gallery swipe items

GallerySwipeItem

PropDefaultDescription
as'div'The element or component the Gallery should render as.