This design system is based on the NL Design System architecture.
For more info about the NL Design System and learn about things happening in our open source community, join the #nl-design-system Slack via praatmee.codefor.nl!
✂ In your own repository: remove the "Getting started" section below!
This template contains all relevant linting rules used by the NL Design System repository. It also contains the Storybook setup with two example components and two example general documentation page. Feel free to add or modify those documentation pages and use the example components as an initial template to create your own storybook components.
You need to have the following tools installed to run Storybook locally:
- Git
- Node.js and npm
pnpm,npm install -g pnpm
- Choose a prefix for your organisation. For example: the main NL Design System uses
nl-, The Hague usesdenhaag-, and you can choose something unique for you to use. - Modify
.stylelintrc.jsonby replacing the prefixexamplewith the prefix you have chosen, in the following rules:custom-property-pattern,selector-class-pattern,keyframes-name-pattern,scss/dollar-variable-patternandscss/percent-placeholder-pattern. - Choose and register an npm organisation on npmjs.com, if you haven't already. This is very important to keep your project secure. The core NL Design System uses
@nl-design-system/, and you can choose something for yourself. This prevents others from adding their code to your teams codebase. - Modify all
package.jsonfiles to use your npm organisation scope. Don't forget the locally linked packages underdevDependencies. Find and replace all occurences of@example/in your project with@your-organisation/. Runpnpm installto install each package in under the new organisation directory in eachnode_modules/. - Modify
.npmpackagejsonlintrc.jsonto require your organisation scope in package names, by configuring thevalid-values-name-scopeproperty. - Modify the imports in
/packages/storybook/config/preview.tsxandpackages/web-components-stencil/src/button/index.scssto use your prefix. - Modify
proprietary/design-tokens/style-dictionary.config.jsonto output.yourprefix-themeinstead of.example-theme. - Modify
preview.tsxto useyourprefix-themeinstead ofexample-themeas default theme for Storybook stories.
- Install dependencies:
pnpm install - Run storybook:
npm run storybook
In .storybook/customTheme.js the theme used by NL Design System can be found. By changing those properties one can style the storybook to match ones brand. Checkout https://storybook.js.org/docs/react/configure/theming to learn more about all the possible configurations to brand this storybook.
- In
src/demo-empty-componentan example story of a documentation first (or documentation only) component can be found. - Copy this folder
- Rename to match your component
- The folder
- The
x.stories.mdxtocomponent-name.stories.mdx - The title of the
Metacomponent incomponent-name.stories.mdx
- Add the UX guidelines in
README.md - Optionally add the component specific accessibility or content guidelines in
docs/accessibility-guidelinesordocs/content-guidelines. - Optionally add the Figma component in
component-name.stories.mdxby adding part of the Figma url to the Figma component<Figma title="Link" url="file/..." />
Add global tokens to /brand.css. Add tags to make them appear in the Storybook Design token addon. For example @tokens Colors and @presenter Color. See https://storybook.js.org/addons/@tommyem/storybook-design-token for more details.
In src/demo-link-component an example story and web-component can be found. All steps below are represented in this demo-link.stories.mdx example.
To add a component implementation to storybook, we use the <component-name>-stories.mdx which already contains the documentation pages or create one with placeholder documentation by following step 1-3 from the Adding UX and other documentation without a component implementation chapter.
- Create a component template function that takes variable arguments. If an argument might contain childnodes, use the
sanatizepackage to prevent unsafe content and injections. Place thisTemplatefunction above theMetacomponent - Declare a story for each component variation and bind the template
- Declare the possible inputs, with types and a description in the
argTypesproperty of theMetacomponent instories.mdx. - Add an
Argstablecomponent in yourstories.mdx - Optionally add a different
statusto theMetaparameters. The options and colors can be found instorybook/config/preview.tsx
Things we usually do:
- Generate fine grained personal access token in GitHub, with rights to push npm version commits. Use a name that will be clear when the token expires, for example:
nl-design-system/example GH_TOKEN. Choose "All repositories". For "Resource owner" choose the user or organisation of the repository. For "Repository access" choose "Only select repositories", and select only your repository. Expand "Account permissions", then for "Contents" select "Read and write". - Configure
GH_TOKENin Repository tokens, for use in thepublish-npmGitHub Action. You might notice theGITHUB_TOKENalready exists, but theGITHUB_prefix is used by GitHub itself and the token has read-only rights. - Go to npmjs.com and create an "Granular Access Token". Use a name that serves as hint where to reset the token when it expires, for example:
nl-design-system/example NPM_TOKEN. For "Permissions", allow only "Only select packages and scopes" and choose the scope of your npm packages. Do not store the token anywhere, just copy it to GitHub once. You can always generate new tokens, and they will be protected by multi-factor authentication. - Configure
NPM_TOKENin Repository tokens, for use in thepublish-npmGitHub Action. - Configure GitHub repository settings
- General settings
- Uncheck "Allow merge commits"
- Should already be checked: "Allow squash merging"
- Should already be checked: "Allow rebase merging"
- Check "Allow auto-merge"
- Check "Automatically delete head branches"
- Branches
- Add rule to protect
mainbranch. Branch pattern should be exactlymain.- Check "Require a pull request before merging"
- Check "Require approvals" with at least one approval.
- Check "Require approval of the most recent reviewable push"
- Check "Require status checks to pass before merging"
- Search for the following status checks, and make them required:
- Make
installa required status check. - Make
linta required status check. - Make
testa required status check. - Make
builda required status check. - Optional: configure Chromatic visual regression tests as a required status check.
- Check "Require linear history"
- Add rule to protect
gh-pagesbranch, to prevent someone from deleting it accidentally.
- Add rule to protect
- General settings
- Enable GitHub Pages to host Storybook
- Go to Pages, choose "Deploy from a branch" with
gh-pagesas branch with/ (root)as folder. Ifgh-pagesis not in the list, make sure thepublish-websiteaction succeeds at least once. - In the "Code" tab (the home page of your repository), configure the "About" section. Use "your GitHub Pages website" as "Website" of your repository.
- Configure "nl-design-system" as one of the topics of your repository.
- Go to Pages, choose "Deploy from a branch" with
If you get this the following error, you still need to configure NPM_TOKEN in your repository settings. Use "Generate New Token" in Access Tokens of npmjs.com to create a new automation tokne. Use "New repository secret" in GitHub Repository Secrets to configure it.
Run actions/checkout
Error: Input required and not supplied: token
✂ In your own repository: remove the "Getting started" section above!
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. Read our Code of Conduct if you haven't already.
This project is free and open-source software licensed under the European Union Public License (EUPL) v1.2. Documentation is licensed as Creative Commons Zero 1.0 Universal (CC0-1.0)
For information about proprietary assets in this repository, please carefully read the NOTICE file.