You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-```@scality/core-ui``` requires some peerDependencies below. Make sure that you have them in the ```package.json```'s dependencies.
17
+
-```@scality/core-ui``` requires the peerDependencies below. Make sure that you have them in the ```package.json```'s dependencies.
18
18
19
19
```json
20
20
"@fortawesome/fontawesome-free": "^5.10.2",
@@ -128,35 +128,90 @@ export type CoreUITheme = {
128
128
129
129
This project is built with [React](https://react.dev/) and [TypeScript](https://www.typescriptlang.org/), and styled with [styled-components](https://styled-components.com/).
130
130
131
-
Project structure :
131
+
To start contributing to core-ui, clone the repository :
Give your branch an explicit name with the reference to the Jira ticket or issue if it exists, and prefix it with :
146
+
147
+
- feature/ for new component or major component update : `feature/TICKET-123-some-feature`
148
+
- improvement/ for code improvement, component update : `improvement/TICKET-456-some-improvement`
149
+
- bugfix/ for bug related issue : `bugfix/TICKET-789-some-bug`
150
+
151
+
Use :
152
+
153
+
```sh
154
+
git checkout -b <branch-name>
155
+
```
156
+
157
+
### Creating a new component
158
+
159
+
Create a new folder in `src/lib/components` for the component file and test file.
160
+
Depending on your component, it can be useful to create more files for the style, hooks, or utility functions that are necessary for your component. It will make the code more readable and easier to maintain.
161
+
162
+
Create a new folder in `stories` for the documentation files.
163
+
164
+
You should end with something like below :
132
165
133
166
```text
134
167
- src/
135
168
- lib/
136
169
- components/
137
-
- MyComponent/
138
-
- MyComponent.component.tsx
139
-
- MyComponent.test.tsx
170
+
- example/
171
+
- Example.component.tsx
172
+
- Example.test.tsx
140
173
- stories/
141
-
- MyComponent/
142
-
- mycomponent.stories.tsx
143
-
- mycomponent.guideline.mdx
174
+
- example/
175
+
- example.stories.tsx
176
+
- example.guideline.mdx
144
177
```
145
178
146
-
### Creating a new component
179
+
Expose your component in `src/lib/index.ts`.
180
+
When creating a new version of an existing component, expose it in `src/lib/next.ts` instead to avoid conflict.
181
+
182
+
### Use Storybook
183
+
184
+
You can use storybook to help with the development.
185
+
Storybook helps to test and vizualize component in isolation.
186
+
If it doesn't exist, write a [story](https://storybook.js.org/docs/get-started/whats-a-story) for the component :
147
187
148
-
When creating a new component, you can use storybook to help with the development.
149
-
Write a [story](https://storybook.js.org/docs/get-started/whats-a-story) with your component and launch storybook :
import { Example } from'../src/lib/components/example/Example.component.tsx';
192
+
193
+
const meta:Meta<typeofExample> = {
194
+
component: Example,
195
+
};
196
+
197
+
exportdefaultmeta;
198
+
type Story = StoryObj<typeof Example>;
199
+
200
+
exportconst Default:Story= {
201
+
render: () =><Example />,
202
+
};
203
+
204
+
```
205
+
206
+
then launch storybook :
150
207
151
208
```sh
152
209
npm run storybook
153
210
```
154
211
155
212
Storybook will be launched on `http://localhost:3000`.
156
213
157
-
After creating or updating a component, make sure to lint, test and document your code :
158
-
159
-
#### Lint
214
+
### Lint
160
215
161
216
To make sure your code is correctly lint, run :
162
217
@@ -166,28 +221,70 @@ npm run lint
166
221
167
222
It will run ESLint by using `eslint-config-react-app` which is a shareable ESLint configuration used by [Create React App](https://github.com/facebook/create-react-app).
168
223
169
-
####Test
224
+
### Test
170
225
171
-
Build tests with [jest](https://jestjs.io/) and run them with :
226
+
Build tests with [jest](https://jestjs.io/)
227
+
228
+
Make sure to write tests that cover all cases, then you can run all tests with :
172
229
173
230
```sh
174
231
npm run test
175
232
```
176
233
177
-
#### Documentation
234
+
or run a specific test with :
235
+
236
+
```sh
237
+
npm run test Example.test.tsx
238
+
```
239
+
240
+
### Documentation
178
241
179
242
Core-UI uses [storybook](https://storybook.js.org/) for its documentation. \
180
243
Illustrate use cases and state variations with [stories](https://storybook.js.org/docs/writing-stories).
244
+
All stories should be type.
245
+
246
+
If possible create or update the component guideline.
247
+
This guideline is an MDX file containing details about the component usage and is illustrated with the stories write in stories.tsx file.
248
+
249
+
```txt
250
+
// in example.guideline.mdx
251
+
import { Canvas, Meta } from '@storybook/blocks';
252
+
253
+
import * as ExampleStories from './Example.stories';
254
+
255
+
<Meta of={ExampleStories} />
256
+
257
+
# Example Component
258
+
259
+
An Example component is used for example.
260
+
261
+
<Canvas of={ExampleStories.Default} />
262
+
263
+
```
264
+
265
+
### Pull request
266
+
267
+
Push your code on the repository
268
+
269
+
```sh
270
+
git push origin <branch-name>
271
+
```
272
+
273
+
then create a `Pull Request`.
274
+
Pull request needs to be approved by at least one reviewer.
275
+
After your PR is approved you can comment `/approve`
181
276
182
-
### Release process
277
+
### Release
183
278
279
+
After merging one or more PR in Core-UI, it is possible to plublish a new release.
184
280
In the Core-UI repo, follow these steps :
185
281
186
-
1.Click on `Releases` then `Draft a new release`
282
+
1.Go on `Releases` then `Draft a new release`
187
283
2. In the select menu `Choose a tag` : Create a new tag (the current tag increment by 1).
188
284
3. You can now `Generate release notes` : it will add all the PR infos since the last release. \
0 commit comments