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

@slimy/hva

v0.2.5

Published

Haruhi Variance Authority

Downloads

10

Readme

Haruhi Variance Authority

What is HVA?

HVA is a variant manager, that allows you to create variants for you components to later on, use them in your code.

For being this simple, it can be used with Astro integrations without any trouble or error.

What is a variant?

A variant is a component that has a different style, but the same functionality.

For example, a button with a different color, or a card with a different background.

So Haruhi, manages that for you in a simple way.

How to Install it?

You can install it using npm:

npm install @slimy/hva

Or using Pnpm:

pnpm install @slimy/hva

Or using Yarn:

yarn add @slimy/hva

How to use it?

First of all, have in count two things, HVA doesn't support type safety right now, and it has been tested only in React and Svelte, is as simple as it can be.

Now, you can add default styles to the components.

React

import hva from '@slimy/hva';

const button = hva({
   variants: {
    intent: {
      primary: [styles]
    }
    } 
    // You can add other styles here as well
}, [defaultStyles]) // Default styles are not required

export function Button({intent, className, ...props}) {
    return <button className={button({intent, className})}>Click me</button>
}

Svelte

<script lang="ts">
import hva from '@slimy/hva'

  export let intent: 'primary' | 'secondary' = 'primary';
  
  const styles = hva({
    variants: {
    intent: {
      primary: [styles]
    }
    }  
  }, [defaultStyles]) // Default styles are not required;

  $: haru = `${styles({ intent, class: $$props.class })}`;
</script>

<button class={haru}>Click me!</button>

Then you can use it like this in both React and Svelte:

<Button intent="primary" />

How to contribute?

Making an issue is the most helpful way possible, I will try to fix it as soon as possible.

If you want to contribute to the code, you can make a pull request, and I will review it as soon as possible.

License

This project is licensed under the MIT License.