Design tokens en Web Components voor RegelRecht.
- Add
.npmrcto your project for GitHub Packages authentication:
@minbzk:registry=https://npm.pkg.github.com
- Authenticate with GitHub Packages (one-time setup):
npm login --registry=https://npm.pkg.github.com
# Use your GitHub username and a personal access token with `read:packages` scope- Install the package:
npm install @minbzk/storybookImportant: You must import the CSS tokens for proper styling.
// Import CSS tokens (required for styling)
import '@minbzk/storybook/css';
// Import all components
import '@minbzk/storybook';
// Or import specific components
import { RRButton, RRCheckbox, RRSwitch } from '@minbzk/storybook';<!-- Use in HTML -->
<rr-button variant="accent-filled">Click me</rr-button>
<rr-checkbox label="Accept terms"></rr-checkbox>
<rr-switch label="Enable notifications"></rr-switch>View the live component documentation: https://minbzk.github.io/storybook/
src/assets/styles/settings.css (CSS custom properties)
↓
dist/css/tokens.css
↓
Web Components (Lit)
# Dependencies installeren
npm install
# Tokens bouwen
npm run build:tokens
# Storybook starten
npm run storybook
# Open http://localhost:6006 voor de component documentatie<link rel="stylesheet" href="dist/css/tokens.css" /><script type="module">
import './src/components/actions/button/rr-button.ts';
</script><rr-button variant="primary">Primary Action</rr-button>
<rr-button variant="secondary">Secondary Action</rr-button>
<rr-button size="sm">Small Button</rr-button>| Attribuut | Type | Default | Beschrijving |
|---|---|---|---|
variant |
string | neutral-tinted |
primary, secondary, destructive, accent-filled, accent-outlined, accent-transparent, neutral-tinted, neutral-transparent, danger-tinted |
size |
string | md |
xs, sm, md |
disabled |
boolean | false |
Disabled state |
type |
string | button |
button, submit, reset |
full-width |
boolean | false |
Stretches button to fill container width |
is-expandable |
boolean | false |
Adds an icon indicating the button opens a menu or popover |
popovertarget |
string | '' |
ID of the popover element to target |
Tokens zijn georganiseerd in drie lagen:
- Primitives - Basis waarden (kleuren, spacing, typography)
- Semantics - Betekenisvolle tokens (buttons, controls, views)
- Components - Component-specifieke tokens
/* Primitives */
--primitives-color-accent-100: #154273;
--primitives-space-16: 16px;
/* Semantics */
--semantics-buttons-accent-filled-background-color: #154273;
--semantics-controls-md-min-size: 44px;
/* Components */
--components-button-md-font: 600 18px/1.125 RijksSansVF, system-ui;- Bewerk
src/assets/styles/settings.css - Run
npm run build:tokens
- Maak een directory in
src/components/{category}/{component-name}/ - Maak de volgende bestanden aan:
rr-{component-name}.ts— component class (extendsLitElement)rr-{component-name}.styles.ts— component stylesrr-{component-name}.template.ts— render templaterr-{component-name}.stories.ts— Storybook storiesrr-{component-name}.test.ts— unit tests
- Exporteer de component class in
src/index.ts
Zie CLAUDE.md voor conventies en richtlijnen.
EUPL-1.2