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

@dwp/components-theme

v0.0.1-alpha.12

Published

CSS-in-JS Shareable Styles built upon govuk-frontend Design System

Downloads

3

Readme

GOV.UK Shareable Styles

This repository provides a framework agnostic theme for intended use alongside any object or tagged template literal framework.

It contains properties and helpers, extracted directly from the SASS-authored govuk-frontend library. If you're looking for the components, click here.

The styles and variables included inside the govuk-frontend are automatically extracted at build time and not hardcoded into this library.

Getting Started

Add the library to your project as a dependency using:

npm i TODO --save

If you need access to the GDS font and crown images, ensure that the contents of the assets/ folder (packaged inside the library) are copied over to your build destination. This can be achieved by adding a postbuild or postinstall script hook to your package.json.

{
  "scripts": {
    "postbuild": "@dwp/components-theme copy --destination ./build/static/"
  }
}

Afterwards, be sure to add the asset paths for the library to your .gitignore file, for example:

/path/to/assets/fonts
/path/to/assets/images

The library is implemented to ensure that it is easy to take advantage of tagged template literals, including numerous helpers designed at producing strings of CSS compatible with various pre-processing frameworks.

Usage

const { typography } = require('@dwp/components-theme');
// OR: import { typography } from '@dwp/components-theme';

console.log(typography.headings.xl());

Using the XL typography heading helper as the example above demonstrates, produces the following valid css string:

Note how the helper makes zero assumptions about the class name or identifier. This responsibility is left to the implementing framework or library.

font-weight: 700;
font-family: 'nta', 'Arial', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;

@media print {
  font-family: sans-serif;
}

@media only screen and (min-width: 320px) {
  font-size: 32px;
  line-height: 35px;
}

@media only screen and (min-width: 641px) {
  font-size: 48px;
  line-height: 50px;
}

Afterwards, we can begin to introduce ES6 tagged template literals to compile more complex components from these base style helpers.

const theme = require('TODO');

const str = tagged`
  ${theme.typography.headings.m()}
  ${theme.spacing.property('padding', { top: 8, right: 7, bottom: 6, left: 5 })}
  margin: ${() => theme.spacing.unit(4)};
`;

The above example produces the following str value:

font-weight: 700;
font-family: 'nta', 'Arial', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;

@media print {
  font-family: sans-serif
}

@media only screen and (min-width: 320px) {
  font-size: 18px;
  line-height: 20px;
}

@media only screen and (min-width: 641px) {
  font-size: 24px;
  line-height: 30px;
}

padding-top: 30px;
padding-right: 25px;
padding-bottom: 20px;
padding-left: 15px;

@media only screen and (min-width: 641px) {
  padding-top: 50px;
  padding-right: 40px;
  padding-bottom: 30px;
  padding-left: 25px;
}

margin: 15px