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

carouse

v0.0.1

Published

web component carousel ui

Downloads

19

Readme

🍻 carouse 🚬

web component carousel ui

flip between images or other content, with arrow/dot buttons

live demos

understanding the <carouse-carousel> component

  1. put the carousel on your page
    <carouse-carousel arrows dots loop hidden>
      <figure>
        <img src="https://picsum.photos/300/200?1" alt=""/>
        <figcaption>
          <p>hello</p>
        </figcaption>
      </figure>
      <figure>
        <img src="https://picsum.photos/300/200?2" alt=""/>
        <figcaption>
          <p>hola</p>
        </figcaption>
      </figure>
      <figure>
        <img src="https://picsum.photos/300/200?3" alt=""/>
        <figcaption>
          <p>hallo</p>
        </figcaption>
      </figure>
    </carouse-carousel>
  2. know how to use the carousel
    <carouse-carousel arrows dots loop hidden>
    • optional boolean attributes
      • [arrows] – enable arrow controls
      • [dots] – enable dot button controls
      • [loop] – enable end-to-end looping
      • [hidden] – hide the component until it has loaded
    • how does the carousel work?
      • you give it html elements as children, and the carousel treats them like slides
      • then the carousel sets the [hidden] attribute on all but the "active slide"
    • programmatically control the carousel
      • carousel.forward(), onto the next slide
      • carousel.backward(), back to the previous slide
      • carousel.jump(0), jump directly to the first slide
      • carousel.childElementCount, getter for the number of children
  3. style the carousel and its children
    <style>
      @import url("https://unpkg.com/[email protected]/dist/carouse.css");
    
      carouse-carousel {
        max-width: 300px;
    
        /* carouse custom css properties */
        --focus-outline: 2px solid #0ef;
        --carouse-slate-bg: rgba(255,255,255, 0.1);
        --carouse-arrow-size: 4em;
        --carouse-arrow-bg: rgba(60,60,60, 0.8);
        --carouse-dotbar-bg: rgba(0,0,0, 0.3);
        --carouse-dot-size: 0.8em;
        --carouse-dot-bg: white;
      }
    </style>
    • you'll probably want to import carouse.css because it has some preset styles for figure and figcaption elements
    • every available --carouse- custom property is shown with its default value
    • you'll probably want to set a max-width rule on the carousel
    • the carousel assumes you are setting a app-level * { margin: 0; padding: 0; box-sizing: border-box; }, and if you don't, it might look wacky

okay, so that's how i use it.. how do i install it?

  • include the following snippet on your page

    <script type="importmap-shim">
      {
        "imports": {
          "lit-html/": "https://unpkg.com/[email protected]/",
          "lit-html": "https://unpkg.com/[email protected]/lit-html.js",
          "lit-element/": "https://unpkg.com/[email protected]/",
          "lit-element": "https://unpkg.com/[email protected]/lit-element.js",
          "carouse/": "https://unpkg.com/[email protected]/",
          "carouse": "https://unpkg.com/[email protected]/dist/register-all.js"
        }
      }
    </script>
    <script type="module-shim">
      import "carouse/dist/register-all.js"
    </script>
    <script src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script>

    here's what's going on in this snippet

    • import maps
      • in the above snippet, we provide an import map which locates carouse and its dependencies
      • of course, for the import map, we're using guy bedford's awesome polyfill: es-module-shims
      • if you're from the future, you won't need the -shim's
    • register the carouse component
      • we run import "carouse/dist/register-all.js" to register the <carouse-carousel> component

contributions are welcome

please open issues and launch pull requests, let's talk about it