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

hmrc-frontend

v6.39.0

Published

Design patterns for HMRC frontends

Downloads

48,087

Readme

HMRC Frontend

HMRC Frontend contains the code and documentation for patterns specifically designed for HMRC.

GOV.UK Frontend and the GOV.UK Design System contains the code and documentation for design patterns designed to be used by all government departments.

The two sets of code and documentation are separate but used together.

See HMRC Design Patterns for examples of what the design patterns look like and guidance on how to use them in your service.

Quick Start

Requirements

To install more than one version of Node.js, it may be easier to use a node version manager like nvm or n.

How to install

Clone this repository and install its dependencies.

git clone https://github.com/hmrc/hmrc-frontend.git
cd hmrc-frontend
npm install

How to run

  1. Run npm start
  2. Components are available at http://localhost:3000

Using HMRC Frontend locally

Prototypes

npm install hmrc-frontend

Frontend microservices

For use in frontend microservices running on MDTP, please refer to the README in play-frontend-hmrc.

Explanations

Relative @imports and SASS load paths

Our SASS needs to be compilable in three different contexts:

  1. Within the library itself
  2. Within the node_modules folder of prototypes
  3. Within the folder that webjar assets get extracted to in tax services

SASS load paths are folders that SASS will look in for paths you try to @import SASS files from.

How will @import "../../govuk-frontend"; be resolved in these different contexts?

1. Within the library itself during release and local development

The govuk-frontend dependency will be located in the node_modules directory, so it will not exist at ../../govuk-frontend relative to the SASS files in the src/ directory.

However, because we are doing the compilation ourselves, we can modify the SASS load paths - and so we add node_modules folder (where govuk-frontend will be located) via the "includePaths" option of the SASS library we use.

Then, to resolve @import "../../govuk-frontend";, the SASS compiler will first try to find the file at ../../govuk-frontend relative to the file doing the @import. Which won't be found, so then it will discard the relative parts of the path and try to locate it within any of the folders in the configured SASS load paths - which in this case will just be node_modules, and it will be found in node_modules/govuk-frontend.

Which means you could (though only theoretically, as you will be prevented by automated tests) have any relative path prefix at the start of your @imports as long as the rest of the path is something that exists in the node_modules folder.

2. Within the node_modules folder of prototypes

In this case, we aren't able to add to the SASS load paths, so the relative parts at the start of our @import paths matter.

So src/all-govuk-and-hmrc.scss will be installed to node_modules/hmrc-frontend/hmrc/all-govuk-and-hmrc.scss and @imports of external dependencies from this file will need to traverse up two levels to get to the node_modules folder, so @import "../../govuk-frontend"; will resolve to node_modules/govuk-frontend.

We have an automated test to ensure that we don't use an invalid relative path that would break this use case.

3. Within the folder that webjar assets get extracted to in tax services

The sbt-sassify plugin used by most tax services to compile SASS also has no way to add to the SASS load paths. Luckily, the subfolder structure that assets from webjars are extracted into matches what you'd find in node_modules, so the relative import paths that work for node_modules for prototypes will also work here (so long as you've got the govuk-frontend webjar in your project.)

How to contribute

Design patterns

If you need a pattern that does not appear in the HMRC Design Patterns, you can contribute a new one.

Features and issues

If you would like to propose a feature or raise an issue with HMRC Frontend, create an issue.

You can also create a pull request to contribute to HMRC Frontend. See our contribution process and guidelines for HMRC Frontend before you create a pull request.

License

This code is open source software licensed under the Apache 2.0 License.