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

@hyphen/hyphen-design-tokens

v4.18.0

Published

Design tokens that power all Hyphen UIs.

Downloads

1,061

Readme

Hyphen Design Tokens

npm version

A central location to store shared attributes of the hyphen Design System. These attributes include: colors, fonts, spacing, and more. Using Amazon's Style Dictionary we transform attributes into usable variables for a variety of platforms.

Table of Contents

Usage

Install The package in your project

npm install @hyphen/hyphen-design-tokens

or

yarn add @hyphen/hyphen-design-tokens

Import tokens into your project based on your platform requirements

Ideally you'd want to import them into a file that exposes them to your entire application.

CSS Variables imported into a .css file

@import '~@hyphen/hyphen-design-tokens/build/css/variables.css'

SASS Variables imported into a .scss file

@import '~@hyphen/hyphen-design-tokens/build/scss/variables.scss'

CSS Utility Classes imported into a .css file

@import '~@hyphen/hyphen-design-tokens/build/utilities/utilities.css'

Use variables as needed

CSS

.class-with-base-text-color: { color: var(--color-font-base); }
--my-own-shadow-variable: 1rem 1rem var(--color-base-black);

Using Icons

The library includes custom svg icons from the design system. They are provided in two formats, svg or as React components.

They can be pulled from the build here:

@hyphen/hyphen-design-tokens/build/assets/icons/ // <-- SVG ICONS
@hyphen/hyphen-design-tokens/build/assets/icons/react // <-- React Components. NOTE: there is an index file that maps all icons in a dictionary, but they can also be used individually.

USING RAW SVGs

<img src="../user.svg" alt="user">

USING REACT COMPONENTS

import UserIcon from '@hyphen/hyphen-design-tokens/build/assets/icons/react/Add'; <-- Single Icon Import

// or
import icons from '@hyphen/hyphen-design-tokens/build/assets/icons/react; <-- Icon map

const MyUserIcon = icons['user']; <-- Use icon name to.

<MyUserIcon {...props} />


// All icon names are documented in the IconName union type.
import { IconName } from '@hyphen/hyphen-design-tokens/build/types';

Available Tokens

  • Assets
    • Font Family
  • Color
    • Brand
    • Font
    • Border
  • Size
    • Border
    • Border Radius
    • Box Shadow
    • Breakpoint
    • Height
    • Font Size
    • Font Weight
    • Line-Height
    • Spacing
    • Width
    • Z-Index

Local Development

To build tokens locally run npm run build or yarn build. NOTE: you will need a local .env file with a Figma access token assigned to FIGMA_PERSONAL_ACCESS_TOKEN. See HOW TO GET A FIGMA ACCESS TOKEN. If you are still unsure how to get a working access token, or the process is not working for you, please reach out to one of our library owners.

In order to test any local changes you'll need to build tokens, and symlink your local package into any project that consumes it. See NPM link or Yarn link for more details.

Update Tokens via file

TDB

Updating Icons

The build process handles the following:

  • mapping any svg icons in the /icons folder into the appropriate build directory
  • updating the IconName type based on the file names in the directory.
  • Creating corresponding react components for each svg, and transpiling the resulting JSX with babel.
  • Regenerating the icons index map for use in react applications.

As a developer, to update icons all that needs to be done is add them to the /icons folder with the name that you want the icon to have. Please follow these rules when exporting and adding icons:

  • SVGs should be exported with a size of 16x16px since this will be the size of our default viewbox.
  • SVGS should be exported with default width, height of 1em so they will inherit their size from the adjacent element font sizes, or a class/style applied directly.
  • SVGs must not include fill or stroke color, instead being exported with a value of 'currentColor' for both these attributes. This will ensure proper inheritance.
  • Remove any classNames or title that might be in the svg file
  • SVG files should be named using kebab-case.
  • Commit your changes using the following commit message format: 'feat(Icon): new-icon-name, new-icon-name2`
  • Open a pull request and get it approved for publishing

Releases

↥ back to top

hyphen Components uses the semantic-release npm package to fully automate the release workflow. Instead of manually updating the release version in package.json, and creating a new release tag in GitHub for each release, they are automatically triggered by prefixing the commit message when merging to main. Upon triggering a release, the package version is bumped depending on the type specified, a release tag is created in GitHub, and the new version is automatically published to npm.

For example, opening a PR to main with the commit message fix: Resolve bug, will trigger a minor release and bump the package's version from 0.0.0 to 0.0.1. Opening a PR with feat(Table): Finalize tests will trigger a feature release and bump the package's version from 0.0.0 to 0.1.0.

The link above provides full documentation for this workflow. However, a comprehensive list of the prefix types, and their intended uses are provide below for quick reference:

Release Types

Must be one of the following:

Major

  • BREAKING CHANGE: A set of breaking changes.

Minor

  • feat: A new feature

Patch

  • fix: A bug fix
  • perf: A code change that improves performance
  • ci: A change to our CI pipelines/workflows.
  • build: A change to the library build process (That does not break the consumer API).
  • test: Added or improved testing in some area of the library.
  • refactor: Changed code structure without affecting features.
  • docs: Added to, or improved documentation.
  • style: Change in code style without affecting features.

Prerelease

If your code includes major changes or any breaking changes to the codebase, I.E, a new major version, or a large refactor, that will require a pre-release, and more extensive testing. To publish a pre-release, open (and eventually merge) your PR against the beta branch. This will publish the package with a @beta tag which can then be easily consumed and tested by other consumers locally.

How to Publish to NPM

Publishing to NPM is handled automatically by the CI/CD pipeline. Here are the steps:

  1. Bump the version in package.json to the appropriate type, and merge your PR to main.
  2. Create a release in github with the appropriate version number. This will trigger the CI/CD pipeline to publish the package to NPM.

If you need to publish a pre-release, or a hotfix, you can do so manually by following these steps:

  1. Checkout the main branch
  2. Run npm run build to ensure the package is up to date
  3. Run npm version [major | minor | patch | prerelease] to bump the package version
  4. Run npm publish --tag <insert tag> to publish the package to NPM