Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rodneylab/sveltekit-simple-image-gallery

Simple Svelte responsive image gallery: create a ribbon gallery, using Svelte dimension bindings to maintain the aspect ratio of all images.
https://github.com/rodneylab/sveltekit-simple-image-gallery

image-gallery lazyload-images next-gen responsive-images responsive-layout svelte sveltekit vite-imagetools

Last synced: 3 months ago
JSON representation

Simple Svelte responsive image gallery: create a ribbon gallery, using Svelte dimension bindings to maintain the aspect ratio of all images.

Awesome Lists containing this project

README

        

Rodney Lab sveltekit-simple-image-gallery Github banner



Rodney Lab logo



SvelteKit Simple Image Gallery

# sveltekit-simple-image-gallery

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/rodneylab/sveltekit-simple-image-gallery)

Demo code for creating a simple responsive image gallery with Svelte. The code
accompanies the
post
on creating a simple responsive image gallery SvelteKit
. If you have any
questions, please drop a comment at the bottom of that page.

## Building and previewing the site

If you're seeing this, you've probably already done this step. Congrats!

```bash
git clone https://github.com/rodneylab/sveltekit-simple-image-gallery.git
cd sveltekit-simple-image-gallery
pnpm install # or npm install
pnpm run dev
```

## Building

```bash
pnpm run build
```

> You can preview the built app with `pnpm run preview`, regardless of whether
> you installed an adapter. This should _not_ be used to serve your app in
> production.

## Customising for your own images

1. The project includes the raw images in the `src/lib/assets` folder. Add your
images there.
2. `src/data/image.json` links the image files names with alt text and titles.
Update this manually or generate it based on an existing source for your
images.
3. `src/data/generated` has a JavaScript file for each base image, each
containing data needed to create the responsive and next-gen image set from
the base images. I generated these files automatically using the
`generate-responsive-image-data.js` script in the project root directory. You
can update it to suit your needs, then run it with `node`. I prefer using
vite-node (which will also work with TypeScript projects):

```shell
pnpm add -D vite-node
pnpm vite-node generate-responsive-image-data.js
```

Hope that’s clear, but let me know if I can improve the explanation.

Feel free to jump into the
[Rodney Lab matrix chat room](https://matrix.to/#/%23rodney:matrix.org).