Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
@primer/primitives
Advanced tools
Color, spacing, and typography primitives for GitHub's Primer design system
This package contains the color, spacing, and typography primitives (AKA constants or "tokens") that form the foundation of Primer, GitHub's design system.
This repository is distributed with npm. You can install it with:
$ npm install --save @primer/primitives
The package's default JavaScript export is an object with the following keys:
colors
is the colors objectspace
is the spacing objectfontSizes
is from typographylineHeights
is from typographyThere are separate exports for colors
, space
, and typography
. For instance, to enumerate the colors:
// all of the following are equivalent:
let {colors} = require('@primer/primitives')
colors = require('@primer/primitives/colors')
colors = require('@primer/primitives/colors.json')
for (const [name, value] of Object.entries(colors)) {
console.log(`colors.${name} = ${JSON.stringify(value)}`)
}
This default export object is suitable for use as a theme source in CSS-in-JS libraries such as styled-components and emotion, and is specifically tailored for use with styled-system's style functions.
Here's an example using styled-components:
import React from 'react'
import styled, {ThemeProvider} from 'styled-components'
import theme from '@primer/primitives'
const Alert = styled.div`
color: ${props => props.theme.colors.green[9]};
background-color: ${props => props.theme.colors.green[2]};
`
const App = props => (
<ThemeProvider theme={theme}>
<Alert />
</ThemeProvider>
)
And styled-system:
import React from 'react'
import styled, {ThemeProvider} from 'styled-components'
import {color} from 'styled-system'
import theme from '@primer/primitives'
const Alert = styled.div`
${color}
`
const App = props => (
<ThemeProvider theme={theme}>
<Alert color='green.0' bg='green.2' {...props} />
</ThemeProvider>
)
Refer to the styled-system table for more information.
The colors object represents Primer's color system. The following keys represent single RGB hex colors:
black
is not "pure" black, but is darker than the darkest graywhite
is pure white (#fff
)The rest of the keys are arrays representing gradients of a certain hue, from lightest to darkest:
gray
blue
green
yellow
orange
red
purple
The space
object is an array of numeric pixel values that represent Primer's spacing scale.
These primitives are the foundation of Primer's typography styles. These keys are merged into the theme object:
fontSizes
represents Primer's font size scale in pixels, from smallest to largest.lineHeights
is an object with keys for each of Primer's named line heights: default
, condensed
, and condensedUltra
.The typography primitives are also available in JavaScript via the @primer/primitives/typography
export, with or without the .json
filename extension.
FAQs
Typography, spacing, and color primitives for Primer design system
The npm package @primer/primitives receives a total of 49,694 weekly downloads. As such, @primer/primitives popularity was classified as popular.
We found that @primer/primitives demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 15 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.