The Co-op Front-end Toolkit contains all the core assets needed to build Co-op-branded digital content.
For more information on all the available styles and modules, please refer to the Co-op Design Manual.
Install the Toolkit by adding it as a NPM package to your project:
npm install coop-frontend-toolkit --save
Simply import the style components you require into your own stylesheet:
/* my_styles.scss */
@import 'node_modules/coop-frontend-toolkit/styles/fonts';
@import 'node_modules/coop-frontend-toolkit/styles/forms';
/* Import some more and add your own styles */
You can override default variables by setting your own. Copy /styles/_variables.scss
into your project and start modifying typographic scale, colours and other settings (you can omit the settings you want to keep as is), then import it before importing toolkit components:
/* _my_variables.scss */
$base-line-height: 1.25;
$body-copy: #bbb;
/* my_styles.scss */
@import 'my_variables';
@import 'node_modules/coop-frontend-toolkit/styles/coop-toolkit';
You will need to copy the static assets found in /static/
to your project as required.
The default path for those assets is set by the variable $base-asset-url
, which you can update as required. For instance, if your assets will be served at /assets/static/
, set $base-asset-url: '/assets/static/';
.
Any asset referenced in your CSS using the asset-url
function will then resolve to the set path automatically:
$base-asset-url: '/assets/static/';
@import 'node_modules/coop-frontend-toolkit/functions';
body {
background-image: asset-url('images/background.jpg');
}
/* Will result in:
body {
background-image: url('/assets/static/images/background.jpg');
}
*/
The base styles provided by the Toolkit changed quite a bit between version 1.1.3 and version >= 2.0.0, unfortunately resulting in a couple of breaking changes. The older versions (up to 1.1.3) are available on the Co-op Digital organisation repository on Github.
If you need to carry on using the older styles, you need to make sure you are using version 1.1.3 of the Toolkit. To do so use the full github URL, including the version number:
{
"name": "project-name",
"dependencies": {
"coop-frontend-toolkit": "coopdigital/coop-frontend-toolkit#1.1.3"
}
}
If you want to update to version 2, you need to be aware of the following breaking changes.
If you have set a custom typographic scale, this will need to be updated to contain all the necessary base
properties. Here are the defaults now set, all of which need to be present in the base
property of your custom scale:
$typographic-scale: (
base: (
body: 16px,
h-mega: 46px,
h1: 30px,
h2: 20px,
h3: 18px,
h4: 18px,
h5: 18px,
h6: 13px,
blockquote: 20px,
lead: 20px,
small: 13px,
base-line-height: 1.7,
base-spacing-unit: 32px,
)
}
Checkboxes and radio buttons followed directly by a <label>
element will need a small tweak to display on the same line. The following CSS handles this realignment:
input[type="checkbox"],
input[type="radio"] {
display: inline-block;
width: auto;
}
input[type="checkbox"] + label,
input[type="radio"] + label {
display: inline-block;
margin: 0 0 0 5px;
vertical-align: middle;
}
The Javascript modules (Tabs and Toggles) have been removed from the Toolkit. If you wish to carry on using those, you will need to copy them over from version 1.1.3 to your project manually, as well as the modules loader.
These assets should be compiled into production-ready versions (minified for CSS/JS, optimised for images), using a task runner or an asset pipeline. An example using Gulp can be found in the Co-op Style Guide repository.
This repository will eventually contains a set of best practices and recommendations for serving fast, optimised web pages to the users.
This Toolkit contains SASS stylesheets, JavaScripts and static assets (fonts and images).
The core styles are available as SASS stylesheets. Most are available as mixins, so you can choose to apply the styles using your own class names. The main stylesheet _coop-toolkit.scss contains the complete collection of available core styles and components and is a good starting point for building your project's final stylesheet.
Some stylesheets may need to contain Internet Explorer-specific styles, to cater for the older versions of IE that still require support. This is done through the use of the ie($version)
mixin, which adds the styles to the outputted CSS if the variable $ie
is lower than the specified version. To make use of those styles, a separate stylesheet should be created for IE browsers, which should be served using conditional comments:
<!-- This stylesheet will be served to IE 9: -->
<!--[if IE 9]><link rel="stylesheet" type="text/css" href="/css/ie-9.css"><![endif]-->
<!-- This stylesheet will be served to all other browsers: -->
<!--[if gt IE 9]><!--><link rel="stylesheet" type="text/css" href="/css/main.css"><!--<![endif]-->
The static assets contain the necessary fonts (Avenir, Coopicons) used by the styles, as well as SVG and PNG versions of the Co-op logo. These should be copied over to your project's assets directory by whichever task runner or asset pipeline you are using.
See CONTRIBUTING.md guidelines.
- Usage guidance
- Remove pixel font sizes
- Colours and layout helpers separation
- Table styles
- Updated README
- Added missing fonts
- Link hover colour
- Tweaked list spacing
- Tiles hover states
- Public release
- Major update to styles
- Removal of JavaScript modules
- Fix tables content copy colour
- Add
nowrap
helper
- Added info banner component
- Travis CI integration
- Customisable typographic scale
- Toggles modules
- More consistent JS test fixtures
- Darker default body text
- Video wrapper module
- Freeform media queries
- Several tweaks and fixes
- 'Public' release
- Added JS modules
- Main logo aligned to the left.
- Updated package links in README.
- Added option to install as NPM package.
- Added minimal scripts.
- Initial release: streamlined version of the Co-op Styleguide styles.