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

@department-of-veterans-affairs/mobile-tokens

v0.23.0

Published

VA Design System Mobile Token Library

Downloads

5,961

Readme

VA Mobile Design System - Tokens Package

The Tokens package contains the design tokens for the VA Mobile Design Library. It uses Style Dictionary as a build system to define our styles in JSON and export them to different formats.

For consumers

Direct consumption of the tokens package is optional, but recommended. The tokens package contains the same building blocks used to build the design system components which will more easily allow screen content and app-level custom components to follow design system conventions, helping maintain consistency in experience for users. It is also recommended to match the tokens package version to the version of tokens used by the components package you are leveraging, to ensure consistency.

Token Usage

To use the tokens, simply:

  1. Add @department-of-veterans-affairs/mobile-tokens to your project via your package manager (e.g. yarn)
  2. Add import { colors } from '@department-of-veterans-affairs/mobile-tokens to files you wish to use them in.
  3. Reference colors in your code: e.g. buttonColor = colors.vadsColorGrayMedium

Themes

The tokens package also has light and dark themes available. These themes are a subset of the colors tokens above, containing primitive colors, semantic tokens without an OnLight or OnDark mode specified, and the colors for only the light or dark themes respectively. The OnLight and OnDark mode suffixes are also removed.

The purpose of themes is to allow for assignment of color tokens without the need to specify the light or dark mode, and let your theme provider or handler return the correct theme. For example: instead of having a conditional where you'd assign either the colors.vadsColorForegroundDefaultOnLight or colors.vadsColorForegroundDefaultOnDark token, you could instead use theme.vadsColorForegroundDefault if your app already knows which color scheme it wants to use.

Using theme tokens directly

  1. Add @department-of-veterans-affairs/mobile-tokens to your project via your package manager (e.g. yarn)
  2. Add import { themes } from '@department-of-veterans-affairs/mobile-tokens to files you wish to use them in.
  3. Reference the theme in your code using either themes.light or themes.dark

useTheme hook

We have also made a hook available in the component library that will return the appropriate light or dark theme based on the user's OS setting. To use the hook:

  1. Add @department-of-veterans-affairs/mobile-component-library to your project via your package manager (e.g. yarn)
  2. Add import { useTheme } from '@department-of-veterans-affairs/mobile-component-library'
  3. Use the hook to at the top of your component function to retrieve either the light or dark theme based on the device's current color scheme. e.g.
  const theme = useTheme()

  const componentStyle = {
    color: theme.vadsColorForegroundDefault
  }

For contributors

Depending on what is being contributed, the recommendation for how to proceed differs.

If you are contributing a simple addition or update of an existing token, the recommendation is to do so in the GitHub web interface by updating the relevant src tokens file and running an alpha publish against the branch for the package to affirm the dist/ folder correctly forms up your updated/added token as expected in the resulting NPM package.

If you are contributing many tokens or need to adjust build processes, you should get set up locally. See the directions in the components package documentation for doing so with minor modifications to that process of changing directory to the tokens package (va-mobile-library/packages/tokens) instead of components and not having the final running steps as the tokens:build command is essentially running the tokens as it generates the output folders based on the build/config setup and tokens in the src/ folder.

Note: the folder structure and file naming within the src/ folder is relevant so follow the existing structure and direct questions to the DSVA Slack channel.

Yarn Commands

| Command | Description | | -------------------- | ----------- | | tokens:build | Takes any JSON files in the src/tokens folder and transforms them according to the defined transformations in the config.js |