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

@nycopportunity/pttrn-plugin-properties

v1.1.1

Published

A plugin command script for the https://github.com/nycopportunity/patterns-cli that will compile JSON tokens into CSS Custom Properties.

Downloads

5

Readme

Patterns CLI CSS Properties Plugin

A plugin command script for the Patterns CLI that will compile an array of JSON objects containing design tokens into CSS Custom Properties using the css-vars-from-json package.

Usage

Install as a development dependency in a project that uses the Patterns CLI.

$ npm install @nycopportunity/pttrn-plugin-properties -D

Add a proxy command script in the ./bin/ directory:

$ touch bin/properties.js
$ echo "module.exports = require('@nycopportunity/pttrn-plugin-properties');"

This will make the command available to the CLI. Compile the sprite by running:

$ npx pttrn properties
$ ⚫ Tokens in ./config/tokens.js out ./src/config/_tokens.scss

Can also be ran with the watching flag -w.

$ npx pttrn properties -w
$ 👀 Properties watching ./config/properties.js, ./config/tokens.js
$ 👀 Detected change on ./config/tokens.js
$ ⚫ Properties written to dist/css/tokens.css

The dist/css/tokens.css will contain a :root { ... } declaration with all of the properties in the tokens file inside.

Config

A config file named properties.js should be added to the /config directory that exports an array of objects with CSS Custom property settings. Each object should include the the following options:

Option | Type | Description -------------|----------|- dist | String | The output file for the CSS Custom Properties file. ruleset | String | The rule-set properties will be attached to. Defaults to :root. May include multiple classes such as :root, .dark. This can be used to narrow the limit the scope of CSS Custom Properties. properties | Object | The CSS Custom properties object. Individual tokens can be added or they can be imported from the local ./config/tokens.js file used by the tokens command.

Config Sample

const resolve = require(`${process.env.PWD}/node_modules/@nycopportunity/pttrn/bin/util/resolve`);
const tokens = resolve('config/tokens', true, false); // The resolve utility prevents the tokens file from being cached

let light = tokens['color-modes']['light'];
let dark = tokens['color-modes']['default'];

module.exports = [
  {
    'dist': 'dist/styles/tokens.css',
    'properties': {
      ...tokens
    }
  },
  {
    'dist': 'dist/styles/tokens-default.css',
    'ruleset': ':root, .light',
    'properties': {
      ...dark
    }
  },
  {
    'dist': 'dist/styles/tokens-dark.css',
    'ruleset': '.dark',
    'properties': {
      ...light
    }
  }
];