This style guide assumes you're using Less for preprocessing CSS. For high level components, it's assumed that your application is built with React and compiled using Webpack.
$ npm install --save-dev seek-style-guideIf you're creating a new project from scratch, consider using sku, our officially supported front-end development toolkit. It's specially designed to get your project up and running as fast as possible, while simplifying the process of keeping your development environment up to date.
First, decorate your server Webpack config:
const decorateServerConfig = require('seek-style-guide/webpack').decorateServerConfig;
module.exports = decorateServerConfig({
// Webpack config...
});Then, decorate your client Webpack config:
const decorateClientConfig = require('seek-style-guide/webpack').decorateClientConfig;
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const extractCss = new ExtractTextPlugin('style.css');
const config = {
// Webpack config...
};
module.exports = decorateClientConfig(config, {
// Ensure you pass your ExtractTextPlugin instance to the decorator, if required:
extractTextPlugin: extractCss
});Please note that, if your Webpack loaders aren't scoped to your local project files via the "include" option, the decorator will throw an error.
While webpack has first class support, this style guide will work with any bundler that can be configured to support the following:
- Overloading of import statements to allow dependencies between different asset types.
- JavaScript compilation with support for ES2015, JSX, class properties and object rest/spread.
- Compilation of Less and CSS Modules, with the ability to generate static CSS files.
- Handling of web fonts, with the ability to base64 encode them into CSS.
- Importing raw file contents from SVGs.
If you've successully created another bundler integration along the lines of seek-style-guide-webpack, please open a pull request!
When importing from the style guide, while it might appear that you are only importing what's needed, it's highly likely that you're actually including the entire style guide in your application bundle (even when using tree shaking in webpack 2).
In order to help you optimise your bundle size, all components can be imported directly from their individual source files. For example, take a look at standard import statement:
import { Header, Footer } from 'seek-style-guide/react';This can also be expressed as separate, file-level imports:
import Header from 'seek-style-guide/react/Header/Header.js';
import Footer from 'seek-style-guide/react/Footer/Footer.js';Rather than transforming this manually, it's recommended that you leverage Babel instead, with babel-plugin-transform-imports configured to match the pattern used in this style guide.
To set this up, assuming you're already using Babel, first install the plugin:
npm install --save-dev babel-plugin-transform-importsThen, include the following in your Babel config:
"plugins": [
["babel-plugin-transform-imports", {
"seek-style-guide/react": {
"transform": "seek-style-guide/react/${member}/${member}",
"preventFullImport": true
}
}]
]Wrap your app with the StyleGuideProvider component to use any of the style guide components. For example:
render() {
const locale = 'AU';
const title = '...';
const meta = [
{ name: 'description', content: '...' }
];
const link = [
{ rel: 'canonical', href: 'https://www.seek.com.au/' }
];
return (
<StyleGuideProvider locale={locale} title={title} meta={meta} link={link}>
...
</StyleGuideProvider>
);
}StyleGuideProvider's props are used to set the page head properties using Helmet.
The standard header and footer are provided as React components:
import { Header, Footer } from 'seek-style-guide/react';The <Header> component accepts the following props:
- locale:
'AU'(default) or'NZ' - authenticated:
null/undefined(default, authentication pending),trueorfalse - userName: User's display name, when authenticated
- activeTab: Text of the active tab, e.g.
'Job Search' - divider:
true(default, renders a blue divider below the navigation tabs) orfalse - linkRenderer: Function to allow custom rendering of links. The default implementation simply renders a standard link, spreading all props:
props => <a {...props} />
The <Footer> component accepts the following props:
- locale: See above.
- linkRenderer: See above.
In any style sheet that depends on the style guide, first import the Less theme by reference.
@import (reference) "~seek-style-guide/theme";As much as possible, colors should be directly imported from the style guide. The following colors are provided:
// Brand colors
@sk-blue
@sk-pink
@sk-green
@sk-purple
// Partner brand colors
@sk-business
@sk-volunteer
@sk-learning-light
@sk-learning-medium
@sk-learning-dark
// Grays
@sk-black
@sk-charcoal
@sk-mid-gray-dark
@sk-mid-gray-medium
@sk-mid-gray
@sk-mid-gray-light
@sk-gray-light
@sk-gray-lightest
@sk-off-white
@sk-white
// Element colors
@sk-link
@sk-link-visited
@sk-focus
@sk-highlight
@sk-green-light
@sk-yellow
@sk-yellow-light
@sk-footer
@sk-background
@sk-yellowTo ensure correct relative elements stacking order z-index variables are provided:
@z-index-header-overlay
@z-index-header
@z-index-page-overlay
@z-index-inline-overlay
@z-index-negativeThe contrast ratio of certain foreground/background color combinations don't meet the AA accessibility standards that we aim for. As a result, a suite of accessible variants have been provided:
@sk-mid-gray-on-white
@sk-pink-on-gray-light
@sk-learning-dark-on-gray-light
@sk-business-on-gray-lightPlease note that this list is not exhaustive, so contributions are encouraged. To validate color combinations, we recommend the use of the web-based tool Accessible Colors by @moroshko.
All type should use the standard typographic mixins, e.g.
.element {
.heroText();
.headlineText();
.headingText();
.subheadingText();
.superstandardText();
.standardText();
.substandardText();
.smallText();
.touchableText();
}Under the hood, these mixins leverage basekick to ensure that typography sits correctly on the baseline grid.
The style guide exposes one responsive breakpoint:
@responsive-breakpoint: 740px;Our components use this internally, and can be expected to change presentation past this breakpoint if there is an advantage in doing so (for example the Columns component only presents as columns past this breakpoint).
We also expose responsive type mixins that may change scale and row span based on this breakpoint:
.element {
.heroTextResponsive();
.headlineTextResponsive();
.headingTextResponsive();
.subheadingTextResponsive();
.superstandardTextResponsive();
.standardTextResponsive();
.substandardTextResponsive();
.smallTextResponsive();
}In particular standard text is larger on a smaller screen using .standardTextResponsive
In order to ensure elements correctly follow the grid, element sizing should always be controlled by the following variables:
@grid-row-height
@grid-gutter-width
@grid-column-width
@grid-container-widthWhen defining a document content container:
.element {
max-width: @grid-container-width;
}When defining heights and vertical padding/margins:
.element {
height: (@grid-row-height * 3);
padding-bottom: @grid-row-height;
margin-bottom: @grid-row-height;
}When defining widths and horizontal padding/margins:
.element {
width: (@grid-column-width * 3);
padding-right: @grid-gutter-width;
margin-right: @grid-column-width;
}It's important to note that any additions to these values (e.g. borders) will need to be negated to maintain rhythm, e.g.
.element {
@border-width: 1px;
border-bottom: @border-width solid @sk-charcoal;
padding-bottom: @grid-row-height - @border-width;
}A growing suite of React components are provided in this style guide. They can be imported like so:
import { HeartIcon, StarIcon } from 'seek-style-guide/react';These components can be viewed online in the following categories:
If you're maintaining or updating a non-React app, a standalone JS + CSS package is provided when installing from npm. The bundled JavaScript is provided as a UMD package, providing a global SeekHeaderFooter object as a fallback for older apps without a proper module system.
First, include the following files in your app:
seek-style-guide/dist/header-footer/styles.cssseek-style-guide/dist/header-footer/client.js
Then, add placeholder elements to your page:
<div id="header"></div><div id="footer"></div>
When the document is ready, render the header:
var header = SeekHeaderFooter.renderHeader(document.getElementById('header'), {
...initialProps
});
// Update props later, if needed:
header.updateProps({
...newProps
});Finally, render the footer following a similar pattern:
var footer = SeekHeaderFooter.renderFooter(document.getElementById('footer'), {
...initialProps
});
// Update props later, if needed:
footer.updateProps({
...newProps
});If you need to create React elements (e.g. when providing a linkRenderer function), the standalone bundle also exports React's createElement function so you don't need to install React separately to gain access to it:
var link = SeekHeaderFooter.createElement('a', { href: '/jobs' }, 'Jobs');For more detail on accepted props, read the React documentation for applying the standard header and footer.
Refer to CONTRIBUTING.md.
MIT.