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

@brochington/horizon

v0.2.0

Published

CSS generator and CLI

Downloads

63

Readme

horizon

CSS generator done right.

Horizon is a Functional CSS generator. It's kinda like Tailwind, but isn't part of the build step. This makes it very easy to use in non-compiled projects.

No default colors are given. You must declare them in a config.

Setup

# Simply run the horizon cli in your project
$ horizon

Configuration

You may add a horizon.config.js in the root of you project. example:

const config = { /* your config */};

module.exports = {
  path: 'src/client/styles',
  filename: 'horizon-styles.css',
  docPath: 'docs/styles/site',
  config,
};

Check out the defaultConfig.js file to see an example of what the config looks like. Also know that this is the config that is extended when declaring your own config.

Media Queries

const config = {
  mediaQueries: {
    // The key will be used as a prefix to classes, e.g. su:wrem-3
    su: 'screen and (min-width: 1rem)',
    so: 'screen and (max-width: 39.9375rem)',
    mu: 'screen and (min-width: 40rem)',
    mo: 'screen and (min-width: 40rem) and (max-width: 63.9375rem)',
    lu: 'screen and (min-width: 64rem)',
    lo: 'screen and (min-width: 64rem) and (max-width: 74.9375rem)',
    // You may define your own media queries
    foo: {
      media: 'screen and (max-width: 80rem)',
      // Any additional css that you want scoped to the same media query
      // may be added with the `css` property.
      css: `
      .hello {
        color: orange;
      }
      `
    }
  },
}

Compose

It can be a pain to write a bunch of functional css classes, so an option in the config is given called compose.

const config = {
  compose: {
    // a class called "something" with all the css properties specified in the value string.
    something: "m1 wrem-3.5 bgd-dark-teal",
    foo: 'bar hrem-3.5 lo:ws1'
  },
};

Something cool to maybe integrate in the future

CSS-media-vars: https://github.com/propjockey/css-media-vars

Things to add

Lot's more modifiers

  • dark mode
  • transforms?
    • like scale-150 translate-y-11
  • Grid?

prefixes:

  • h: hover
  • f: focus`
  • a: active
  • d: dark mode
  • so: media query, dynamic, whatever is added to the config.

Using with PurgeCSS

Need to add a custom extractor. Check out the one that tailwind uses

const _ = require('lodash');

function tailwindExtractor(content) {
  // Capture as liberally as possible, including things like `h-(screen-1.5)`
  const broadMatches = content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || []
  const broadMatchesWithoutTrailingSlash = broadMatches.map((match) => _.trimEnd(match, '\\'))

  // Capture classes within other delimiters like .block(class="w-1/2") in Pug
  const innerMatches = content.match(/[^<>"'`\s.(){}[\]#=%]*[^<>"'`\s.(){}[\]#=%:]/g) || []

  return broadMatches.concat(broadMatchesWithoutTrailingSlash).concat(innerMatches)
}