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

hibiscss

v0.0.12

Published

Tool for making functional css stylesheets

Downloads

17

Readme

Functional css generator

Build Status npm

Functional css (à la tachyons), but customizable for your project's visual language. No more rewriting long stylesheets to include your colours, typefaces, and spacing scale! 🌺

Features

  • flexible: easily define colors, type styles, spacing scales
  • performant: only generates the breakpoints/variables you need (default kit is 3kb, compared to 14kb+ for tachyons)
  • simple: spits out a css string, no fancy client-side work needed
  • just javascript: integrates well with css-in-js, easy to extend, automate documentation, etc.

:construction: This project is still v0.x.x and the API is subject to change.

Install

npm install hibiscss --save

Getting Started

For a quick start, use the default rule kit. You can pass in options to define your project’s visual language:

import hibiscss from 'hibiscss';
import kit from 'hibiscss/default';

const styles = hibiscss(kit({
  colors: {
    pink: '#ffb7b3',
    black: '#141414'
  },
  fontFamily: {
    work: 'Work Sans, sans-serif'
  },
  fontSize: [36, 24, 19, 17, 15, 12]
}));

Then use the classes like so:

<div class="c-pink ff-work fs-2">Work Sans in pink at 24px!</div>

Yay! :tada: Check out the examples or default kit docs for more!

Configuration

Hibiscss returns a string of css. You can integrate it with your build system however you'd like. I find the easiest is to spit out a static css file, like so:

Make a file with your config and output it to console.log, like so:

// css.js

import hibiscss from 'hibscss';
import tachyons from 'hibscss/tachyons';

const styles = hibiscss(tachyons());

console.log(styles);

Then add a package.json script to generate the styles:

{
  "scripts": {
    "build-css": "node css.js > /path/to/styles.css"
  }
}

Run npm run build-css to create your styles, and re-run whenever you make changes to your kit.

Kits

Hibiscss generates css using kits, presets that map your visual language to functional css styles. Hibiscss comes with two kits bundled into the package:

  • default (docs): small, highly customizable kit
  • tachyons (docs): familiar tachyons-like classes

Kits are functions which take options, and return css rules for hibiscss to generate. For example, using the default kit:

import hibiscss from 'hibiscss';
import kit from 'hibiscss/default';

const config = {
  spacing: [0, 8, 16, 24, 48, 64],
  colors: { rausch: '#ff5a5f', foggy: '#767676' },
  fontSize: { title: 44, large: 24, regular: 19 },
  fontWeight: { light: 300, regular: 400, semibold: 600 }
};

const rules = kit(config);
const css = hibiscss(rules);

Will give you classes like:

<div class="c-foggy mh-2 mh-4-m fs-title fw-semibold">Semibold and large</div>

Kits let you customize everything whether you can adjust line heights to how verbose the class names should be (eg. mh-2 vs. marginHorizontal-2).

Making a custom kit

If you'd like fine-grained control over the final css, you can write your own kit. Kits are simply a function that returns a set of rules, created with the rule helper function.

Check out the custom kit example, or read the API docs to learn more.

Motivation

functional css makes css a lot of fun, but many of the toolkits out there are difficult to customize.

I found myself manually editing tachyons colours, typefaces, and breakpoints more times than I’d like. So I built hibiscss to provide a simple structure for quickly generating functional css frameworks.

See also

Lots of prior art in the functional css area:

Hibiscss pairs nicely with:

License

MIT