@nimbus-ds/components 5.8.0-rc.19 โ 5.8.0-rc.21
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/dist/index.js +0 -1
- package/package.json +3 -9
- package/dist/CHANGELOG.md +0 -489
- package/dist/README.md +0 -235
package/dist/README.md
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
# `@nimbus-ds/components`
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@nimbus-ds/components)
|
|
4
|
-
|
|
5
|
-
Nimbus components is a component library built with [React](https://reactjs.org), designed to help our teams and ecosystem build better products for our merchants.
|
|
6
|
-
|
|
7
|
-
## ๐ Getting started
|
|
8
|
-
|
|
9
|
-
Install `@nimbus-ds/components` using any package manager.
|
|
10
|
-
|
|
11
|
-
```sh
|
|
12
|
-
$ yarn add @nimbus-ds/components
|
|
13
|
-
# or
|
|
14
|
-
$ npm install @nimbus-ds/components
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## ๐ป Usage
|
|
18
|
-
|
|
19
|
-
```jsx
|
|
20
|
-
import { Button } from "@nimbus-ds/components";
|
|
21
|
-
|
|
22
|
-
const ComponentExample = () => <Button>Hello World</Button>;
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
For more information about our components, check out our [Storybook](https://tiendanube.github.io/nimbus-design-system/).
|
|
26
|
-
|
|
27
|
-
### Folder & file structures ๐ ๐
|
|
28
|
-
|
|
29
|
-
- For best practices in structure files please read this [document](https://redux.js.org/style-guide/style-guide#structure-files-as-feature-folders-with-single-file-logic)
|
|
30
|
-
- When creating a new component, do so inside the **src/atomic** or **src/composite** directory
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
โโ ๐ src
|
|
34
|
-
โ โโ ๐ atomic/composite
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
- Every directory must contain a ๐ **CHANGELOG.md** which serves to document all changes and changes made to each component.
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
โโ ๐ src
|
|
41
|
-
โ โโ ๐ atomic/composite
|
|
42
|
-
โ โ โโ ๐ ComponentExample
|
|
43
|
-
โ โ โ โโ ๐ src
|
|
44
|
-
โ โ โ โโ CHANGELOG.md
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
- Every directory should contain a ๐ **README.md** which serves to document the installation steps and a brief summary of each component.
|
|
48
|
-
|
|
49
|
-
```
|
|
50
|
-
โโ ๐ src
|
|
51
|
-
โ โโ ๐ atomic/composite
|
|
52
|
-
โ โ โโ ๐ ComponentExample
|
|
53
|
-
โ โ โ โโ ๐ src
|
|
54
|
-
โ โ โ โโ CHANGELOG.md
|
|
55
|
-
โ โ โ โโ README.md
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
- The directory should have the same name as the component. The component file should have the name of the component in Pascal Case format and the extension `.tsx`
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
โโ ๐ src
|
|
62
|
-
โ โโ ๐ atomic/composite
|
|
63
|
-
โ โ โโ ๐ ComponentExample
|
|
64
|
-
โ โ โ โโ ๐ src
|
|
65
|
-
โ โ โ โ โโ ComponentExample.tsx
|
|
66
|
-
โ โ โ โโ CHANGELOG.md
|
|
67
|
-
โ โ โ โโ README.md
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
- Every directory should contain a ๐ **index.ts** which serves as an entry point for the module, component, utils and/or hooks.
|
|
71
|
-
|
|
72
|
-
```
|
|
73
|
-
โโ ๐ src
|
|
74
|
-
โ โโ ๐ atomic/composite
|
|
75
|
-
โ โ โโ ๐ ComponentExample
|
|
76
|
-
โ โ โ โโ ๐ src
|
|
77
|
-
โ โ โ โ โโ index.ts
|
|
78
|
-
โ โ โ โ โโ ComponentExample.tsx
|
|
79
|
-
โ โ โ โโ CHANGELOG.md
|
|
80
|
-
โ โ โ โโ README.md
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
- Every component, utils and/or hooks should come with a test. The test must have the same name as the file being tested and the extension must be `.spec.tsx`
|
|
84
|
-
|
|
85
|
-
```
|
|
86
|
-
โโ ๐ src
|
|
87
|
-
โ โโ ๐ atomic/composite
|
|
88
|
-
โ โ โโ ๐ ComponentExample
|
|
89
|
-
โ โ โ โโ ๐ src
|
|
90
|
-
โ โ โ โ โโ index.ts
|
|
91
|
-
โ โ โ โ โโ ComponentExample.tsx
|
|
92
|
-
โ โ โ โ โโ componentExample.spec.tsx
|
|
93
|
-
โ โ โ โโ CHANGELOG.md
|
|
94
|
-
โ โ โ โโ README.md
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
- Every component must come with documentation. The documentation must have the same name as the file being documented and the extension must be `.stories.tsx`.
|
|
98
|
-
|
|
99
|
-
```
|
|
100
|
-
โโ ๐ src
|
|
101
|
-
โ โโ ๐ atomic/composite
|
|
102
|
-
โ โ โโ ๐ ComponentExample
|
|
103
|
-
โ โ โ โโ ๐ src
|
|
104
|
-
โ โ โ โ โโ index.ts
|
|
105
|
-
โ โ โ โ โโ ComponentExample.tsx
|
|
106
|
-
โ โ โ โ โโ componentExample.spec.tsx
|
|
107
|
-
โ โ โ โ โโ componentExample.stories.tsx
|
|
108
|
-
โ โ โ โโ CHANGELOG.md
|
|
109
|
-
โ โ โ โโ README.md
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
- Every component must come with a typing. The type must have the same name as the file being documented and the extension must be `.types.tsx`.
|
|
113
|
-
|
|
114
|
-
```
|
|
115
|
-
โโ ๐ src
|
|
116
|
-
โ โโ ๐ atomic/composite
|
|
117
|
-
โ โ โโ ๐ ComponentExample
|
|
118
|
-
โ โ โ โโ ๐ src
|
|
119
|
-
โ โ โ โ โโ index.ts
|
|
120
|
-
โ โ โ โ โโ ComponentExample.tsx
|
|
121
|
-
โ โ โ โ โโ componentExample.spec.tsx
|
|
122
|
-
โ โ โ โ โโ componentExample.stories.tsx
|
|
123
|
-
โ โ โ โ โโ componentExample.types.ts
|
|
124
|
-
โ โ โ โโ CHANGELOG.md
|
|
125
|
-
โ โ โ โโ README.md
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
- If a component has one or more children components, a subdirectory **๐ components** must be created inside de main directory of the component.
|
|
129
|
-
|
|
130
|
-
```
|
|
131
|
-
โโ ๐ src
|
|
132
|
-
โ โโ ๐ atomic/composite
|
|
133
|
-
โ โ โโ ๐ ComponentExample
|
|
134
|
-
โ โ โ โโ ๐ src
|
|
135
|
-
โ โ โ โ โโ ๐ components
|
|
136
|
-
โ โ โ โ โ โโ ๐ ComponentChild
|
|
137
|
-
โ โ โ โ โ โ โโ index.ts
|
|
138
|
-
โ โ โ โ โ โ โโ ComponentChild.tsx
|
|
139
|
-
โ โ โ โ โ โ โโ componentChild.spec.tsx
|
|
140
|
-
โ โ โ โ โ โ โโ componentExample.types.ts
|
|
141
|
-
โ โ โ โ โ โโ index.ts
|
|
142
|
-
โ โ โ โ โโ index.ts
|
|
143
|
-
โ โ โ โ โโ ComponentExample.tsx
|
|
144
|
-
โ โ โ โ โโ componentExample.spec.tsx
|
|
145
|
-
โ โ โ โ โโ componentExample.stories.tsx
|
|
146
|
-
โ โ โ โ โโ componentExample.types.ts
|
|
147
|
-
โ โ โ โโ CHANGELOG.md
|
|
148
|
-
โ โ โ โโ README.md
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### Component coding ๐ค โจ๏ธ
|
|
152
|
-
|
|
153
|
-
- The component should have the same name as the file using Pascal Case format. It should be declared in a Arrow Function, always typying the expected answer and making the default export at the end of the file.
|
|
154
|
-
|
|
155
|
-
```jsx
|
|
156
|
-
// ComponentExample.tsx
|
|
157
|
-
import React from "react";
|
|
158
|
-
|
|
159
|
-
const ComponentExample: React.FC = () => <div>...</div>;
|
|
160
|
-
|
|
161
|
-
export { ComponentExample };
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
- If the component has props, they will be imported from the corresponding `.definitions.ts` file adding initial prefix corresponding to their type. Example interface ` ILogin`, type `TLogin`, enum `ELogin`.
|
|
165
|
-
|
|
166
|
-
```jsx
|
|
167
|
-
// ComponentExample.tsx
|
|
168
|
-
import React from "react";
|
|
169
|
-
import { ComponentExampleProps } from "./componentExampleProps.types";
|
|
170
|
-
|
|
171
|
-
const ComponentExample: React.FC<ComponentExampleProps> = ({
|
|
172
|
-
title,
|
|
173
|
-
description,
|
|
174
|
-
}) => (
|
|
175
|
-
<div>
|
|
176
|
-
<h1>{title}</h1>
|
|
177
|
-
<p>{description}</p>
|
|
178
|
-
</div>
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
export { ComponentExample };
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
### Testing ๐งช๐ฌ
|
|
185
|
-
|
|
186
|
-
- For testing best practices, please read this [document](https://kentcdodds.com/blog/common-mistakes-with-react-testing-library).
|
|
187
|
-
- To create a test is necessary to import from the testing library both the render and the screen.
|
|
188
|
-
|
|
189
|
-
```jsx
|
|
190
|
-
import { render, screen } from "@testing-library/react";
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
- The component to be tested should also be imported.
|
|
194
|
-
|
|
195
|
-
```jsx
|
|
196
|
-
import { render, screen } from "@testing-library/react";
|
|
197
|
-
import { ComponentExample } from "./ComponentExample";
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
- The heading of the tests must be written following the order Given-When-Then [Documentation](https://cucumber.io/docs/gherkin/reference/)
|
|
201
|
-
- **Given** represents a precondition
|
|
202
|
-
- **When** an action
|
|
203
|
-
- **Then** a result or consequence of the action (user acceptance criteria).
|
|
204
|
-
- **And** a result or consequence of other consequence (user acceptance criteria).
|
|
205
|
-
- **But** a result which should not be possibly observable
|
|
206
|
-
|
|
207
|
-
```jsx
|
|
208
|
-
import { render, screen } from "@testing-library/react";
|
|
209
|
-
import { ComponentExample } from "./ComponentExample";
|
|
210
|
-
|
|
211
|
-
describe("GIVEN <ComponentExample />", () => {
|
|
212
|
-
describe("WHEN rendered", () => {
|
|
213
|
-
it("THEN should display the correct text", () => {
|
|
214
|
-
...
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
- In this first instance, we will verify the right rendering of the component by checking the text in each of the elements.
|
|
221
|
-
|
|
222
|
-
```jsx
|
|
223
|
-
import { render, screen } from "@testing-library/react";
|
|
224
|
-
import { ComponentExample } from "./ComponentExample";
|
|
225
|
-
|
|
226
|
-
describe("GIVEN <ComponentExample />", () => {
|
|
227
|
-
describe("WHEN rendered", () => {
|
|
228
|
-
it("THEN should display the correct text", () => {
|
|
229
|
-
render(<ComponentExample title="title" description="description" />);
|
|
230
|
-
expect(screen.getByText(/title/i)).toBeInTheDocument();
|
|
231
|
-
expect(screen.getByText(/description/i)).toBeInTheDocument();
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
```
|