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

macro-carousel

v1.0.0

Published

Carousel as a vanilla Web Component

Downloads

216

Readme

<macro-carousel> · npm version Build Status Coverage Status GitHub license

<macro-carousel> is a carousel (vanilla) Web Component.

DEMOS | DOCS

  • Compatible with every framework
  • Public APIs exposed as methods, events and properties/attributes
  • Mouse and touch events
  • Previous and next buttons
  • Pagination indicators
  • Multiple slides per view
  • Customisable styles though CSS custom properties
  • Focused on a11y
  • no external dependencies

Installation

npm install --save macro-carousel

It is reccommended to install the inert and focus-visible polyfills (listed as peerDependencies).

Running the project locally

Run npm install to install all local dependencies.

Run npm start and open the http://localhost:8080/demo/ page in your browser.

Usage

Please read the full documentation

<macro-carousel>
  <div>First slide</div>
  <div>Second slide</div>
  <div>Third slide</div>
</macro-carousel>

<script src="macro-carousel.min.js" defer></script>

For more examples, look at the demos (Live demo, Demo code)

Browser support

WebComponent Polyfills suite

In order for this Web Component to work on all evergreen browsers, you may need to add the WebComponent polyfills suite to your page. (Please note that this repository focuses on the macro-carousel Web Component, and not on the polyfills)

All the demos in this repository already make use of the polyfills (by using webcomponents-loader.js). The source code of the macro-carousel Web Component also makes optional calls to the ShadyCSS polyfill.

Because of the ShadyCSS polyfill limitations, certain style rules are not applied in polyfilled browsers:

  • all the rules that rely on the :host-context() selector are not polyfilled correctly (these rules are mainly around using the focus-visible polyfill)
  • some of the more complex selectors using :host() are also not supported. This mainly impact the hover/focus states on navigation buttons.
  • normally, external styles have the priority over the internal Web Component styles. But sometimes, after the polyfill's transformation, some internal selectors end up having a higher specificity then the external ones. This is quite an edge case, but keep an eye for it (e.g.: the custom navigation demo uses the !important keyword to force some styles).

For browsers not supporting ES6 classes, the tranpiled ES5 version can be used instead (macro-carousel.es5.min.js), together with the custom-elements-es5-adapter.js polyfill. The es5 demo shows how to do that.

As browser support grows and the polyfills improve, these limitations should become less and less frequent and problematic.

Other known cross-browser limitations

In order to change the color of the navigation button arrow, this project makes use of the mask-image CSS property. Unofruntaly, when this CSS feature is not supported, the color defined through --macro-carousel-navigation-color-focus is not going to be applied correctly to the arrow.

Test

Run npm test to run all tests.

Whishlist

Please have a look at the backlog to see the plan for the next releases.

If you have a feature request, feel free to open an issue!