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

@maxcoding/simpleslider

v1.3.1

Published

slider/carrousel

Downloads

5

Readme

Simpleslider

Note: If you enjoy the package, I would appreciate and be very grateful if you endorse me on LinkedIn 😇, because it would help me tremendously.

Take a look at the docs and examples on simpleCode

Take a look at the example on codepen.

This package is really simple to use and I let you display a slides-show or carousel on your website without having to worry at all.

All you need to do is to create a section or div tag with the class sliderContainer and inside it place as many div tags as you want your slides-show or carousel to have. This div needs to have the slide class to work.

Installation

npm i @maxcoding/simpleslider

Usage

Register the packeget

import simpleSlider from "@maxcoding/simpleslider";

or

import simpleslider from "./node_modules/@maxcoding/simpleslider/index.js";

Javascript

After registering the package inside your javascript file you just need to iniciate the simpleSlider like this:

simpleslider();
Don't forget
Your javascript file must be type="module".

Frameworks

For static data you can iniciate the package when the component is mouting. If you are going to use it with dynamic data read Dynamic data section at the end of file.

Template

<section class="sliderContainer">
    <div class="slide">
        <img src="cat1.jpg" alt="" />
    </div>
    <div class="slide">
        <img src="cat2.jpg" alt="" />
    </div>
    <div class="slide">
        <img src="cat3.jpg" alt="" />
    </div>
</section>

Params

SimpelSlider have some basic params so you can start using it right away but also it gives you the chance to customize them.

| Param | Description | Default | Notes | | ----------- | --------------------------------- | ------- | ------------ | | height | Control height of sliderContainer | 100% | px, vh or % | | width | Control width of sliderContainer | 600px | Use px or vh | | color | Change color of arrows | black | RGB hex name | | arrowSize | Size of arrows | 2 | From 1 to 5 | | arrowWeight | Size of weight | 5 | From 1 to 10 |

Example

<section
    class="sliderContainer"
    height="300px"
    width="300px"
    arrowSize="2"
    color="white"
>
    <div class="slide">
        <img src="cat1.jpg" alt="" />
    </div>
    <div class="slide">
        <img src="cat2.jpg" alt="" />
    </div>
    <div class="slide">
        <img src="cat3.jpg" alt="" />
    </div>
</section>

Take a look at the example on codepen.

Dynamic data

To use Simple Slider with dynamic data, you need to initiate the package after you get the data. For example in plain javascript you need to do this:

  1. Select the container
  2. Fetch the data
  3. After you get the data, you can map over it and create the slides
  4. Initiate the package

Code

const sliderContainer = document.querySelector(".sliderContainer"); // Select the container
const fetchProjects = async () => {
    // your function
    try {
        const resp = await fetch(
            // Fetch the data
            "https://my-portfolio-blog-website.netlify.app/api/myProjects"
        );
        const data = await resp.json();
        const projectImg = data // Map over it and create the slides
            .map((project) => {
                return `
      <a class="slide" href="${project.pageUrl}" target="_blank"
        >visit
        <img src="${project.url}" alt="cateria" />
      </a>
        `;
            })
            .join("");
        sliderContainer.innerHTML = projectImg;
        simpleslider(); // Initiate the package
    } catch (error) {
        console.log(error);
    }
};

fetchProjects(); // Run your function

Example

Take a look at the example on codepen