dp-design-system
is the Digital Publishing (DP) build of the ONS Design System.
dp-design-system allows us to use the modules from the ONS design system that are pertinent to the ONS website, in tandem with any patterns or styles that are DP-specific. An example of this would be the cookies banner and its JS interactions, which the ONS website handles differently to the way the design system does.
If you work across multiple Node.js projects there's a good chance they require different Node.js and npm versions.
To enable this we use nvm (Node Version Manager) to switch between versions easily.
Note brew is not supported as an installation option
- Clone this repo in the root of your user profile
cd ~/
from anywhere thengit clone https://github.com/nvm-sh/nvm.git .nvm
cd ~/.nvm
and check out the latest version with e.g.git checkout v0.39.7
- Activate
nvm
by sourcing it from your shell:. ./nvm.sh
Add these lines to your ~/.bashrc
, ~/.profile
, or ~/.zshrc
file to have it automatically sourced upon login:
(you may have to add to more than one of the above files)
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
- Run nvm install in the project directory (this will use .nvmrc)
nvm install
- Install Node (version denoted in
.nvmrc
) and NPM. - Run
npm install
from the root of the repo you've cloned onto your machine.
- Make sure you are using the correct version of node and npm
nvm use
- Build the CSS and JS, and start the local web server with
npm run dev
- Once built, you can find assets stored on the web server, default location is
localhost:9002/dist/assets/
When PRs are merged into main
, compiled assets are made available on the ONS CDN. Versioning is done based on the seven-character commit hash. The following files are made available via the CDN:
- Module JS:
https://cdn.ons.gov.uk/dp-design-system/{COMMIT_HASH}/js/main.js
- ES5 JS (for older browsers, targets IE11):
https://cdn.ons.gov.uk/dp-design-system/{COMMIT_HASH}/js/main.es5.js
- CSS:
https://cdn.ons.gov.uk/dp-design-system/{COMMIT_HASH}/css/main.css
- Favicons:
https://cdn.ons.gov.uk/dp-design-system/{COMMIT_HASH}/favicons
- Fonts:
https://cdn.ons.gov.uk/dp-design-system/{COMMIT_HASH}/fonts
which installs:
Locally served on port 9002 .sass-lint
This app lints using eslint with Airbnb base configuration. See .eslintrc.json
for settings.
npm run lint
Some linting issues can be fixed automatically. To use this functionality, pass the file you wish to fix at the end of the command:
npm run lint:fix path/to/js/file/to/fix
See CONTRIBUTING for details.
Copyright © 2023, Office for National Statistics (https://www.ons.gov.uk)
Released under MIT license, see LICENSE for details.