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

ld-carousel

v1.0.0

Published

Module for creating Image Carousels / Slideshows easily.

Downloads

11

Readme

ld-carousel

JS module for easy implementation of image carousels or slideshows in HTML.
Developed by Leandecks (rigel1631).

Installation

npm i -D ld-carousel

You need to have npm in your project. If you don't, run npm init.

Usage

The module gives you a custom JavaScript function for creating modules and a basic stylesheet that styles it. Both can be customized.

JavaScript

function createCarousel(
  container,
  wrapper,
  images = [],
  circleBackgroundColor = "#000"
)
  • container: the element that will contain the images.
  • wrapper: the element that wraps the container of the images. It will display the navigation bar at the bottom.
  • images: an array of all the images that will be in the dropdown.
  • circleBackgroundColor: the background color of the navigation circles at the bottom. Defaults to black.

CSS

This module also contains a simple CSS stylesheet. It positions the buttons that are used to cycle through the images, styles the navbar and puts everything in its place. This is optional but highly recommended!

You can customize the colors using CSS variables. Pay attention to importing the carousel's stylesheet BEFORE your stylesheet.

:root {
  --prime: #000;
  --second: #2f2e3d;
  --accent: #8d8ab9;
  --button-hover-color: #fff;
}
  • --prime: used for the navigation circles, the buttons and the buttons' hover effect.
  • --second: used as background color for the image container. This color only shows up with too small or big images.
  • --accent: used as background color for the buttons and the navbar.
  • --button-hover-color: the text color of the buttons on hover.

Implementation Example

HTML:

<div class="carousel-wrapper">
  <div class="images"></div>
</div>

JS:

import "../index.html";
import "ld-carousel/style.css"; // NOTE: Before your custom stylesheet
import "../css/style.css";
import Image1 from "../img/1.jpg"; // The module also works without a bundler
import Image2 from "../img/2.jpg";
import Image3 from "../img/3.jpg";
import Image4 from "../img/4.jpg";
import Image5 from "../img/5.jpg";
import createCarousel from "ld-carousel";

const container = document.querySelector(".images");
const wrapper = document.querySelector(".carousel-wrapper");
const images = [Image1, Image2, Image3, Image4, Image5]; // Without bundler: pass source
createCarousel(container, wrapper, images, "#1ff");

CSS:

:root {
  --accent: #1ff;
}

::selection {
  color: var(--second);
  background: var(--prime);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  width: 100%;
}

body {
  font-size: var(--font-size);
  color: var(--prime);
  background-color: var(--second);
  font-family: sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
}