âť— DEPRECATED âť— : Superseded by Storybook. See: https://storybook.bnr.nl
Design System for components used by BNR.nl.
The Design System is created to be used in the following ways:
- Component Library
- Skip to installation if you intend to use it as a Component Library within your own React project. List of components and how to use it is described further below.
- Design Documentation
- The Design Documentation is a website which allows you to preview the components. It also documents the design tokens and reasoning behind the designs.
- CSS + HTML code generator
- Each component also outputs generated CSS and HTML which you can copy and use stand-alone in your own website. This is useful if you can't or don't want to make use of the Component Library. Just keep in mind that each component CSS generated this way works completely stand-alone and includes all the CSS Custom Properties (variables). If you intend to use multiple components then including the CSS Custom Properties only once in your own website is enough. Remember to strip the CSS Custom Properties from subsequent components you add to your website.
Install the Design System
as dependency for your project:
- NPMJS:
npm i @fdmg/bnr-design-system
or
- GitHub Packages:
https://github.com/FDMediagroep/bnr-design-system/packages
TypeDefinitions are available and included.
These are the only steps you need to follow in order to use our components.
- Import our CSS style(s)
- It's possible to omit this and use your own styles instead.
- You can choose to import all styles or styles for each component individually (as shown in the code examples for each component).
- Import and implement our component(s).
- You can choose to import components individually (as shown in the code examples for each component) or import main module. Importing components individually allows you to only bundle the components you use.
Example code are listed below.
Global CSS:
import "@fdmg/bnr-design-system/main.css";
Contains all the CSS for all the components. It's possible to only include the CSS for each component separately. The individual imports are shown in the code examples.
Main component module:
import { ...component... } from "@fdmg/bnr-design-system";
The main entry point exports all the available components. This however means your asset bundle will contain all the components regardless of if you actually make use of it.
The reason we publish the library as CommonJS module is because the Webpack build allows for the generation of separate CSS modules and CommonJS modules for each component. This allows you to only import the JS and CSS for the module that you actually use. When using Rollup to build our library we can get a proper ESM library which is tree-shakeable however the CSS will be compiled into a single file which forces you to load all the styles of all components regardless of which ones you're using.
So as of the time of writing Webpack still offers the best of both worlds with the minor inconvenience of locating the specific module you want to import.
React:
import React from 'react';
All components import React even though the example codes don't reflect that.
WIP
Button
Component CSS:
import "@fdmg/bnr-design-system/components/design-tokens/design-tokens.css";
import "@fdmg/bnr-design-system/components/button/Button.css";
import { Button } from "@fdmg/bnr-design-system/components/button/Button";
function Foo() {
function handleClick() {
console.log('clicked');
}
return (
<Button onClick={handleClick}>Click me!</Button>
);
}
Button CTA (call-to-action)
Component CSS:
import "@fdmg/bnr-design-system/components/design-tokens/design-tokens.css";
import "@fdmg/bnr-design-system/components/button/ButtonCta.css";
import { ButtonCta } from "@fdmg/bnr-design-system/components/button/ButtonCta";
function Foo() {
function handleClick() {
console.log('clicked');
}
return (
<ButtonCta onClick={handleClick}>Click me!</ButtonCta>
);
}
Button Follow
Component CSS:
import "@fdmg/bnr-design-system/components/design-tokens/design-tokens.css";
import "@fdmg/bnr-design-system/components/button/ButtonFollow.css";
import { useState } from 'react';
import { ButtonFollow } from "@fdmg/bnr-design-system/components/button/ButtonFollow";
function Foo() {
const [follow, setFollow] = useState(false);
function handleClick() {
console.log('clicked');
setFollow(!follow);
}
return (
<ButtonFollow selected={follow} onClick={handleClick}>Click me!</ButtonFollow>
);
}
Ghost Button
Component CSS:
import "@fdmg/bnr-design-system/components/design-tokens/design-tokens.css";
import "@fdmg/bnr-design-system/components/button/ButtonGhost.css";
import { ButtonGhost } from "@fdmg/bnr-design-system/components/button/ButtonGhost";
function Foo() {
function handleClick() {
console.log('clicked');
}
return (
<ButtonGhost onClick={handleClick}>Click me!</ButtonGhost>
);
}
Play Button
Component CSS:
import "@fdmg/bnr-design-system/components/design-tokens/design-tokens.css";
import "@fdmg/bnr-design-system/components/button/ButtonPlay.css";
import { ButtonPlay } from "@fdmg/bnr-design-system/components/button/ButtonPlay";
function Foo() {
const [playing, setPlaying] = useState(false);
function togglePlay() {
setPlaying((playState) => !playState);
}
return (
<ButtonPlay onClick={togglePlay} isPlaying={playing}/>
);
}
Checkbox
Component CSS:
import "@fdmg/bnr-design-system/components/design-tokens/design-tokens.css";
import "@fdmg/bnr-design-system/components/input/Checkbox.css";
import { Checkbox } from "@fdmg/bnr-design-system/components/input/Checkbox";
function Foo() {
return (
<Switch
id="idOfCheckbox"
label=`Label of the checkbox`
/>
);
}
Date input
Component CSS:
import "@fdmg/bnr-design-system/components/design-tokens/design-tokens.css";
import "@fdmg/bnr-design-system/components/input/TextInput.css";
import { TextInput } from "@fdmg/bnr-design-system/components/input/TextInput";
function Foo() {
return (
<TextInput id="demoDateInput" type="date" label="Birthday" />
);
}
Email input
Component CSS:
import "@fdmg/bnr-design-system/components/design-tokens/design-tokens.css";
import "@fdmg/bnr-design-system/components/input/TextInput.css";
import { TextInput, Patterns } from "@fdmg/bnr-design-system/components/input/TextInput";
function Foo() {
return (
<TextInput id="demoEmailInput" type="email" label="E-mail" pattern={Patterns.EMAIL} required={true} />
);
}
Mobile input (tel)
Component CSS:
import "@fdmg/bnr-design-system/components/design-tokens/design-tokens.css";
import "@fdmg/bnr-design-system/components/input/TextInput.css";
import { TextInput, Patterns } from "@fdmg/bnr-design-system/components/input/TextInput";
function Foo() {
return (
<TextInput id="demoMobileInput" type="tel" label="E-mail" pattern={Patterns.MOBILE} required={true} />
);
}
Radio
Component CSS:
import "@fdmg/bnr-design-system/components/design-tokens/design-tokens.css";
import "@fdmg/bnr-design-system/components/input/Radio.css";
import { Radio } from "@fdmg/bnr-design-system/components/input/Radio";
function Foo() {
return (
<>
<Radio
id="idOfRadio"
name="groupName"
label=`Label of the radio button`
defaultChecked={true}
/>
<Radio
id="idOfRadio2"
name="groupName"
label=`Label of the radio button`
/>
</>
);
}
Select
Component CSS:
import "@fdmg/bnr-design-system/components/design-tokens/design-tokens.css";
import "@fdmg/bnr-design-system/components/input/Select.css";
import { Select } from "@fdmg/bnr-design-system/components/input/Select";
function Foo() {
return (
<Select
id="demoSelect"
label="Aanhef"
errorMessage="Kies uw aanhef"
required={true}
description="Disabled select field"
>
<option value="">-- aanhef --</option>
<option value="dhr">Dhr.</option>
<option value="mevr">Mevr.</option>
<option value="mw">Mw.</option>
<option value="drs">Drs.</option>
<option value="Prof">Prof.</option>
</Select>
);
}
Switch
Component CSS:
import "@fdmg/bnr-design-system/components/design-tokens/design-tokens.css";
import "@fdmg/bnr-design-system/components/input/Switch.css";
import { Switch } from "@fdmg/bnr-design-system/components/input/Switch";
function Foo() {
return (
<Switch
id="idOfSwitch"
label=`Label of the switch`
/>
);
}
TextArea
Component CSS:
import "@fdmg/bnr-design-system/components/design-tokens/design-tokens.css";
import "@fdmg/bnr-design-system/components/input/TextArea.css";
import { TextArea } from "@fdmg/bnr-design-system/components/input/TextArea";
function Foo() {
return (
<TextArea id="demoTextArea" label="Biography" required={true} />
);
}
Text input
Component CSS:
import "@fdmg/bnr-design-system/components/design-tokens/design-tokens.css";
import "@fdmg/bnr-design-system/components/input/TextInput.css";
import { TextInput } from "@fdmg/bnr-design-system/components/input/TextInput";
function Foo() {
return (
<TextInput id="demoTextInput" label="Name" placeholder="Willem Liu" />
);
}
Horizontal card 1
Component CSS:
import "@fdmg/bnr-design-system/components/design-tokens/design-tokens.css";
import "@fdmg/bnr-design-system/components/card/HorizontalCard1.css";
import { HorizontalCard1 } from "@fdmg/bnr-design-system/components/card/HorizontalCard1";
function Foo() {
return (
<HorizontalCard1 {...cardProps} />
);
}
Vertical card 1
Component CSS:
import "@fdmg/bnr-design-system/components/design-tokens/design-tokens.css";
import "@fdmg/bnr-design-system/components/card/VerticalCard1.css";
import { VerticalCard1 } from "@fdmg/bnr-design-system/components/card/VerticalCard1";
function Foo() {
return (
<VerticalCard1 {...cardProps} />
);
}
Typography
Component CSS:
import "@fdmg/bnr-design-system/components/design-tokens/design-tokens.css";
function Foo() {
return (
<h1 className="heading sans xs">Heading sans xs</h1>
<h1 className="heading sans s">Heading sans s</h1>
<h1 className="heading sans m">Heading sans m</h1>
<h1 className="heading sans l">Heading sans l</h1>
<h1 className="heading sans xl">Heading sans xl</h1>
<h1 className="heading sans xxl">Heading sans xxl</h1>
<h1 className="heading sans bold xs">Heading sans bold xs</h1>
<h1 className="heading sans bold s">Heading sans bold s</h1>
<h1 className="heading sans bold m">Heading sans bold m</h1>
<h1 className="heading sans bold l">Heading sans bold l</h1>
<h1 className="heading sans bold xl">Heading sans bold xl</h1>
<h1 className="heading sans bold xxl">Heading sans bold xxl</h1>
<h1 className="heading sans slim xs">Heading sans slim xs</h1>
<h1 className="heading sans slim s">Heading sans slim s</h1>
<h1 className="heading sans slim m">Heading sans slim m</h1>
<h1 className="heading sans slim l">Heading sans slim l</h1>
<h1 className="heading sans slim xl">Heading sans slim xl</h1>
<h1 className="heading sans slim xxl">Heading sans slim xxl</h1>
<p className="body-text sans xs">body-text sans xs</p>
<p className="body-text sans s">body-text sans s</p>
<p className="body-text sans m">body-text sans m</p>
<p className="body-text sans l">Reserved</p>
<p className="body-text sans xl">Reserved</p>
<p className="body-text sans xxl">Reserved</p>
<p className="body-text sans bold xs">body-text sans bold xs</p>
<p className="body-text sans bold s">body-text sans bold s</p>
<p className="body-text sans bold m">body-text sans bold m</p>
<p className="body-text sans bold l">Reserved</p>
<p className="body-text sans bold xl">Reserved</p>
<p className="body-text sans bold xxl">Reserved</p>
<p className="body-text sans slim xs">body-text sans slim xs</p>
<p className="body-text sans slim s">body-text sans slim s</p>
<p className="body-text sans slim m">body-text sans slim m</p>
<p className="body-text sans slim l">Reserved</p>
<p className="body-text sans slim xl">Reserved</p>
<p className="body-text sans slim xxl">Reserved</p>
);
}