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

digitalmarketplace-frontend-toolkit

v36.1.3

Published

A toolkit for design patterns used across Digital Marketplace projects

Downloads

7

Readme

Digital Marketplace frontend toolkit

A toolkit for design patterns used across Digital Marketplace projects.

Using the patterns in an app

Each pattern in ./toolkit/ provides:

  • A Jinja template
  • SASS
  • Javascript (if needed)
  • Images (if needed)

Dependency management and integrating these files into a build pipeline are the concern of each project that uses them. This is already set up for all Digital Marketplace frontend apps.

Viewing the documentation locally

The documentation is generated from the contents of this repository.

Setup

Create a virtual environment in the checked-out repository folder

make virtualenv

Activate the virtual environment

source ./venv/bin/activate

Build

  • In one shell run make serve_pages
  • In another shell run make watch_for_changes
  • Visit http://localhost:8000

Working on the patterns

You can preview changes you make to the patterns by building the documentation locally. There are 3 to 5 parts to a pattern:

Example data

Usage examples for each pattern are defined in the ./pages_builder/pages folder. They are YAML files which show what parameters you can pass to a template. The examples in the documentation are generated from these files.

Grids in example pages

Examples can use the grids (see grids example) by setting a grid property in this file.

If all the examples in your page sit in the same column, set the grid class you need with the page-level properties (ie on the textbox example page).

If any of your examples need their own column, set the grid class you need with the example-level properties (ie on the temporary message example page).

If you don't need a grid column, don't set any grid properties in your file.

Template

Templates are found in the ./toolkit/templates folder. They are Jinja templates with an .html extension. Their name corresponds to the name of the example. They get rendered once for each of the provided examples, using the provided examples' data.

SASS

Create your SASS file in ./toolkit/templates. Import it into ./pages_builder/assets/scss/index.scss.

The ./toolkit/scss, ./pages_builder/govuk_frontend_toolkit/stylesheets and ./pages_builder/assets/scss folders are included in the load path so you can import any files from them.

When writing SASS for this toolkit, follow the styleguide.

Javascript (if needed)

Javascript modules should be initialised by calling them from ./pages_builder/assets/javascripts/onready.js.

jQuery is available for you to use but only as last resort.

Javascript should be tested with Jasmine (requires node and NPM).

To run the tests in ./spec:

npm install
npm test

Images (if needed)

Images can be added to ./toolkit/images

Use the file-url mixin to reference them in your stylesheet. It will resolve paths, eg:

background: file-url('your-image.png');

Development

A local checkout of the frontend-toolkit repo can be shared with locally-running services (i.e. frontend applications) as follows, assuming you have a system-wide install of npm available:

  • from this repo, run npm link
  • from each app, run npm link digitalmarketplace-frontend-toolkit

Your frontend apps will then be using your local copy of the frontend-toolkit patterns rather than the version specified in their package.json - for example, whenever you:

  • rebuild the app's toolkit directory by running make frontend-build; or
  • run npm run frontend-build:watch to automatically rebuild the frontend-toolkit content whenever a pattern file changes.

Versioning

Releases of this project follow semantic versioning, ie

Given a version number MAJOR.MINOR.PATCH, increment the:

  • MAJOR version when you make incompatible API changes,
  • MINOR version when you add functionality in a backwards-compatible manner, and
  • PATCH version when you make backwards-compatible bug fixes.

To make a new version:

  • run npm version to update the version number;
  • (note that npm has been configured not to create a new tag when you run this command - see .npmrc)
  • if you are making a major change, also update the change log;
  • commit package.json and CHANGELOG.md if appropriate - for a small PR, this could be in the same commit as other changes you are making; for a larger PR you might want a separate commit with a message that summarises the entire PR.

When the pull request is merged Github Actions will be run to tag and publish the new version.

Licence

Unless stated otherwise, the codebase is released under the MIT License. This covers both the codebase and any sample code in the documentation.

The documentation is © Crown copyright and available under the terms of the Open Government 3.0 licence.