Giter VIP home page Giter VIP logo

rodneylab / sveltekit-simple-image-gallery Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 0.0 4.58 MB

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

License: BSD 3-Clause "New" or "Revised" License

JavaScript 62.47% HTML 2.22% Svelte 33.84% Shell 1.03% CSS 0.44%
sveltekit svelte responsive-images responsive-layout image-gallery lazyload-images next-gen vite-imagetools

sveltekit-simple-image-gallery's Introduction

Rodney Lab sveltekit-simple-image-gallery Github banner

Rodney Lab logo

SvelteKit Simple Image Gallery

sveltekit-simple-image-gallery

Open in StackBlitz

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!

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

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):
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.

sveltekit-simple-image-gallery's People

Contributors

rodneylab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sveltekit-simple-image-gallery's Issues

Please can you explain how to generate an `image.json` file, or is it already automatic, but undocumented?

I followed this tutorial and have the gallery running (with the large JPGs), but I can't find an entry point or any reference to running generate-responsive-image-data.js. This is awkward, as there's folders I'd like to customise the contents but I don't see how to adapt this to output something relevant.

I tried:

  • pnpm generate-responsive-image-data, this returns:
 ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command failed with ENOENT: generate-responsive-image-data
spawn generate-responsive-image-data ENOENT
  • ...and pnpm vite generate-responsive-image-data, this returns:
(!) Could not auto-determine entry point from rollupOptions or html files and there are no explicit optimizeDeps.include patterns. Skipping dependency pre-bundling.

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.