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

@rhds/tokens

v2.1.0

Published

Red Hat Design System Tokens

Downloads

2,520

Readme

Red Hat Design Tokens

Design Tokens for Red Hat's Digital Design System.

🚚 Installation

npm i @rhds/tokens

🎭 Usage

We use style-dictionary to transform our tokens into multiple formats and helpers.

Global CSS

Apply defaults to the document root by importing the global stylesheet:

<link rel="stylesheet" href="/url/to/@rhds/tokens/css/global.css">
<style>
  :is(h1, h2, h3, h4, h5, h6) {
    font-family: var(--rh-font-family-heading);
  }
</style>

Shadow Root Reset

Reset a component's styles (preventing inheritance) by adding resetStyles to it's static Constructible Style Sheet list:

import { resetStyles } from '@rhds/tokens/css/reset.css.js';
import style from './rh-jazz-hands.css';

@customElement('rh-jazz-hands')
export class RhJazzHands extends LitElement {
  static readonly styles = [resetStyles, style];
}

JavaScript Objects

Import tokens as JavaScript objects:

import { tokens } from '@rhds/tokens';

html`<span style="color: ${tokens.get('--rh-color-blue-300')}">I'm blue</span>`;

or for tree-shakable imports:

import { ColorBlue300 } from '@rhds/tokens/values.js';

html`<span style="color: ${ColorBlue300}">I'm blue</span>`;

:warning: NOTE

We strongly recommend using CSS variables (and accompanying snippets) wherever, instead of importing tokens as JavaScript objects.

Stylelint Plugin

Install the stylelint plugin to automatically correct token values in your files.

See the Stylelint Plugin README for more info.

11ty Plugin

The experimental 11ty plugin lets you display token values in an 11ty site.

Editor Snippets

Editor snippets complete prefixes like --rh-color-brand to their CSS custom properties, complete with fallback, e.g.

color: var(--rh-color-brand, #ee0000);

They also provide reverse lookup, so if you want to choose between all the tokens with value #e00, you can do so by completing the prefix e00.

Load snippets in VSCode: Download the VSIX bundle from the releases page. Or, search the VSCode marketplace for Red Hat Design Tokens

Load snippets in neovim via LuaSnip:

require 'luasnip.loaders.from_vscode'.lazy_load { paths = {
  -- Path to the built project, perhaps in your `node_modules`
  '~/Developer/redhat-ux/red-hat-design-tokens/editor/vscode'
} }

vim-hexokinase

Vim users can load the vim-hexokinase plugin to display colour swatches next to their encoded values in their editor. Use the following config (lua syntax, for neovim users) to configure hexokinase to display colour values next to colour aliases like {color.brand.red}

vim.g.Hexokinase_optInPatterns = {
  'full_hex', 'triple_hex',
  'rgb', 'rgba',
  'hsl', 'hsla',
  'colour_names',
}

vim.g.Hexokinase_ftOptOutPatterns = {
  json = { 'colour_names' },
  yaml = { 'colour_names' },
}

vim.g.Hexokinase_palettes = {
  -- replace with path to the built tokens package on your drive
  vim.fn.expand'~/Developer/redhat-ux/red-hat-design-tokens/editor/neovim/hexokinase.json'
}

🏆 Contributing

See CONTRIBUTING.md