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
Copy file name to clipboardExpand all lines: COLLABORATOR_GUIDE.md
+75-27
Original file line number
Diff line number
Diff line change
@@ -102,10 +102,10 @@ The Website also uses several other Open Source libraries (not limited to) liste
102
102
Locations are subject to change. (If you are someone updating these paths,
103
103
please document those changes here.)
104
104
105
-
- React Components are defined on `apps/site/components`
105
+
- React Components are defined on `apps/site/components` and `packages/ui-components`
106
106
- React Templates are defined on `apps/site/layouts`
107
-
- Global Stylesheets are declared on `apps/site/styles`
108
-
- Styles are done with [PostCSS][]
107
+
- Global Stylesheets are declared on `packages/ui-components/styles`
108
+
- Styles are done with [PostCSS][] and [Tailwind][]
109
109
- Public files are stored on `apps/site/public`
110
110
- Static Images, JavaScript files, and others are stored within `apps/site/public/static`
111
111
- Internationalisation is done on `apps/site/i18n`
@@ -126,7 +126,7 @@ please document those changes here.)
126
126
- Generation of build-time indexes such as blog data
127
127
- Multi-Purpose Scripts are stored within `apps/site/scripts`
128
128
- Such as Node.js Release Blog Post generation
129
-
- Storybook Configuration is done within `apps/site/.storybook`
129
+
- Storybook Configuration is done within `packages/ui-components/.storybook`
130
130
- We use an almost out-of-the-box Storybook Experience with a few extra customisations
131
131
132
132
### Adding new Pages
@@ -197,8 +197,6 @@ Finally, if you're unfamiliar with how to use Tailwind or how to use Tailwind wi
197
197
- We discourage the usage of any plain CSS styles and tokens, when in doubt ask for help
198
198
- We require that you define one Tailwind Token per line, just as shown on the example above, since this improves readability
199
199
- Only write CSS within CSS Modules, avoid writing CSS within JavaScript files
200
-
- We recommend creating mixins for reusable animations, effects and more
201
-
- You can create Mixins within the `apps/site/styles/mixins` folder
202
200
203
201
> \[!NOTE]\
204
202
> Tailwind is already configured for this repository. You don't need to import any Tailwind module within your CSS module.\
@@ -211,26 +209,76 @@ Finally, if you're unfamiliar with how to use Tailwind or how to use Tailwind wi
211
209
212
210
### Best practices when creating a Component
213
211
214
-
- All React Components should be placed within the `apps/site/components` folder.
215
-
- Each Component should be placed, whenever possible, within a sub-folder, which we call the "Domain" of the Component
216
-
- The domain represents where these Components belong to or where they will be used.
217
-
- For example, Components used within Article Pages or that are part of the structure of an Article or the Article Layouts,
218
-
should be placed within `apps/site/components/Article`
219
-
- Each component should have its folder with the name of the Component
220
-
- The structure of each component folder follows the following template:
212
+
-**All React components** should be placed within either `@node-core/ui-components` (for reusable components) or `apps/site/components` (for website-specific components).
213
+
-**Generic UI components** that are not tied to the website should be placed in the `@node-core/ui-components` package.
214
+
- These components should be **framework-agnostic** and must not rely on Next.js-specific features such as `usePathname()` or `useTranslations()`.
215
+
- If a component previously relied on Next.js, it should now accept these values as **props** instead.
216
+
-**Website-specific components** that rely on Next.js or are tied to the website should remain in `apps/site/components`.
217
+
- These components can use Next.js-specific hooks, API calls, or configurations.
218
+
- When using a generic UI component that requires Next.js functionality, pass it as a **prop** instead of modifying the component.
219
+
-**Each component** should be placed within a sub-folder, which we call the **"Domain"** of the component.
220
+
- The domain represents where the component belongs or where it will be used.
221
+
- For example, components used within article pages or related to the structure of an article should be placed within `@node-core/ui-components/Common/Article`.
222
+
-**Each component should have its own folder** with the name of the component.
223
+
- The structure of each component folder follows this template:
224
+
221
225
```text
222
226
- ComponentName
223
-
- index.tsx // the component itself
224
-
- index.module.css // all styles of the component are placed there
- __tests__// component tests (such as unit tests, etc)
227
-
- index.test.mjs // unit tests should be done in ESM and not TypeScript
227
+
- index.tsx // The component itself
228
+
- index.module.css // Component-specific styles
229
+
- index.stories.tsx // Storybook stories (only for @node-core/ui-components)
230
+
- __tests__/ // Component tests (such as unit tests, etc.)
231
+
- index.test.mjs // Unit tests should be done in ESM, not TypeScript
228
232
```
229
-
- React Hooks belonging to a single Component should be placed within the Component's folder
230
-
- If the Hook as a wider usability or can be used by other components, it should be placed in the root `hooks` folder.
231
-
- If the Component has "sub-components" they should follow the same philosophy as the Component itself.
232
-
- For example, if the Component `ComponentName` has a sub-component called `SubComponentName`,
233
-
then it should be placed within `ComponentName/SubComponentName`
233
+
234
+
-**If a component requires Next.js features, it should be wrapped within `apps/site`** rather than being modified directly in `@node-core/ui-components`.
235
+
236
+
- Example: A component that requires `usePathname()` should **not** call it directly inside `@node-core/ui-components`. Instead:
237
+
- The **base component** should accept `pathname` as a prop.
238
+
- The **wrapper component** in `apps/site` should call `usePathname()` and pass it to the base component.
@@ -272,7 +320,7 @@ To add a new download installation method, follow these steps:
272
320
273
321
- Add a new entry to the `INSTALL_METHODS` array.
274
322
- Each entry should have the following properties:
275
-
-`iconImage`: The React component of the icon image for the installation method. This should be an SVG component stored within `apps/site/components/Icons/InstallationMethod` and must follow the other icon component references (being a `FC` supporting `SVGSVGElement` props).
323
+
- `iconImage`: The React component of the icon image for the installation method. This should be an SVG component stored within `@node-core/ui-components/Icons/InstallationMethod` and must follow the other icon component references (being a `FC` supporting `SVGSVGElement` props).
276
324
- Don't forget to add it on the `index.tsx` file from the `InstallationMethod` folder.
277
325
- `recommended`: A boolean indicating if this method is recommended. This property is available only for official installation methods.
278
326
- `url`: The URL for the installation method.
@@ -379,7 +427,7 @@ Each new feature or bug fix should be accompanied by a unit test (when deemed va
379
427
We use [Jest][] as our test runner and [React Testing Library][] for our React unit tests.
380
428
381
429
We also use [Storybook][] to document our components.
382
-
Each component should have a storybook story that documents the component's usage.
430
+
Components within `packages/ui-components` should have a storybook story that documents the component's usage.
383
431
384
432
Visual Regression Testing is automatically done via [Chromatic](https://www.chromatic.com/) to ensure that Components are rendered correctly.
385
433
@@ -407,7 +455,7 @@ They also allow Developers to preview Components and be able to test them manual
0 commit comments