@equinor/echo-components 2.2.3 → 2.4.0

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/README.md CHANGED
@@ -4,40 +4,73 @@ This publishable library was generated with [Nx](https://nx.dev).
4
4
 
5
5
  Building blocks for Echo, built on top of EDS (Equinor Design System).
6
6
 
7
+ ## ⚠️ Dependency Rules
8
+
9
+ **Source of truth: `/eslint.config.js`** - The `@nx/enforce-module-boundaries` rule defines all allowed dependencies.
10
+
11
+ **echo-components can only import from:**
12
+
13
+ - `echo-utils` ✅
14
+
15
+ **echo-components CANNOT import from:**
16
+
17
+ - `echo-framework` ❌
18
+ - `echo-search` ❌
19
+ - `echo-core` ❌
20
+ - `echo-base` ❌
21
+ - `echopedia-web` (app) ❌
22
+
23
+ See `libs/README.md` for the full dependency flow diagram.
24
+
25
+ ---
26
+
7
27
  ## Guidelines for storybook
8
- Think of Storybook as a virtual showroom for your app's building blocks - the UI components. It lets developers experiment with components in isolation, like tinkering with Legos before building something bigger. Storybook isn't just about documenting components, it's about creating an interactive playground for developers to explore their full potential.
28
+
29
+ Think of Storybook as a virtual showroom for your app's building blocks - the UI components. It lets developers experiment with components in isolation, like tinkering with Legos before building something bigger. Storybook isn't just about documenting components, it's about creating an interactive playground for developers to explore their full potential.
9
30
 
10
31
  ### Online storybook
32
+
11
33
  Publishing static storybook page
12
- - a github action builds and deploys the static storybook page to the following branch: `echo-components-storybook` - we shouldn't delete this one!
13
- - another github action will pick it up from here, and publish it to a github page.
34
+
35
+ - a github action builds and deploys the static storybook page to the following branch: `echo-components-storybook` - we shouldn't delete this one!
36
+ - another github action will pick it up from here, and publish it to a github page.
14
37
 
15
38
  [Online storybook can be found here](https://bookish-adventure-l5zz573.pages.github.io/?path=/docs/introduction--docs)
16
39
 
17
40
  ### Why Use Storybook?
41
+
18
42
  - Faster Development: Experiment with components quickly, without needing the whole app running.
19
43
  - Improved Consistency: Ensures all components look and behave the same way throughout the app.
20
44
  - Better Collaboration: Designers and developers can easily share component design and functionality.
21
45
  - Easier Maintenance: New developers can understand existing components through clear documentation.
22
46
 
23
47
  ### Before you write your storybook
24
- - Understand Your Components: Take some time to thoroughly understand the components you'll document. What purpose do they serve? What props do they accept? What states can they be in? This knowledge will guide the scenarios you showcase in your storybook.
25
- - Know Your Audience: Consider who will be using your storybook. Are they primarily developers new to the codebase, or seasoned veterans? This will influence the level of detail you provide and the complexity of the stories you create.
48
+
49
+ - Understand Your Components: Take some time to thoroughly understand the components you'll document. What purpose do they serve? What props do they accept? What states can they be in? This knowledge will guide the scenarios you showcase in your storybook.
50
+ - Know Your Audience: Consider who will be using your storybook. Are they primarily developers new to the codebase, or seasoned veterans? This will influence the level of detail you provide and the complexity of the stories you create.
51
+
26
52
  ### Building Blocks of Captivating Stories
53
+
27
54
  - Isolate and Conquer: Storybook lets components shine by themselves. This allows developers to experiment with props and states without worrying about interactions with other parts of the code.
28
55
  - Variety is the Spice of Life: Don't just show the basics! Showcase the versatility of your component with different prop combinations (sizes, styles), visual themes (light/dark mode), and functional states (loading, error, success).
29
- - Interactive Playground: Utilize Storybook's interactivity features. Allow developers to change props and states directly within the storybook interface. This fosters exploration and experimentation.
56
+ - Interactive Playground: Utilize Storybook's interactivity features. Allow developers to change props and states directly within the storybook interface. This fosters exploration and experimentation.
57
+
30
58
  ### Writing Effective Descriptions:
31
- - Clear and Concise: Write clear and concise descriptions that explain the component's purpose and usage. Avoid technical jargon that new developers might not understand.
32
- - Focus on Benefits: Highlight the benefits of using the component. How does it make development easier or more efficient?
33
- - Code Examples: Provide relevant code examples that demonstrate how to use the component in practice. Include both basic usage and more advanced scenarios.
59
+
60
+ - Clear and Concise: Write clear and concise descriptions that explain the component's purpose and usage. Avoid technical jargon that new developers might not understand.
61
+ - Focus on Benefits: Highlight the benefits of using the component. How does it make development easier or more efficient?
62
+ - Code Examples: Provide relevant code examples that demonstrate how to use the component in practice. Include both basic usage and more advanced scenarios.
63
+
34
64
  ### Beyond the Basics:
65
+
35
66
  - Accessibility for All: Consider accessibility in your stories. Showcase how the component can be used to create interfaces that everyone can use.
36
67
  - BeBest Practices for Best Results: Include examples of how to use the component effectively. This helps developers avoid common pitfalls and write cleaner, more maintainable code.
37
68
  - Visual Appeal Matters: Use clear and organized layouts for your stories. Consider using visual aids like screenshots or mockups to enhance understanding.
38
69
 
39
70
  ### Text Example: Let's Build a Button Story!
40
- Imagine a button component - the workhorse of applications. Here's how to craft a compelling story around it:
71
+
72
+ Imagine a button component - the workhorse of applications. Here's how to craft a compelling story around it:
73
+
41
74
  - Title: Button - A Versatile Action Trigger
42
75
  - Description: A versatile button component for triggering actions in your application. Supports various styles (primary, secondary), sizes (large, small), and states (enabled, disabled) for a consistent user experience.
43
76
  - Basic Usage: Show a simple button with its default label and style.
@@ -45,9 +78,11 @@ Imagine a button component - the workhorse of applications. Here's how to craft
45
78
  - Visual Themes: Showcase the button in different themes (light mode, dark mode) if applicable.
46
79
  - Interactive Playground: Allow developers to change the button text, choose a variant, and toggle the disabled state directly within the storybook.
47
80
  - Code Example: Provide a code snippet demonstrating how to import and use the button component with different props.
48
-
81
+
49
82
  ### Recipe for Writing a Good Story in Your Storybook (Using the Button Component Example)
83
+
50
84
  **Ingredients:**
85
+
51
86
  - Fresh Code: The code for the component you want to showcase (like the provided Button.stories.tsx file).
52
87
  - Storybook Utilities: StoryFn and Meta functions from @storybook/react.
53
88
  - Clarity and Conciseness: Aim for clear and easy-to-understand stories.
@@ -55,11 +90,13 @@ Imagine a button component - the workhorse of applications. Here's how to craft
55
90
  - Visual Appeal (Optional): Make the stories visually appealing for better engagement.
56
91
 
57
92
  **Step 1. Set the Stage: Configuration and Title (Meta):** Define the Meta object with:
93
+
58
94
  - title: A descriptive title indicating the component hierarchy (e.g., "Components/Button/Button").
59
95
  - component: The component you're showcasing (e.g., Button).
60
96
  - args: Default values for component props (e.g., as: 'button').
61
97
  - argTypes: Define control types for interactive prop selection.
62
98
  - parameters.docs.page: Link to your component's documentation (optional).
99
+
63
100
  ```
64
101
  import { Meta, StoryFn } from '@storybook/react';
65
102
  import { Button } from './Button'; // Replace with your Button component import path
@@ -89,6 +126,7 @@ export default meta;
89
126
  ```
90
127
 
91
128
  **Step 2. Create the Template:** Write a reusable Template function that renders the component within a container element (e.g., div). This template will be used in most stories.
129
+
92
130
  ```
93
131
  const Template: StoryFn<Button.Props> = (args) => (
94
132
  <div className="button-container"> {/* Add a container class for styling (optional) */}
@@ -97,7 +135,8 @@ const Template: StoryFn<Button.Props> = (args) => (
97
135
  );
98
136
  ```
99
137
 
100
- **Step 3. Tell the Main Story: Introduction:**
138
+ **Step 3. Tell the Main Story: Introduction:**
139
+
101
140
  - Define a story named Introduction (or similar) that uses the Template function.
102
141
  - Render a basic button with its default props to showcase its fundamental form.
103
142
 
@@ -108,13 +147,14 @@ export const Introduction: StoryFn<Button.Props> = () => (
108
147
  ```
109
148
 
110
149
  **Step 4. Spice it Up: Variations and States:** Create additional stories to demonstrate different button variations and states. These could be:
150
+
111
151
  - Different styles (primary, secondary, outlined)
112
152
  - Sizes (large, small)
113
153
  - Disabled state
114
154
  - Loading state (if applicable)
115
155
  - Icon variations (with or without icons)
116
156
  - Interactive elements (toggling loading state)
117
- For each story, provide a descriptive title that reflects the variation (e.g., "Primary Button - Large").
157
+ For each story, provide a descriptive title that reflects the variation (e.g., "Primary Button - Large").
118
158
 
119
159
  ```
120
160
  export const PrimaryButtonLarge: StoryFn<Button.Props> = () => (
@@ -145,17 +185,18 @@ export const IconButton: StoryFn<Button.Props> = () => (
145
185
  </Template>
146
186
  );
147
187
  ```
188
+
148
189
  **Step 5. Visual Presentation (Optional):** Consider using background colors or layouts to enhance the visual appeal of your stories. Example: You can customize the button-container class in the Template to add background colors or styles for a more visually appealing presentation.
149
190
 
150
191
  **Step 6. Serve it Up! (Export):** Export the meta object (containing configuration) at the end of your file..
192
+
151
193
  ```
152
194
  export default meta;
153
195
  ```
154
196
 
155
197
  ### Picture Example: SecondaryMarker
156
- ![image](https://github.com/equinor/EchopediaWeb/assets/54355967/25d9703e-5b43-4c8a-acc5-4a9f74fbbbf9)
157
-
158
198
 
199
+ ![image](https://github.com/equinor/EchopediaWeb/assets/54355967/25d9703e-5b43-4c8a-acc5-4a9f74fbbbf9)
159
200
 
160
201
  ## How to develop and release EchoComponents
161
202
 
@@ -163,9 +204,9 @@ Check the [readme](/libs/README.md) in the NX libraries folder.
163
204
 
164
205
  ## Available NPM scripts
165
206
 
166
- - `lint-components`
167
- - `build-components`
168
- - `test-components`
207
+ - `lint-components`
208
+ - `build-components`
209
+ - `test-components`
169
210
 
170
211
  ## Old repository of echoComponents
171
212