rk-designsystem 1.1.21 → 1.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 danieltunetek
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 danieltunetek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,249 +1,249 @@
1
- # Røde Kors Design System Component Library (Norwegian Red Cross)
2
-
3
- ## Live Storybook URL
4
-
5
- [https://norwegianredcross.github.io/DesignSystem/storybook/](https://norwegianredcross.github.io/DesignSystem/storybook/)
6
-
7
- ## Overview
8
-
9
- Welcome to the Røde Kors Design System! This repository contains a library of reusable UI components built with React, specifically tailored for Norwegian Red Cross digital projects.
10
-
11
- It's developed leveraging the foundational components from Digdir's Designsystemet. This approach ensures a unified and recognizable visual identity across all applications for the Norwegian Red Cross. The system is pre-configured with the official Røde Kors brand theme, which is provided via a dedicated design token package.
12
-
13
- The primary goal is to ensure brand consistency, improve development efficiency, and maintain high accessibility standards across all Røde Kors applications.
14
-
15
- Storybook serves as the interactive documentation and development environment for viewing and testing these components.
16
-
17
- ## Consuming This Library (For Application Developers)
18
-
19
- To use the Røde Kors Design System in your Next.js (or any React) application:
20
-
21
- ### 1. Installation
22
-
23
- Install the necessary npm packages for your project. You will need three packages: the component library itself (`rk-designsystem`), the base styles from Digdir, and the Røde Kors theme package (`rk-design-tokens`).
24
-
25
- ```bash
26
- # npm
27
- npm install rk-designsystem @digdir/designsystemet-css rk-design-tokens
28
-
29
- # yarn
30
- yarn add rk-designsystem @digdir/designsystemet-css rk-design-tokens
31
-
32
- # pnpm
33
- pnpm add rk-designsystem @digdir/designsystemet-css rk-design-tokens
34
- ```
35
-
36
- **Note:** You do not need to install `@digdir/designsystemet-react` separately, as all required components are included within the `rk-designsystem` package.
37
-
38
- ### 2. Including Styles (CSS)
39
-
40
- For the components to be styled correctly, you must import the stylesheets at the highest level of your application, for instance, in your `layout.tsx` (for Next.js App Router) or `_app.tsx` (for Next.js Pages Router).
41
-
42
- **Crucial Order:** It's vital that the base stylesheet (`@digdir/designsystemet-css`) is loaded **before** the Røde Kors theme file (`rk-design-tokens`). This ensures our theme's tokens can correctly override the default values.
43
-
44
- #### Example for Next.js (App Router - `src/app/layout.tsx`):
45
-
46
- ```tsx
47
- import './globals.css'; // Your own global styles (if any)
48
- import '@digdir/designsystemet-css/index.css'; // Base stylesheet for components
49
- import 'rk-design-tokens/design-tokens-build/theme.css'; // Røde Kors theme
50
-
51
- export default function RootLayout({
52
- children,
53
- }: {
54
- children: React.ReactNode;
55
- }) {
56
- return (
57
- <html lang="en">
58
- <body>{children}</body>
59
- </html>
60
- );
61
- }
62
- ```
63
-
64
- #### Example for Next.js (Pages Router - `pages/_app.tsx`):
65
-
66
- ```tsx
67
- import '../styles/globals.css'; // Your own global styles (if any)
68
- import '@digdir/designsystemet-css/index.css'; // Base stylesheet for components
69
- import 'rk-design-tokens/design-tokens-build/theme.css'; // Røde Kors theme
70
- import type { AppProps } from 'next/app';
71
-
72
- function MyApp({ Component, pageProps }: AppProps) {
73
- return <Component {...pageProps} />;
74
- }
75
-
76
- export default MyApp;
77
- ```
78
-
79
- ### 3. Using Components
80
-
81
- Once the stylesheets are included, you can start importing and using components in your project. All components you need are available directly from the `rk-designsystem` package.
82
-
83
- #### 3.1 Import and Use Røde Kors Design System Components
84
-
85
- Import components directly from the `rk-designsystem` package:
86
-
87
- ```tsx
88
- import { Alert } from 'rk-designsystem'; // Import necessary components
89
-
90
- function MyComponent() {
91
- return (
92
- <>
93
- <Alert variant="info" onClose={() => console.log('Alert closed!')}>
94
- This is an informational message from the Red Cross Design System.
95
- </Alert>
96
- </>
97
- );
98
- }
99
- ```
100
-
101
- #### 3.2 Example Usage in a Next.js Page
102
-
103
- Here's an example of how to use multiple Alert components from the Røde Kors Design System within a Next.js page/component:
104
-
105
- ```tsx
106
- 'use client'; // Remember 'use client' for interactive components in App Router
107
-
108
- import React from 'react';
109
- import { Alert } from 'rk-designsystem'; // Import the components you need
110
-
111
- export default function Home() {
112
- return (
113
- <div className="container mx-auto p-8">
114
- <h1 className="text-3xl font-bold mb-8">
115
- Røde Kors Design System Example
116
- </h1>
117
-
118
- <section>
119
- <h2 className="text-2xl font-semibold mb-4">Alerts</h2>
120
- {/* Røde Kors Design System Alerts */}
121
- <Alert variant="success">
122
- <p>
123
- Welcome! This message is styled with the official Røde Kors theme.
124
- </p>
125
- </Alert>
126
-
127
- <Alert variant="warning" className="mt-4">
128
- <p>
129
- Important information using the official Røde Kors theme.
130
- </p>
131
- </Alert>
132
- </section>
133
-
134
- {/* More Røde Kors components can be added here as needed */}
135
- </div>
136
- );
137
- }
138
- ```
139
-
140
- The appearance of all components is fully controlled by the `rk-design-tokens` package. To receive any visual updates to the brand theme (like a new primary color), simply update the package to its latest version:
141
-
142
- ```bash
143
- npm update rk-design-tokens
144
- ```
145
-
146
- ---
147
-
148
- # Contributing to the Component Library
149
-
150
- This guide provides a set of standards and best practices for creating new components. Following these guidelines ensures that our component library remains consistent, accessible, and easy to maintain.
151
-
152
- ## Getting Started (for Contributors)
153
-
154
- Follow these steps to get the local development environment running. All commands should be run from the root of the project.
155
-
156
- ```bash
157
- # 1. Install dependencies
158
- pnpm i
159
-
160
- # 2. Build all packages
161
- pnpm build
162
-
163
- # 3. Start the local Storybook server
164
- pnpm storybook
165
- ```
166
-
167
- ## Core Principles
168
-
169
- Every component we build should adhere to these core principles:
170
-
171
- 1. **Accessibility (A11y):** Components must be usable by everyone, including people with disabilities. This means proper ARIA attributes, keyboard navigation, and semantic HTML.
172
- 2. **Reusability:** Components should be generic enough to be used in multiple contexts without modification.
173
- 3. **Consistency:** Components should follow our established design tokens (colors, spacing, typography) and have a consistent API and structure.
174
- 4. **Documentation:** Every component must be documented in Storybook to make it discoverable and easy for other developers to use.
175
-
176
- ## When to Create a New Component
177
-
178
- Before you start coding, determine what kind of component you need. Most of our needs fall into one of three categories:
179
-
180
- 1. **Wrapped Component (Simple):**
181
- * **What it is:** A component that directly wraps and re-exports a component from `@digdir/designsystemet-react` with no modifications.
182
- * **When to use:** When the base Digdir component meets our needs perfectly, but we want to include it in our own library for a consistent import source.
183
- * **Example:** The `Buttons` component is a perfect example of this.
184
-
185
- 2. **Wrapped Component (with Style Overrides):**
186
- * **What it is:** A wrapped Digdir component where we apply custom CSS to tweak its appearance to better match Røde Kors's specific design language.
187
- * **When to use:** When a Digdir component is functionally correct but needs visual adjustments (e.g., different icons, border radius, padding).
188
- * **Example:** The `Alert` component, which uses `composes` in its CSS to inherit base styles and then applies its own overrides.
189
-
190
- 3. **Custom Component (from Scratch):**
191
- * **What it is:** A completely new component built when no existing Digdir component meets our requirements.
192
- * **When to use:** For unique UI patterns or functionality not covered by the base library.
193
- * **Example:** The `DateInput` component is a custom component with its own state, logic, and styling.
194
-
195
- ## Component File Structure
196
-
197
- To maintain consistency, every new component should follow this file structure. Create a new folder under `src/components/` with the component's `PascalCase` name.
198
-
199
- ```text
200
- src/
201
- └── components/
202
- └── MyNewComponent/
203
- ├── index.ts // Public API - exports the component and props
204
- ├── MyNewComponent.tsx // The React component logic and JSX
205
- ├── MyNewComponent.stories.tsx // Storybook stories for documentation
206
- ├── styles.module.css // Scoped CSS (only for custom components)
207
- └── MyNewComponent.test.tsx // (Optional but Recommended) Unit tests
208
- ```
209
-
210
- ## Coding Guidelines
211
-
212
- ### 1. Component Logic (`MyNewComponent.tsx`)
213
-
214
- * **TypeScript First:** All components must be written in TypeScript. Define a `Props` interface for your component, extending from the base HTML element or Digdir component props if applicable.
215
- * **Forward Refs:** Always use `React.forwardRef` to allow parent components to get a `ref` to the underlying DOM element.
216
- * **Accessibility is Mandatory:**
217
- * Use semantic HTML (`<button>`, `<label>`, `<nav>`).
218
- * Ensure all interactive elements are keyboard-focusable and operable.
219
- * Provide `aria-label` for icon-only buttons or elements where the text label is not visible.
220
- * Use `aria-invalid`, `aria-describedby`, etc., to communicate state to assistive technologies.
221
- * **Controlled vs. Uncontrolled:** If your component has state (like an input), it should support both controlled (`value` + `onChange`) and uncontrolled (`defaultValue`) patterns.
222
- * **Props Naming:** Use `data-*` attributes for styling variants (e.g., `data-size`, `data-color`) to align with the patterns in our existing components.
223
-
224
- ### 2. Styling (`styles.module.css`)
225
-
226
- * **CSS Modules:** For **custom components**, all styles must be placed in a `styles.module.css` file. This scopes class names locally and prevents global style conflicts.
227
- * **Design Tokens:** Always use our design system tokens (`var(--ds-...)`) for colors, spacing, fonts, etc. Do not use hardcoded values (e.g., `#FFF`, `16px`).
228
- * **Overriding Wrapped Components:** For **wrapped components**, use a standard CSS file. Use the `@layer` and `composes` keywords to extend base Digdir styles without increasing CSS specificity unnecessarily.
229
-
230
- ### 3. Documentation (`MyNewComponent.stories.tsx`)
231
-
232
- Your Storybook file is the official documentation. It must be clear and comprehensive.
233
-
234
- * **`meta` Object:** Define the component's title, component reference, and `tags: ['autodocs']` to enable automatic documentation.
235
- * **`argTypes`:** Document every single prop. Provide a `description`, `control` type (e.g., `select`, `boolean`, `text`), and `options` if applicable. This powers the interactive controls in Storybook.
236
- * **Create Multiple Stories:** Create a separate story for each key state and variant of your component (e.g., `Default`, `Disabled`, `WithError`, `WithIcon`).
237
-
238
- ## Contribution Process
239
-
240
- ### 1. Create a Pull Request (PR)
241
-
242
- 1. **Create a Branch:** Pull the latest changes from the `main` branch and create a new feature branch: `git checkout -b feat/my-new-component`.
243
-
244
- 2. **Open a Draft PR:** As soon as you start, open a **draft** pull request on GitHub. This prevents duplicate work and allows others to see what you're working on.
245
-
246
- 3. **Commit Your Changes:** As you work, make small, logical commits.
247
-
248
- 4. **Ready for Review:** When development is complete and all automated checks are passing, mark the PR as "Ready for review" and request a review from the design system maintainers.
249
-
1
+ # Røde Kors Design System Component Library (Norwegian Red Cross)
2
+
3
+ ## Live Storybook URL
4
+
5
+ [https://norwegianredcross.github.io/DesignSystem/storybook/](https://norwegianredcross.github.io/DesignSystem/storybook/)
6
+
7
+ ## Overview
8
+
9
+ Welcome to the Røde Kors Design System! This repository contains a library of reusable UI components built with React, specifically tailored for Norwegian Red Cross digital projects.
10
+
11
+ It's developed leveraging the foundational components from Digdir's Designsystemet. This approach ensures a unified and recognizable visual identity across all applications for the Norwegian Red Cross. The system is pre-configured with the official Røde Kors brand theme, which is provided via a dedicated design token package.
12
+
13
+ The primary goal is to ensure brand consistency, improve development efficiency, and maintain high accessibility standards across all Røde Kors applications.
14
+
15
+ Storybook serves as the interactive documentation and development environment for viewing and testing these components.
16
+
17
+ ## Consuming This Library (For Application Developers)
18
+
19
+ To use the Røde Kors Design System in your Next.js (or any React) application:
20
+
21
+ ### 1. Installation
22
+
23
+ Install the necessary npm packages for your project. You will need three packages: the component library itself (`rk-designsystem`), the base styles from Digdir, and the Røde Kors theme package (`rk-design-tokens`).
24
+
25
+ ```bash
26
+ # npm
27
+ npm install rk-designsystem @digdir/designsystemet-css rk-design-tokens
28
+
29
+ # yarn
30
+ yarn add rk-designsystem @digdir/designsystemet-css rk-design-tokens
31
+
32
+ # pnpm
33
+ pnpm add rk-designsystem @digdir/designsystemet-css rk-design-tokens
34
+ ```
35
+
36
+ **Note:** You do not need to install `@digdir/designsystemet-react` separately, as all required components are included within the `rk-designsystem` package.
37
+
38
+ ### 2. Including Styles (CSS)
39
+
40
+ For the components to be styled correctly, you must import the stylesheets at the highest level of your application, for instance, in your `layout.tsx` (for Next.js App Router) or `_app.tsx` (for Next.js Pages Router).
41
+
42
+ **Crucial Order:** It's vital that the base stylesheet (`@digdir/designsystemet-css`) is loaded **before** the Røde Kors theme file (`rk-design-tokens`). This ensures our theme's tokens can correctly override the default values.
43
+
44
+ #### Example for Next.js (App Router - `src/app/layout.tsx`):
45
+
46
+ ```tsx
47
+ import './globals.css'; // Your own global styles (if any)
48
+ import '@digdir/designsystemet-css/index.css'; // Base stylesheet for components
49
+ import 'rk-design-tokens/design-tokens-build/theme.css'; // Røde Kors theme
50
+
51
+ export default function RootLayout({
52
+ children,
53
+ }: {
54
+ children: React.ReactNode;
55
+ }) {
56
+ return (
57
+ <html lang="en">
58
+ <body>{children}</body>
59
+ </html>
60
+ );
61
+ }
62
+ ```
63
+
64
+ #### Example for Next.js (Pages Router - `pages/_app.tsx`):
65
+
66
+ ```tsx
67
+ import '../styles/globals.css'; // Your own global styles (if any)
68
+ import '@digdir/designsystemet-css/index.css'; // Base stylesheet for components
69
+ import 'rk-design-tokens/design-tokens-build/theme.css'; // Røde Kors theme
70
+ import type { AppProps } from 'next/app';
71
+
72
+ function MyApp({ Component, pageProps }: AppProps) {
73
+ return <Component {...pageProps} />;
74
+ }
75
+
76
+ export default MyApp;
77
+ ```
78
+
79
+ ### 3. Using Components
80
+
81
+ Once the stylesheets are included, you can start importing and using components in your project. All components you need are available directly from the `rk-designsystem` package.
82
+
83
+ #### 3.1 Import and Use Røde Kors Design System Components
84
+
85
+ Import components directly from the `rk-designsystem` package:
86
+
87
+ ```tsx
88
+ import { Alert } from 'rk-designsystem'; // Import necessary components
89
+
90
+ function MyComponent() {
91
+ return (
92
+ <>
93
+ <Alert variant="info" onClose={() => console.log('Alert closed!')}>
94
+ This is an informational message from the Red Cross Design System.
95
+ </Alert>
96
+ </>
97
+ );
98
+ }
99
+ ```
100
+
101
+ #### 3.2 Example Usage in a Next.js Page
102
+
103
+ Here's an example of how to use multiple Alert components from the Røde Kors Design System within a Next.js page/component:
104
+
105
+ ```tsx
106
+ 'use client'; // Remember 'use client' for interactive components in App Router
107
+
108
+ import React from 'react';
109
+ import { Alert } from 'rk-designsystem'; // Import the components you need
110
+
111
+ export default function Home() {
112
+ return (
113
+ <div className="container mx-auto p-8">
114
+ <h1 className="text-3xl font-bold mb-8">
115
+ Røde Kors Design System Example
116
+ </h1>
117
+
118
+ <section>
119
+ <h2 className="text-2xl font-semibold mb-4">Alerts</h2>
120
+ {/* Røde Kors Design System Alerts */}
121
+ <Alert variant="success">
122
+ <p>
123
+ Welcome! This message is styled with the official Røde Kors theme.
124
+ </p>
125
+ </Alert>
126
+
127
+ <Alert variant="warning" className="mt-4">
128
+ <p>
129
+ Important information using the official Røde Kors theme.
130
+ </p>
131
+ </Alert>
132
+ </section>
133
+
134
+ {/* More Røde Kors components can be added here as needed */}
135
+ </div>
136
+ );
137
+ }
138
+ ```
139
+
140
+ The appearance of all components is fully controlled by the `rk-design-tokens` package. To receive any visual updates to the brand theme (like a new primary color), simply update the package to its latest version:
141
+
142
+ ```bash
143
+ npm update rk-design-tokens
144
+ ```
145
+
146
+ ---
147
+
148
+ # Contributing to the Component Library
149
+
150
+ This guide provides a set of standards and best practices for creating new components. Following these guidelines ensures that our component library remains consistent, accessible, and easy to maintain.
151
+
152
+ ## Getting Started (for Contributors)
153
+
154
+ Follow these steps to get the local development environment running. All commands should be run from the root of the project.
155
+
156
+ ```bash
157
+ # 1. Install dependencies
158
+ pnpm i
159
+
160
+ # 2. Build all packages
161
+ pnpm build
162
+
163
+ # 3. Start the local Storybook server
164
+ pnpm storybook
165
+ ```
166
+
167
+ ## Core Principles
168
+
169
+ Every component we build should adhere to these core principles:
170
+
171
+ 1. **Accessibility (A11y):** Components must be usable by everyone, including people with disabilities. This means proper ARIA attributes, keyboard navigation, and semantic HTML.
172
+ 2. **Reusability:** Components should be generic enough to be used in multiple contexts without modification.
173
+ 3. **Consistency:** Components should follow our established design tokens (colors, spacing, typography) and have a consistent API and structure.
174
+ 4. **Documentation:** Every component must be documented in Storybook to make it discoverable and easy for other developers to use.
175
+
176
+ ## When to Create a New Component
177
+
178
+ Before you start coding, determine what kind of component you need. Most of our needs fall into one of three categories:
179
+
180
+ 1. **Wrapped Component (Simple):**
181
+ * **What it is:** A component that directly wraps and re-exports a component from `@digdir/designsystemet-react` with no modifications.
182
+ * **When to use:** When the base Digdir component meets our needs perfectly, but we want to include it in our own library for a consistent import source.
183
+ * **Example:** The `Buttons` component is a perfect example of this.
184
+
185
+ 2. **Wrapped Component (with Style Overrides):**
186
+ * **What it is:** A wrapped Digdir component where we apply custom CSS to tweak its appearance to better match Røde Kors's specific design language.
187
+ * **When to use:** When a Digdir component is functionally correct but needs visual adjustments (e.g., different icons, border radius, padding).
188
+ * **Example:** The `Alert` component, which uses `composes` in its CSS to inherit base styles and then applies its own overrides.
189
+
190
+ 3. **Custom Component (from Scratch):**
191
+ * **What it is:** A completely new component built when no existing Digdir component meets our requirements.
192
+ * **When to use:** For unique UI patterns or functionality not covered by the base library.
193
+ * **Example:** The `DateInput` component is a custom component with its own state, logic, and styling.
194
+
195
+ ## Component File Structure
196
+
197
+ To maintain consistency, every new component should follow this file structure. Create a new folder under `src/components/` with the component's `PascalCase` name.
198
+
199
+ ```text
200
+ src/
201
+ └── components/
202
+ └── MyNewComponent/
203
+ ├── index.ts // Public API - exports the component and props
204
+ ├── MyNewComponent.tsx // The React component logic and JSX
205
+ ├── MyNewComponent.stories.tsx // Storybook stories for documentation
206
+ ├── styles.module.css // Scoped CSS (only for custom components)
207
+ └── MyNewComponent.test.tsx // (Optional but Recommended) Unit tests
208
+ ```
209
+
210
+ ## Coding Guidelines
211
+
212
+ ### 1. Component Logic (`MyNewComponent.tsx`)
213
+
214
+ * **TypeScript First:** All components must be written in TypeScript. Define a `Props` interface for your component, extending from the base HTML element or Digdir component props if applicable.
215
+ * **Forward Refs:** Always use `React.forwardRef` to allow parent components to get a `ref` to the underlying DOM element.
216
+ * **Accessibility is Mandatory:**
217
+ * Use semantic HTML (`<button>`, `<label>`, `<nav>`).
218
+ * Ensure all interactive elements are keyboard-focusable and operable.
219
+ * Provide `aria-label` for icon-only buttons or elements where the text label is not visible.
220
+ * Use `aria-invalid`, `aria-describedby`, etc., to communicate state to assistive technologies.
221
+ * **Controlled vs. Uncontrolled:** If your component has state (like an input), it should support both controlled (`value` + `onChange`) and uncontrolled (`defaultValue`) patterns.
222
+ * **Props Naming:** Use `data-*` attributes for styling variants (e.g., `data-size`, `data-color`) to align with the patterns in our existing components.
223
+
224
+ ### 2. Styling (`styles.module.css`)
225
+
226
+ * **CSS Modules:** For **custom components**, all styles must be placed in a `styles.module.css` file. This scopes class names locally and prevents global style conflicts.
227
+ * **Design Tokens:** Always use our design system tokens (`var(--ds-...)`) for colors, spacing, fonts, etc. Do not use hardcoded values (e.g., `#FFF`, `16px`).
228
+ * **Overriding Wrapped Components:** For **wrapped components**, use a standard CSS file. Use the `@layer` and `composes` keywords to extend base Digdir styles without increasing CSS specificity unnecessarily.
229
+
230
+ ### 3. Documentation (`MyNewComponent.stories.tsx`)
231
+
232
+ Your Storybook file is the official documentation. It must be clear and comprehensive.
233
+
234
+ * **`meta` Object:** Define the component's title, component reference, and `tags: ['autodocs']` to enable automatic documentation.
235
+ * **`argTypes`:** Document every single prop. Provide a `description`, `control` type (e.g., `select`, `boolean`, `text`), and `options` if applicable. This powers the interactive controls in Storybook.
236
+ * **Create Multiple Stories:** Create a separate story for each key state and variant of your component (e.g., `Default`, `Disabled`, `WithError`, `WithIcon`).
237
+
238
+ ## Contribution Process
239
+
240
+ ### 1. Create a Pull Request (PR)
241
+
242
+ 1. **Create a Branch:** Pull the latest changes from the `main` branch and create a new feature branch: `git checkout -b feat/my-new-component`.
243
+
244
+ 2. **Open a Draft PR:** As soon as you start, open a **draft** pull request on GitHub. This prevents duplicate work and allows others to see what you're working on.
245
+
246
+ 3. **Commit Your Changes:** As you work, make small, logical commits.
247
+
248
+ 4. **Ready for Review:** When development is complete and all automated checks are passing, mark the PR as "Ready for review" and request a review from the design system maintainers.
249
+