Skip to content

Commit 2680821

Browse files
improve dev section
1 parent 5a83931 commit 2680821

File tree

1 file changed

+119
-22
lines changed

1 file changed

+119
-22
lines changed

README.md

+119-22
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ Core-UI is a component library containing all components, layouts, icons and the
1010

1111
- Add ```@scality/core-ui``` in the ```package.json```'s dependencies of your project.
1212

13-
```json
14-
"@scality/core-ui": "github:scality/core-ui#0.113.0",
15-
```
13+
```json
14+
"@scality/core-ui": "github:scality/core-ui#0.114.0",
15+
```
1616

17-
- ```@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.
1818

1919
```json
2020
"@fortawesome/fontawesome-free": "^5.10.2",
@@ -128,35 +128,90 @@ export type CoreUITheme = {
128128

129129
This project is built with [React](https://react.dev/) and [TypeScript](https://www.typescriptlang.org/), and styled with [styled-components](https://styled-components.com/).
130130

131-
Project structure :
131+
To start contributing to core-ui, clone the repository :
132+
133+
```sh
134+
git clone [email protected]:scality/core-ui.git
135+
```
136+
137+
then install the dependancies :
138+
139+
```sh
140+
npm install
141+
```
142+
143+
### Create a new branch
144+
145+
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 :
132165

133166
```text
134167
- src/
135168
- lib/
136169
- components/
137-
- MyComponent/
138-
- MyComponent.component.tsx
139-
- MyComponent.test.tsx
170+
- example/
171+
- Example.component.tsx
172+
- Example.test.tsx
140173
- stories/
141-
- MyComponent/
142-
- mycomponent.stories.tsx
143-
- mycomponent.guideline.mdx
174+
- example/
175+
- example.stories.tsx
176+
- example.guideline.mdx
144177
```
145178

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 :
147187

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 :
188+
```jsx
189+
// in stories/example/example.stories.tsx
190+
import type { Meta, StoryObj } from '@storybook/react';
191+
import { Example } from '../src/lib/components/example/Example.component.tsx';
192+
193+
const meta: Meta<typeof Example> = {
194+
component: Example,
195+
};
196+
197+
export default meta;
198+
type Story = StoryObj<typeof Example>;
199+
200+
export const Default: Story = {
201+
render: () => <Example />,
202+
};
203+
204+
```
205+
206+
then launch storybook :
150207

151208
```sh
152209
npm run storybook
153210
```
154211

155212
Storybook will be launched on `http://localhost:3000`.
156213

157-
After creating or updating a component, make sure to lint, test and document your code :
158-
159-
#### Lint
214+
### Lint
160215

161216
To make sure your code is correctly lint, run :
162217

@@ -166,28 +221,70 @@ npm run lint
166221

167222
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).
168223

169-
#### Test
224+
### Test
170225

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 :
172229

173230
```sh
174231
npm run test
175232
```
176233

177-
#### Documentation
234+
or run a specific test with :
235+
236+
```sh
237+
npm run test Example.test.tsx
238+
```
239+
240+
### Documentation
178241

179242
Core-UI uses [storybook](https://storybook.js.org/) for its documentation. \
180243
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`
181276

182-
### Release process
277+
### Release
183278

279+
After merging one or more PR in Core-UI, it is possible to plublish a new release.
184280
In the Core-UI repo, follow these steps :
185281

186-
1. Click on `Releases` then `Draft a new release`
282+
1. Go on `Releases` then `Draft a new release`
187283
2. In the select menu `Choose a tag` : Create a new tag (the current tag increment by 1).
188284
3. You can now `Generate release notes` : it will add all the PR infos since the last release. \
189285
You can add details if necessary.
190286
4. `Publish release`
287+
5. It will create a PR that need to be approved.
191288

192289
### Build
193290

0 commit comments

Comments
 (0)