Front end pattern library for Department of International Trade
The primary goal of the Trade Elements project it to provide front-end resources for developers creating web sites and services for DIT in a GDS style. The toolkit consists of an NPM package and a pattern library available to view online
The Frontend toolkit currently
the npm package has a 'dist' folder containing pre-processed files. The 'dist' folder contains:
File/Folder | Description |
---|---|
css | Compiled CSS for users who do not want to use the sass styles. Also contains compiled css used by base layouts |
images | Image assets typically references from style |
index.js | A bundle of helper functions for javascript, some functions are for use in the browser, others for the server or both. Include as a standard npm module, e.g. const guid = require('trade-elements').guid |
javascripts | A folder to add to your static assets mappings in node to host the javascript bundle to add behaviour to the page. This folder contains trade-elements-components.js, this is the code that enhances parts of a page, such as readio buttons. The cookie and component scripts in this folder are called by the base layout by default. |
nunjucks/filters | Helpful filters for nunjucks, such as date formatting and console logging |
nunjucks/layouts | Base page layouts for pages to provide a consistant layout, header and footer. |
nunjucks/macros/trade.html | A collection of macros for nunjucks for generating layout. Using the macros produces consistent markup designed to be used in conjuction with the sass styles. |
sass | The sass folder contains all the sass source for styling a site to be consistent with .gov.uk. The majority of projects can simply include 'trade-elements.scss' which in turn will pull in all the required files. The sass files are a combination of the gov.uk toolkit, gov.uk elements and the Department of Trade styles. The files are combined to make it easier for projects to pull all these styles in without having to learn complex sass configurations. |
The Online Gallery demonstrates the layouts, components and styles that make up the Trade Elements toolkit. The gallery includes:
A tutorial is in the process of being written, for now though take a look at the source for the gallery here, this project can show you how to:
JS for components are 'self registering'. The control searches for all elements that have a given class name and progressively enhance the page. Parameters are specified in html attributes
You download and install this application as normal for node by checking the code out, running yarn install and then use the following yarn scripts to do something, enter yarn scriptname
Use docker and docker compose to start or develop components without having to install NodeJS. Simply docker-compose up and you can connect to the sever via http://localhost:3050 for normal usage or http://localhost:3051 for a version in which css changes instantly show in the browser