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

tailwind-plugin-ripple-effect

v0.0.5

Published

A Tailwind plugin for adding ripple animations on click

Downloads

23

Readme

tailwind-plugin-ripple-effect

A Tailwind plugin to add ripple effects when clicking things

SUPER DUPER ALPHA: USE AT YOUR OWN RISK, WEIRDOS

Installation

npm i -D tailwind-plugin-ripple-effect

Update Tailwind Config

Add the plugin to your tailwind.config.js file:

const rippleEffectPlugin = require("tailwind-plugin-ripple-effect");

/** @type {import('tailwindcss').Config} */
export default {
  content: ["./src/**/*.{js,jsx,ts,tsx}"],
  theme: {
    extend: {},
  },
  plugins: [rippleEffectPlugin],
};

Start Listening For Ripple Clicks

Then you MUST execute startRippleEffect() from tailwind-plugin-ripple-effect/start somewhere in your application. This is a lightweight event handler that must be wired up. This will most often be done in your root component, but could be done just at the top level when your application loads. Calling startRippleEffect() will return a function that can be called to remove the event handler. This can be useful if you want to add and remove the feature during hot reloads, but is generally not required.

NOTE: If you stop using ripple-effect, you'll want to remove the call to startRippleEffect(). There's no efficient way to dynamically add the required JavaScript just because a class was used.

import { startRippleEffect } from "tailwind-plugin-ripple-effect/start";

const stop = startRippleEffect();

// If you wanted to stop listening for ripple effect clicks you can do that:
// stop()

API

ripple-effect

Add this to any clickable element to create the ripple effect on click.

<button type="button" class="ripple-effect">
  Click Me
</button>

This can be added to any clickable element.

ripple-color-variant

There are a number of classes to allow you to determine the color used with ripple effect, these are aligned with the colors in your Tailwind theme that exist for backgrounds. For example: ripple-red-500, or ripple-slate-500, etc. These styles will determine the color of the ripple itself.

<button type="button" class="ripple-effect ripple-red-500">
  Click Me
</button>

ripple-bg-color-variant

By default, ripple-effect will simply ripple over any existing background color. However, if you want to override that color during the ripple. You can use ripple-bg-color-variant... for example ripple-bg-gray-800 or ripple-bg-red-500.

<button type="button" class="ripple-effect ripple-bg-red-500 ripple-white">
  Click Me
</button>

ripple-stop

If you have a clickable element, like a <button> wrapped in another element that has the class ripple-effect, clicking the button will fire the ripple-effect unless you add ripple-stop to that button, or an element between that button and the ancestor with ripple-effect, or you stopPropagation().

ripple-slow

Does a slower-speed ripple effect. You still need ripple-effect, this just slows it down. <button class="ripple-effect ripple-slow">slower ripple</button>. This is particularly interesting looking on larger areas.

Known Issues

Currently you cannot trigger more than one ripple effect on click. <div class="ripple-effect"><button type="button" class="ripple-effect">Click Me</button></div> will only trigger the ripple in the button if you click it, not the div. The handler searches for the closest ancestor that is a ripple-effect and adds the animation to that, it does not propagate further. I don't know why you'd want to do that, but if you have a good use case, file an issue.

I haven't added a way to change any foreground colors or other styling while the ripple is playing. I'm open to suggestions, it's just not a requirement for me right now.

I don't have time to implement some amazing way to test this in multiple browsers. If you want to do that, File an issue outlining your plan BEFORE you implement it. I don't want to cause you a ton of work just to be like, "Nope, I don't want to maintain that thing you wrote". Currently I'm using this in one project that targets Chromium-based browsers only, but it should work in all modern browsers, AFAICT.