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

varbq

v1.0.12

Published

Generate CSS and JS variables from a JSON file

Downloads

5

Readme

varbq is a package that helps you generate CSS and TypeScript variable files based on a theme configuration.

Installation

To install varbq, use npm or yarn:

npm install --save-dev varbq

Next run npx varbq build. This will build the varbq.json file (if it doesn't yet exist).

Usage

npx varbq build

Generates CSS and TypeScript variable files based on the theme configuration. This command should be run from the root directory of your project.

This command will also create the varbq.json file with default configuration (if it doesn't exist already) and generate the CSS and TypeScript files in the theme folder.

varbq watch

Watches for changes in the theme configuration file (varbq.json) and automatically rebuilds the CSS and TypeScript files whenever a change is detected. Watch will not work without a varbq.json file.

npx varbq watch

This command will start watching the varbq.json file and regenerate the CSS and TypeScript files whenever it changes.

Args

You can also pass in the following flags:

--js will only generate the ts file. For example: npx varbq watch --js.

--css will only generate the css file. For example: npx varbq build --css.

If no flags are passed, both files will be created by default.

Configuration

The varbq.json file contains the theme configuration. The key names can be whatever you want as long as nothing is nested and each key name contains an array of values.

{
  "primary": ["hsl(216, 99%, 98%)", "hsl(216, 98%, 92%)", "hsl(216, 95%, 86%)"],
  "secondary": ["hsl(40, 99%, 98%)", "hsl(40, 98%, 92%)", "hsl(40, 95%, 86%)"],
  "typography": ["8px", "10px", "12px", "16px", "24px"],
  "spacing": ["4px", "8px", "12px", "16px"]
}

Modify the colors, typography, and spacing variables (or whatever else you want) to customize the generated CSS and TypeScript files. Each array gets converted into the key name plus adds 100 onto each successive item in the array. For example, the primary key becomes:

:root {
  --primary100: hsl(216, 99%, 98%);
  --primary200: hsl(216, 98%, 92%);
  --primary300: hsl(216, 95%, 86%);
  ...;
}

And:

export const varbq = {
  primary100: "hsl(216, 99%, 98%)",
  primary200: "hsl(216, 98%, 92%)",
  primary300: "hsl(216, 95%, 86%)",
  ...
}

Integrating with npm scripts

To automatically run npx varbq watch when starting your development server, you can add it to your start or dev script in the scripts section of your package.json file.

For example, if your package.json file has the following script:

"scripts": {
  "dev": "npm run start",
  "start": "node server.js"
}

You can modify it to include npx varbq watch:

"scripts": {
  "dev": "npm run start & npx varbq watch",
  "start": "node server.js"
}

Now, when you run npm run dev, it will start your development server and concurrently run npx varbq watch to regenerate the CSS and TypeScript files whenever a change is detected in the varbq.json file.

Remember to adjust the script configuration based on your project setup. And don't forget to import the variable files where needed.