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

@entur/tokens

v3.14.0

Published

This package contains all design tokens and design variables used throughout the design system. We are currently in a process to migrate over to a new design variable system based on [Figma Variables](https://help.figma.com/hc/en-us/articles/1533965713538

Downloads

10,115

Readme

Entur design tokens

This package contains all design tokens and design variables used throughout the design system. We are currently in a process to migrate over to a new design variable system based on Figma Variables.

Since not all values are available as a variable yet and to avoid breaking changes, all previous design tokens will be kept around for a while. These are built from the src/legacy-tokens.ts file.

💡 Looking for the documentation?

Installation

npm install @entur/tokens
# or if you are using Yarn:
yarn add @entur/tokens

Usage

Please refer to the documentation for in-depth usage information.

This package has several main exports:

  • a CSS file with all tokens as kebab-cased CSS properties
  • a SCSS file with all tokens as kebab-cased SCSS variables
  • a LESS file with all tokens as kebab-cased LESS variables
  • a JavaScript file with all tokens as nested objects.

CSS

To use the CSS file, import it into your bundle like so:

import '@entur/tokens/dist/styles.css';

You'll then have access to all design tokens as CSS variables. You can then use them like so:

.custom-box {
  background-color: var(--colors-greys-grey10);
  color: var(--colors-brand-coral);
  font-size: var(--font-sizes-medium);
  margin: var(--space-medium) var(--space-large);
}

Please refer to the design system documentation for which ones are available.

LESS / SCSS

To use the LESS or SCSS files, import it into your LESS or SCSS file. The method is the same:

@import '@entur/tokens/dist/styles.less';
@import '@entur/tokens/dist/styles.scss';

You'll then be able to use the variables in your code as usual.

// LESS
.custom-box {
  background-color: @colors-greys-grey10;
  color: @colors-brand-coral;
  font-size: @font-sizes-medium;
  margin: @space-medium @space-large;
}
// SCSS
.custom-box {
  background-color: $colors-greys-grey10;
  color: $colors-brand-coral;
  font-size: $font-sizes-medium;
  margin: $space-medium $space-large;
}

JavaScript

To use the design tokens in JavaScript, import the ones you need like so:

import { StyleSheet } from 'react-native';
import { colors, breakpoints, fontSizes } from '@entur/tokens';

StyleSheet.create({
  example: {
    fontSize: fontSizes.medium,
    color: colors.brand.coral,
  },
});

px vs rem

These values are mainly provided in pixels. If you need the values in rem instead, add a .rem after the token name, e.g. space.rem.large for rem value and space.large for pixel value.

[For maintainers] Updating design variables

There are three steps needed to update the set of available designs variables in this repo:

  1. generate a JSON-export of the variable set from Figma
  2. Update the corresponding JSON-file in the src folder
  3. Build the new variables and commit the changes

1. Generate a JSON export

The JSON is exported from Figma using the variabels2css-plugin, download the plugin if you haven't already. Go to the Figma file containing the variables you want to export, eg. Semantic Colors. In you menu bar, select 'Plugins' and choose 'variables2css' – this opens a modal. Under 'choose your collection' choose the variable set you want to export. Under 'type' choose 'JSON', and under 'color' and 'unit' choose 'hex' and 'rem'. Then click 'Generate' and copy the result.

2. Update JSON file

Back in this repo, find the JSON-variables file you want to update, eg. semantic.json, delete its content and paste the generated result you copied in step 1. Then save the file.

3. Build variables

When the JSON-file content is updated, run the script yarn build inside this package or yarn build:packages from root. This will generate new files with updated values in both this package and in all other packages where the component color value has been updated. Once the build is finished, commit all changes and push the commit.