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

@preply/ds-tokens

v0.17.0

Published

> Source of truth for design tokens (+ code generators).

Downloads

3

Readme

@preply/ds-tokens

Source of truth for design tokens (+ code generators).

Using the Design System in your application or library?

Follow the instructions in @preply/ds-workspace.

tl;dr:

import { tokens } from `@preply/ds-core`;
import { useToken } from `@preply/ds-web-core`;

const color = useToken(tokens...);

Development

You probably want to execute yarn dev and/or yarn docs in the root, as per instructions in @preply/ds-workspace.

More details about tools and configurations in @preply/ds-workspace.

Authoring

  • yarn build - validates and builds themes
  • yarn dev - validates and builds every time a data file is modified
  • yarn resolve - get help with one token
    • yarn resolve preply-ui action.variant.primary.color invert

Data files

Source of truth for tokens, types, themes, is stored in data/.

  • tokens.json defines which tokens should exist in themes using patterns such as palette.*.*.color
  • options.json defines which options go into those * placeholders, and which ones should exist as a type in @preply/ds-core
  • themes.json declares which themes exist in the system (and the dependencies between them)
  • schemes.json declares which color schemes exist in the system

How it works

Code generation

We are using:

Generated files

Following the spec in Token System:

  • @preply/ds-tokens
    • dist/metadata.json
  • @preply/ds-core
    • src/generated/tokens.ts
  • @preply/ds-web-core
    • src/generated/tokens.less
  • @preply/ds-web-root
    • src/generated/themes.ts
    • src/generated/themes.module.less
  • @preply/ds-theme-*
    • src/generated/web/constants.ts
    • src/generated/web/theme.module.less

Troubleshooting

Search for * FILE to locate the function responsible for each generated file.

All functions are documented with a sample of the generated code.

Validation rules (WIP)

The following validations will be implemented progressively, not with the first version of this package.

Options

  • no repeated patterns
  • for each pattern
    • no repeated types
    • no repeated defaults
    • no repeated option ids

Schemes

  • for each scheme
    • for each scheme.extends
      • value must exist in schemes.items

Tokens

  • validate id collisions

Themes

  • for each theme
    • for each theme.extends
      • [ ] value must exist in themes.items
      • for each token in theme
        • [x] token needs to exist
        • [x] data must match the expected format depending on scheme true/false
        • [ ] if value is {reference} it must be a valid token name
        • if color scheme
          • for each "base" color scheme
            • [x] value must be provided
    • if theme is a "base" theme (does not extend other themes)
      • for each token in expanded tokens
        • [x] theme must implement token

Dependencies

This packages is essentially a Node.js build-time package that generate codes therefore it depends on:

  • typescript - uses its factory API to generate TS code.
  • chokidar, lodash, etc..

Note: This package could theoretically use some of the types from @preply/ds-core but we don't want to add that dependency because this tool is responsible for generating some of the type files in there.

Dev dependencies

Relies on ts-node for executing TS in Node.js.