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 🙏

© 2022 – Pkg Stats / Ryan Hefner

@guardian/pasteup

v2.0.0-alpha.2

Published

Guardian design tokens

Downloads

201

Readme

Pasteup

The Guardian Design Tokens are intended to be used in conjunction with a CSS-in-JS library such as Emotion.

Under construction 🚧

This file documents the current version of Pasteup. This package is still under heavy construction, please do not install this in applications intended for use in production. The API may change significantly before it is out of alpha.

Motivation

For an introduction to the origins of Pasteup, see Motivation.

Usage

This section gives examples of the current usage of Pasteup

Breakpoints

Example

import { desktop } from '@guardian/pasteup/breakpoints';

const wrapper = css`
    ${desktop} {
        max-width: 620px;
        margin-right: 310px;
        padding-left: 10px;
    }
`;

Where desktop will be replaced by

@media (min-width: 980px)

Reference

The starting point is the base mapping (breakpoints)

| name | size | | :-------------- | -----: | | mobile | 320px | | mobileMedium | 360px | | mobileLandscape | 480px | | phablet | 660px | | tablet | 740px | | desktop | 980px | | leftCol | 1140px | | wide | 1300px |

The API exposes the following values:

  1. mobile, mobileMedium, mobileLandscape, phablet, tablet, desktop, leftCol and wide. For instance, mobile is replaced by

    @media (min-width: 980px)
  2. until.[symbol], where symbol ranges over the constants in subsection 1). For instance, until.desktop is replace by

    @media (max-width: 979px)
  3. from.[symbol1].until.[symbol2], where symbol ranges over the constants in subsection 1). For instance, from.tablet.until.desktop is replaced by

    @media (min-width: 740px) and (max-width: 979px)

Fonts

import { textSans } from '@guardian/pasteup/typography';

const footer = css`
    ${textSans(6)}
    margin-top: 20px;
`;

Note the use of the function textSans imported from typography.

typography exposes three functions: headline, body and textSans, all taking a number/integer and returning a CSS string. For instance

textSans(2) =
font-size: 13px; line-height: 18px; font-family: GuardianTextSans, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif

The current mapping is hardcoded in the code of typography and is:

const fontScaleMapping: any = {
    headline: {
        1: { fontSize: 14, lineHeight: 18 },
        2: { fontSize: 16, lineHeight: 20 },
        3: { fontSize: 20, lineHeight: 24 },
        4: { fontSize: 24, lineHeight: 28 },
        5: { fontSize: 28, lineHeight: 32 },
        6: { fontSize: 32, lineHeight: 36 },
        7: { fontSize: 36, lineHeight: 40 },
        8: { fontSize: 40, lineHeight: 44 },
        9: { fontSize: 44, lineHeight: 48 },
    },
    body: {
        1: { fontSize: 14, lineHeight: 20 },
        2: { fontSize: 16, lineHeight: 24 },
        3: { fontSize: 18, lineHeight: 28 },
    },
    textSans: {
        1: { fontSize: 12, lineHeight: 16 },
        2: { fontSize: 13, lineHeight: 18 },
        3: { fontSize: 14, lineHeight: 20 },
        4: { fontSize: 14, lineHeight: 22 },
        5: { fontSize: 16, lineHeight: 22 },
        6: { fontSize: 18, lineHeight: 18 },
        7: { fontSize: 20, lineHeight: 20 },
    },
};

// together with

`serif.headline`: `font-face: GH Guardian Headline, Georgia, serif`
`serif.body`: `font-face: GuardianTextEgyptian, Georgia, serif`
`sans.body`: `font-face: GuardianTextSans, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif`

This mapping may see adjustements in the future.

Mixins

import { screenReaderOnly } from '@guardian/pasteup/mixins';

css`
    ${screenReaderOnly};
`;

Palette

import { palette } from '@guardian/pasteup/palette';

const footerLink = css`
    color: ${palette.neutral[100]};
    :hover {
        color: ${palette.highlight.main};
    }
`;