JSPM

@primer/primitives

0.0.0-20220915103511
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 71175
  • Score
    100M100P100Q165331F
  • License MIT

Typography, spacing, and color primitives for Primer design system

Package Exports

  • @primer/primitives
  • @primer/primitives/dist/deprecated/colors
  • @primer/primitives/dist/deprecated/colors.json
  • @primer/primitives/dist/js/index.js
  • @primer/primitives/dist/json/colors/dark.json
  • @primer/primitives/dist/json/colors/dark_colorblind.json
  • @primer/primitives/dist/json/colors/dark_dimmed.json
  • @primer/primitives/dist/json/colors/dark_high_contrast.json
  • @primer/primitives/dist/json/colors/light.json
  • @primer/primitives/dist/json/colors/light_colorblind.json
  • @primer/primitives/dist/json/colors/light_high_contrast.json
  • @primer/primitives/dist/removed/colors
  • @primer/primitives/dist/removed/colors.json
  • @primer/primitives/tokens-v2-private/ts/tokens/functional/size/viewport
  • @primer/primitives/tokens-v2-private/ts/tokens/functional/size/viewport.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@primer/primitives) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Primer Primitives

npm package

This repo contains values for color, spacing, and typography primitives for use with Primer, GitHub's design system.

primer primitives diagram

Install

This repository is distributed on npm. After installing npm, you can install @primer/primitives with this command.

$ npm install --save @primer/primitives

Usage

Primitive data is served in several formats from the dist/ folder:

  • dist/scss contains SCSS files that define CSS variables to be imported into other SCSS files
  • dist/json contains JSON files for each set of primitives
  • dist/js contains CommonJS-style JavaScript modules for each set of primitives, as well as an index file that loads all of the primitives for all primitive types; you can access this via require('@primer/primitives'). The JavaScript modules also include TypeScript typings files for use in TypeScript projects.

Deprecating variables

To deprecate a variable, define a mapping from the deprecated variable to its replacement(s) in a file called deprecated.json in the appropriate subdirectory of data:

  data/
    colors/
+     deprecated.json
    spacing/
    ...
// data/colors/deprecated.json
{
{
  "text.primary": "fg.default", // this means: `text.primary` is deprecated. Use `fg.default` instead
  "auto.blue.4": ["accent.fg, accent.emphasis"], // this means: `auto.blue.4` is deprecated. Use `accent.fg` or `accent.emphasis` instead
  "text.white": null // this means: `text.white` is deprecated. We don't have a replacement for it
}
}

During the build process, the deprecated.json files will be added to a dist/deprecated directory organized by variable category:

  dist/
    js/
    ts/
    json/
    scss/
+   deprecated/
+     colors.json

Removing variables

When you're ready to remove a variable, first remove it's definitions:

// data/colors/vars/global_light.ts
import {get} from '../../../src/utils'

export default {
  text: {
-   primary: get('scale.gray.9'),
    secondary: get('scale.gray.6')
  }
}
// data/colors/vars/global_dark.ts
import {get} from '../../../src/utils'

export default {
  text: {
-   primary: get('scale.gray.1'),
    secondary: get('scale.gray.3')
  }
}

Then remove it from deprecated.json and add it to removed.json:

// data/colors/deprecated.json
{
- "text.primary": "fg.default"
}
// data/colors/removed.json
{
+ "text.primary": "fg.default"
}

During the build process, the removed.json files will be added to a dist/removed directory organized by variable category:

  dist/
    js/
    ts/
    json/
    scss/
    deprecated/
+   removed/
+     colors.json

License

MIT © GitHub