Style Guide
A style guide/pattern library containing all the basic elements we currently implement on our site. Many questions will be answered here, so give it a read and all shall become clear. Enjoy! If something isn't here let me know and I'll just have to add it in I suppose.
Typograghy & Logos
Logo usage
Logos are added to the page using a class. This adds a base64 version of our SVG logo. Size must be explicly stated when adding to an empty element
.icon-b2g-logo-purple-nostrap
.icon-b2g-logo-purple-strap
.icon-b2g-logo-white-nostrap
.icon-b2g-logo-white-strap
.icon-c2g-logo-purple-nostrap
.icon-c2g-logo-purple-strap
.icon-c2g-logo-white-nostrap
.icon-c2g-logo-white-strap
Typograghy
Fonts are controlled via a base size of 16px and are then resized with rems. Heading fonts have a negative letter spacing of -0.05rem and are to be used sparingly. note: Raleway shows numbers badly.
https://www.fontsquirrel.com/fonts/raleway
$heading-font-family
H1 |
Main Heading | 2.5rem |
H2 |
Sub Heading | 2.25rem |
H3 |
Section Heading | 2rem |
H4 |
Smaller Section heading | 1.625rem |
H5 |
Notes Heading | 1.375rem |
H6 |
1.25rem |
https://www.myfonts.com/fonts/linotype/avenir/
$base-font-family
Smallerest | 8px | $smallerest |
smallest | 10px | $smallest |
smaller | 12px | $smaller |
small | 14px | $small |
smallish | 15px | $smallish |
normal | 16px | $normal |
big | 18px | $big |
bigger | 20px | $bigger |
biggest | 22px | $biggest |
biggerest | 24px | $biggerest |
Brand Colours
$brand-purple-dark |
|
$brand-purple |
|
$brand-light-purple |
|
$brand-lightest-purple |
|
$brand-orange |
|
$brand-green |
|
$brand-teal |
|
$brand-blue |
|
$brand-red |
|
$brand-dark-grey |
|
$brand-mid-grey |
|
$brand-light-grey |
Icons
Using grunticon, base64 background images are created from SVGs, and automatically added to assests/css/icons.data.svg.css. they are then accessible via the .icons-{filename} selector. It is important to set width and height to the element.
If you require access to the SVG in the document please add data-grunticon-embed:
This will automatically insert the SVG (not the backgorund image) and make the class .st0 availble for css styles.
grunticon also provides a script, which handles PNG fallbacks which are automatically generated
Why?
There are 100+ icons, which obviously adds many extra requests - grunticon means you can create and edit SVGs as normal - without having to edit spritesheets, create fallbacks and handle imageswapping for unsupported browsers whilst still having the benefit of making only one server request!
Grid System
We use the flexboxgrid.com grid system, placed on top of the bootstrap (4.0) flexbox grid. Both follow the same syntax. It is essential to add the .row element for flexbox to be activated
Alignment
Add classes to align elements to the start or end of a row as well as the top, bottom, or center of a column
.start-
<div class="row start-xs">
<div class="col-xs-6">
<div class="box">
start
</div>
</div>
</div>
.center-
<div class="row center-xs">
<div class="col-xs-6">
<div class="box">
start
</div>
</div>
</div>
.end-
<div class="row end-xs">
<div class="col-xs-6">
<div class="box">
end
</div>
</div>
</div>
Here is an example of using the modifiers in conjunction to acheive different alignment at different viewport sizes.
<div class="row center-xs end-sm start-lg">
<div class="col-xs-6">
<div class="box">
All together now
</div>
</div>
</div>
.top-
<div class="row top-xs">
<div class="col-xs-6">
<div class="box">
top
</div>
</div>
</div>
.middle-
<div class="row middle-xs">
<div class="col-xs-6">
<div class="box">
center
</div>
</div>
</div>
.bottom-
<div class="row bottom-xs">
<div class="col-xs-6">
<div class="box">
bottom
</div>
</div>
</div>
Video
We use the LazyYT.js script to embed youtube videos either in page or via a modal. Script will grab the thumbnail, title and video time to present in page. On click thumbnail is swapped for real video.
n.b. script has been edited - so don't update it!
In Page Video
<div class="embed-responsive" data-youtube-id="_oEA18Y8gM0"></div>
In Page Video - Small
<div class="embed-responsive" data-youtube-id="_oEA18Y8gM0" data-size="small"></div>
Video via modal (show thumbnail)
<div class="embed-responsive" data-youtube-id="_oEA18Y8gM0" data-modal="true"></div>
Video via modal (show thumbnail) - Small
<div class="embed-responsive" data-youtube-id="_oEA18Y8gM0" data-modal="true" data-size="small"></div>
Video via modal (anchor link)
<div class="embed-responsive" data-youtube-id="_oEA18Y8gM0" data-modaltext="Watch Video"></div>
Offers
We currently undertake 2 types of offers, both of which we need to add a slider, offer icon and snip to the site.
1) Individual products / ranges / collections
Offers are added via Product Admin. You search existing offers or create a new one on. essential fields when creating an offer:Title | Shown on the buy page |
Internal Name | how the offer is displayed in product admin |
Swatch Image | This is the offer icon, does not need html, does need extension. If left blank will be offer default (take from % off product) |
images prefix | if swatch image left blank, you can prefix the offer icon i.e. 'shnigles-' - offer name will be shingles-50off.png |
type | ignore |
country | should be ireland and united kingdom |
visibilty | Sets the visibilty of the offer, should be 'test' while creating the offer, 'all' when offer goes live |
lining | only applicaable for blackout lining offers |
position | location of the offer icon on each product |
start / end | as expected |
Products are selected via the 'Offer Items' tab, however this is best left to Max
Accordian
Our Accordian is based on the class Bootstrap version. Key notes where we differentiate:
- Panel Heading does not need the H4 tag
- Direction arrows have been added and are now automatic
- you MUST wrap content in a span. Otherwise Jquery won't take into account the padding of the panel-collapse element and the animation will jutter
Carousel
Carousel by owlcarousel. No changes made. This component is used on the homepages, the trust widget and the buy page product slider. Style can be esily overriden with a new ID, initiated via JS and then styled
Image 123
Placeholder text 123
Image 124
Placeholder text 124
Image 125
Placeholder text 125
Image 126
Placeholder text 126
Image 127
Placeholder text 127
HTML
Image
Placeholder text
Jquery
function mainCarousel() {
'use strict';
$('#owl-example').owlCarousel({
autoPlay: false,
navigation: true,
pagination: false,
singleItem: true,
transitionStyle: 'fade',
navigationText: [' ', ' ']
});
}
Grunt Workflow
Install
Grunt and Grunt plugins are installed and managed via npm, the node.js package manager. Node.js install package can be downloaded from the Node.js website.
Once node.js has been installed, you can check it is working correctly by asking node what version it is running:
node -v
Once node.js is installed, to get grunt.js on your Mac you can run in the terminal:
sudo npm install -g grunt-cli
Check the installation and version:
grunt --version
Initialise
To initialise Grunt, navigate to the necessary folder using terminal and run the command:
grunt serve
Grunt serve overview
The grunt file is set up to watch website files and automatically do the following when any changes are made and grunt is initialised.
- Check JS - Make sure js code styles are up to par and there are no obvious mistakes.
- Inject Bower - Inject Bower components into the HTML file
- Process SASS/SCSS - Converts SASS/SCSS to CSS.
- Prefix CSS - Adds vendor prefixes for browsers up to 2 versions behind.
- BrowserSync - Gives URL for synchronised browser testing.
- Watch - Watches files for changes. See watch overview below.
Adding external libraries
Bower manages all the frameworks, libraries, assets, and utilities on the website and keep them up-to-date. You can search for packages on Bower and install using the following replacing [package] with the package name:
bower install [package]
Build
To build the site to deploy, navigate to the necessary folder using terminal and run the command:
grunt build
Grunt build overview
The grunt file is set up to go through a more rigorous procedure upon build following the process below.
- Clean - Cleans out /dist/ folder ready for newly built files.
- Prepare Minify - Reads HTML for usemin blocks to enable smart builds that automatically concat, minify and revision files. Creates configurations in memory so additional tasks can operate on them.
- Clean JS - Make sure js code styles are up to par and there are no obvious mistakes.
- Process SASS/SCSS - Converts SASS/SCSS to CSS.
- Prefix CSS - Adds vendor prefixes for browsers up to 2 versions behind.
- Concatenate files - Join multiple JS/CSS files together into 1.
- Uglify - Process JS files to compress variable and function names.
- Modernizr - Include Modernizr
- Minify JSON - Minify JSON files
- Add File Revisions - Adds file revision to image filename to stop caching issues.
- Minify - Commits configurations in memory.
- Unused images - Outputs a list of images not used in HTML, CSS & JS files to: unused-images.txt
- Check pages - Checks built files for broken links, compression, response times and others.
- Watch - Watches files for changes. See watch overview below.
Grunt watch overview
Grunt watches website files and automatically does the following when any changes are made and grunt is watching.
- Bower - The bower.json file governs all js packages in the project and keeps packages up-to-date.
- ESLint - Make sure js code styles are up to par and there are no obvious mistakes.
- SASS/SCSS - CSS preprocessor allowing you to use SASS/SCSS which outputs as CSS.
- svgmin - Minifies SVG Files in Icons folder.
- GruntIcon - Creates PNG backups for SVG files in Icons folder and CSS file to load in what works.
- imagemin - Minifies all images in project