npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

virstellung

v8.0.1

Published

Slide show

Downloads

40

Readme

Virstellung

A library for server side generated slide show,

if JS in enabled, then the "next" and "previous" links have the default behaviour removed and switch to the next/previous slide without a full page refresh.

The improved select requires <dialog> support (progressive enhancement)

Installation

npm i virstellung

Usage

virstellung.html.js

virstellung is a function that generates html code. This code should be inserted into the <body>. returns a promise

Example

import { virstellung } from "virstellung";
import mime from "mime"; // not included


const items = [
    "image1.jpg",
    "video.mp4",
];

const mediaFolder = "media";

// must be completely safe to inserted into html
// make sure to validate or escape
// in this example the items are hardcoded so there is no problem
// fileAlone will be passed to getText (if any text is present)
const preparedSlideItems = items.map(item => {
    return {
        label: item,
        url: `./${mediaFolder}/${item}`,
        file: item,
        mime: mime.getType(item),
    }
});

const currentSlideParam = "currentslide";

const generateHref = function (index, item) {
    return `./slide-${index}.html`;
};

const htmlCodeForAllSlides = preparedSlideItems.map((slideItem, i) => {
    return `<!doctype html><html><head>
    <meta name="viewport" content="width=device-width">
    <link media="screen" href="./virstellung.css" rel="stylesheet">
    </head><body>    
    ${await virstellung({
        slideItems: preparedSlideItems, // array with {label, url, mime}
        currentSlide: i, // current slide
        generateHref, // href used in the links for next, previous
        previousLabel: undefined, // optional label string
        nextLabel: undefined, // optional label string
        id: undefined, // id that will be used in the html,
        // for the event handlers to know which slide should go next
        // (there can be multiples slides on the same page)
        //  only required if multiple slides are used
        getText: undefined, // function used to get the text content (server side)
        // may be async
        // needed because there is no native html include yet
        // the text should be html escaped 
    })}
    <script type="module" src="./virstellungAutoLaunch.js"></script>
</body></html>`;
});

In the HTTP server, use currentSlideParam queryParameter or the generated Href (see above) to know which html page to serve. (server side rendering)

virstellungAutoLaunch.js

Optional

Code that should run after the html code generated by the above function. Bundle it with rollup or similar. Import the result as text and serve it inside a <script type="module">. This will not work if the html code generated by the above is not found.

Depends upon dom99

virstellung.js

Alternative to virstellungAutoLaunch, does nothing by itself, exports a function stellFir. Use it with the same id as used before for virstellung function. To improve a select import augmentSelect instead

virstellung.css

Optional

Serve it to inside <link media="screen" href="./virstellung.css" rel="stylesheet"> in the <head>. Again, your server should serve this file.

Progressive Enhancement

Multiple Image resolution

If there are multiple resolutions or formats for 1 image you may instead of using url, use a sources array, with object that have url, mime and media (breakpoints).

Make slideItems have items be like :

slideItems = [
{
    label: `flower`,
    mime: `image`,
    sources: [
        {
            url: `./imgfull.jpg`,
            media: `(min-width: 2000px)`,
            mime: `image/jpeg`,
        },
        {
            url: `./goodenough.jpg`,
            media: `(min-width: 1000px)`,
            mime: `image/jpeg`,
        },
        {
            // last should be fallback without media
            url: `./fallback.jpg`,
            mime: `image/jpeg`,
        }
    ]
}
];

selectImage

displays a select with all the images, if js is enabled and virstellung.js is run with the augmentSelect function then the select is replaced with a button and a hidden input the hidden input holds the value and sends it in the form as the select would. the button is displayed and when clicked opens a dialog to chose an image. Once chosen the button display and the hidden input value are updated

const [putInsideLabel, putOutsideLabel, putOutsideForm] = selectImage(options, fileSelected=``, multiple=false);

The reason it returns 3 pieces of html code is that the slide show container has next and previous interactions that absorbs user input and messes with regular form and is probably invalid html

Empty option, how to

have an item with value set to empty string, and url point to an image that represents emptyness

About

Virstellung means presentation in Luxembourgish

Changelog

Changelog

License

CC0

Related

  • reveal.js