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

@porotkin/slide-show

v0.0.7

Published

The accessible, scroll-snapping, styleable, horizontal carousel custom element. No dependencies, about 12kB minified and gzipped.

Downloads

32

Readme

Published on webcomponents.org

<slide-show>

An accessible <slide-show> custom element for building horizontal scroll-snapping carousels. Features options for pagination, previous and next navigation buttons, autoplay, continuous looping and fullscreen mode. Children of a <slide-show> are layed out in a grid and may contain any arbitrary HTML. About 12kB minified and gzipped.

Example of an HTML carousel showing an image of a tractor as the current slide

Demos and Documentation

Demos and docs at stephen.band/slide-show/.

Install

Via download

Download the latest release:

github.com/stephband/slide-show/releases

Then import the CSS and JS files:

<link rel="stylesheet" href="./build/slide-show.css" />
<script type="module" src="./build/slide-show.js"></script>

Via npm

Install into node_modules/:

npm install @stephband/slide-show

The package comes with CSS files, one for the outer DOM and one for the shadow DOM. The outer DOM CSS can be imported from build/slide-show.css:

<link rel="stylesheet" href="./node_modules/@stephband/slide-show/build/slide-show.css" />

The shadow DOM CSS file must be placed in the same location as 'build/slide-show.js', which will work fine as-is until you build your own package to a different location. (I really don't know how you are supposed to handle this sort of thing via npm and I hope someone will advise.)

Quick start

You are now ready to write <slide-show> tags in your HTML:

<slide-show loop controls="pagination">
    <img src="../images/donkeys.jpg" draggable="false" />
    <img src="../images/tractor.jpg" draggable="false" />
    <img src="../images/mauverin.jpg" draggable="false" />
</slide-show>

API

Attributes

  • active - id string of initial slide to 'activate'
  • autoplay - boolean attribute, slide-show plays through slides
  • controls - token list attribute supporting the tokens "pagination", "navigation", "fullscreen"
  • loop - boolean attribute, causes slides to appear on a continuous carousel

Properties

  • .active - a reference to the current scroll-snap aligned (ie 'active') child
  • .autoplay - boolean, get/set the state of autoplay
  • .controls - a TokenList object supporting the tokens "pagination", "navigation", "fullscreen"
  • .loop - boolean, get/set the state of loop

Methods

  • .activateNext() - activates next slide
  • .activatePrevious() - activates previous slide

Events

  • 'slide-active' - emitted by a child slide when scrolled into scroll-snap alignment

Style

Style for the slide-show:

  • --slide-duration - a CSS time value in s or ms, used when autoplay is enabled
  • --padding-left - padding and scroll-padding inside the scroll area
  • --padding-right - padding and scroll-padding inside the scroll area
  • ::part(prev-button) - the 'previous' navigation button
  • ::part(next-button) - the 'next' navigation button
  • ::part(page-button) - a pagination button
  • ::part(page-button-active) - the currently active pagination button
  • ::part(fullscreen-button) - the fullscreen toggle button
  • ::part(fullscreen-button-active) - the fullscreen toggle button when in fullscreen

Style for child slides:

  • --slide-duration - a CSS time value in s or ms, used when autoplay is enabled

See stephen.band/slide-show/ for more detail.

Polyfill for element.scrollTo()

The script element.js includes a polyfill for element.scrollTo(), as Safari's native version lacks support for smooth scrolling behaviour. The polyfill is ignored in other browsers.

Build

To build the <slide-show> component from its dependent modules, you must have Deno installed. You then need to clone this git repository into the same directory as two other repositories that contain dependencies:

git clone [email protected]:stephband/fn
git clone [email protected]:stephband/dom
git clone [email protected]:stephband/slide-show
cd slide-show

Now the slide-show modules can be built. The build process uses esbuild to import and compile JS and CSS modules to the build/ folder:

make modules

Build documentation

To build documentation, also clone the literal repo:

git clone [email protected]:stephband/literal
cd slide-show

The documentation builder compiles .literal templates to .html, pulling out documentation comments from JS and CSS, and packages dependencies found in the docs/ folder:

make docs