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

vue-sparkles

v1.1.0

Published

A Vue component making things a little sparklier

Downloads

23

Readme

Vue Sparkles

A Vue component making things a little sparklier

npm bundle size npm GitHub issues NPM AppVeyor

What is Vue Sparkles?

Vue Sparkles is the Vue.JS variant of Josh W Comeau's animated sparkles for React. I took a couple of different approaches to the idea than he did. And I had to, since this is Vue and not React, of course :) It is essentially the same though.

It could look like this in action

Preview of a sparkling header

How to install it

easy, in your command line of choice:

npm install vue-sparkles --save

You have it installed. Now we just have to import it: in your main.js import the component like this

import VueSparkles from  'vue-sparkles';

And then we have to tell Vue to use it.

Vue.use(VueSparkles);

How to use Vue Sparkles?

Just wrap your soon-to-be sparkly element in a <VueSparkles> tag. That could look as follows

<VueSparkles><h1>What a great looking Header this is</h1></VueSparkles>

Or like so

<VueSparkles><img src="@/assets/img/some-image.png" alt="A sparkling image" /></VueSparkles>

You want to get more into customization? No problem!

Customization

Colors

You can pass a color prop to apply a custom color. Only an HSL style of colors work though. If you don't pass any color prop all sparkles will use the default of hsl(50deg, 100%, 50%)

<VueSparkles
  color="hsl(0deg, 100%, 50%)">
    <h1>What a great looking Header this is</h1>
</VueSparkles>

Alright, alright, I understand. You are thirsty now. You want more. No problem. Multiple Colors! To achieve that, I find it easiest to bind the color prop to a variable. Said var could look like this

color: [
    {
      h: '0',
      s: '100',
      l: '50'
    },
    {
      h: '50',
      s: '100',
      l: '50'
    }
  ]

This will give you a nice rainbowy effect of colors ranging from red to yellow for example. Notice how I only changed the hue and left the saturation and luminance the same. I would urge you to do the same if you don't intentionally aim for a different effect.

Paths

You can also use different paths. If you don't pass a path object, all sparkles will use the default star sparkle created by Josh Comeau. There is a restriction however! Since you are only changing the path, you won't be able to change stuff such as viewBox or stroke. That means you will be limited to filled SVGs, no outline icons here. Also, the viewBox is 0 0 160 160, so if your path doesn't respect that it is either cut on the viewBox borders or it will be so small you can't see it.

So, this should be pretty self-explanatory. For a single path you just have to pass the path-string through the path prop. That could look like this:

<VueSparkles
  path="...">
  <h1>What a great looking Header this is</h1>
</VueSparkles>

For multiple paths, just bind the path-prop to an array containing the paths.

Features

  • [x] Sparkles behind and in front of the child element
  • [x] Color Prop
  • [x] Multiple colors
  • [x] Custom Path
  • [ ] Click to disable
  • [ ] Outline SVGs (?)

Changelog

1.0.3

  • Fix: Changed CSS to Skoped, since it made some SVGs outside the sparkle elements rotate

1.0.1 & 1.0.2

  • Hotfix: default path was the default color
  • Hotfix: when alternating between 2 paths, the random function would always return 0, instead of 0 or 1

1.0.0

  • Stable Release
  • Addition of ESLint

0.1.4

  • Custom Colors and Paths can now be passed through the color or path prop
    • Single Color/Path as String
    • Multiple Colors/Paths as Arrays

0.1.3

  • Build-Issues fixed, the module will now be found on import

Initial Release (0.1.0)

  • Initial Release: <VueSparkle> adds sparkles to Child Element passed through the slot.

Contribute

If you think this can be optimized in any way, please feel free to do so, this is open source after all :)