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

@dawiidio/quarksy

v0.0.6

Published

Compact design tokens parser

Downloads

4

Readme

@dawiidio/quarksy

This is a small, 0-dependency design-tokens parser. What are design tokens? For example, you may check out figma and their Tokens Studio to learn more. In one sentence: tokens are single source of truth for both designers and developers saved in json file which you can export from e.g. Figma tool.

For example, it can generate css output for tokens like the below example:

:root {
    --sizing-base: 2px;
    --sizing-xs: 4px;
    --sizing-s: 8px;
    --sizing-m: 24px;
    --sizing-l: 24px;
    --sizing-xl: 32px;
    --colors-primary-100: #c7fadb;
    --colors-primary-500: #05eb62;
    --colors-primary-900: #066d2f;
    --colors-secondary-100: #e9d5f8;
    --colors-secondary-500: #941bf0;
    --colors-secondary-900: #3e046a;
    --font-size-s: 14px;
    --font-size-m: 16px;
    --font-size-l: 24px;
    --font-size-xl: 36px;
    --border-radius-m: 6px;
    --font-family-primary: Ubuntu;
    --font-family-secondary: Nunito;
    --font-weight-bold: 800;
    --font-weight-thin: 300;
    --font-weight-normal: 500;
    --spacing-s: 4px;
    --spacing-m: 8px;
    --spacing-l: 24px;
}

.typography-H3 { 
   font-family: Nunito;
   font-weight: 500;
   font-size: 36px; 
}

.typography-Body1 { 
   font-family: Ubuntu;
   font-weight: 300;
   font-size: 16px; 
}

it will resolve all token aliases like the below ones

{
  "typography": {
    "H3": {
      "value": {
        "fontFamily": "{fontFamily.secondary}",
        "fontWeight": "{fontWeight.normal}",
        "fontSize": "{fontSize.xl}"
      },
      "type": "typography"
    }
  }
}

to these values:

.typography-H3 { 
   font-family: Nunito;
   font-weight: 500;
   font-size: 36px; 
}

Installation

npm i @dawiidio/quarksy

// or

yarn add @dawiidio/quarksy

Cli usage

Usage: quarksy [options] [inputFile]

Transforms design tokens to code

Arguments:
  inputFile                    tokens file to be transformed (default: "tokens.json")

Options:
  -V, --version                output the version number
  -p, --platform <string...>   for which platforms you want to transform your tokens (default: ["css"])
  --token-prefix <string>      prefix for token variable names
  --token-set-prefix <string>  prefix for token sets variable names, eg. typography which may be build of many
                               properties
  -o, --output-dir <string>    output directory
  -h, --help                   display help for command

Programmatic usage

Below you can see simple example, for implementation hints see src/platforms/CssPlatform.ts

import {
    TokensObjectParser,
    writePlatformOutputToFileSystem,
    Platform
} from '@dawiidio/quarksy';

async function main() {
    const myDesignTokensObject = {
        // json export from eg. Figma tokens
    };

    const tokensObjectParser = new TokensObjectParser(myDesignTokensObject);

    class MyPlatform extends Platform {
        run(tokensObject: TokensObjectParser): [string, string][] {
            // do something to transform tokensObject to platform specific code
            return []
        }
    }

    const myPlatform = new MyPlatform();
    
    await writePlatformOutputToFileSystem(myPlatform.run(tokensObjectParser));
}

Supported platforms

For now only CSS, soon will be more :)