myrentokil-components-library 1.0.331 → 1.0.366
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 +65 -0
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -165,6 +165,71 @@ generated by Styled Components during snapshot testing. It ensures that the
|
|
|
165
165
|
class names in snapshots remain consistent, regardless of the test run
|
|
166
166
|
environment.
|
|
167
167
|
|
|
168
|
+
## Components structure
|
|
169
|
+
|
|
170
|
+
### Atoms
|
|
171
|
+
|
|
172
|
+
Atoms are the smallest UI components, representing individual elements with no dependencies on other components.
|
|
173
|
+
|
|
174
|
+
- Button
|
|
175
|
+
- Icon
|
|
176
|
+
|
|
177
|
+
### Molecules
|
|
178
|
+
|
|
179
|
+
Molecules are simple UI components composed of atoms, forming more complex structures.
|
|
180
|
+
|
|
181
|
+
- DropdownList
|
|
182
|
+
|
|
183
|
+
### Organisms
|
|
184
|
+
|
|
185
|
+
Organisms are complex UI components composed of molecules and/or atoms, representing larger sections of a user interface.
|
|
186
|
+
|
|
187
|
+
- Navbar
|
|
188
|
+
|
|
189
|
+
## Module Federation - Micro Frontend
|
|
190
|
+
|
|
191
|
+
Our components library can be exported using module federation structure to use the components in multiple repositories at the same time. This is a great advantage for many reasons, we can control all of them following the design system, we can ensure that this is the source of truth around all the platforms. and we will reduce the amount of work for the future implementations.
|
|
192
|
+
|
|
193
|
+
In case we want to export a component you have to:
|
|
194
|
+
- Create the component (follow the instructions above)
|
|
195
|
+
- Include the component into webpack.config.js inside "exposes"
|
|
196
|
+
- Run npm run build:mf
|
|
197
|
+
- Run the container app, check if module federation config is ok.
|
|
198
|
+
- Import your component there. This is just an example:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
// webpack.config.js
|
|
202
|
+
const { dependencies } = require('./package.json');
|
|
203
|
+
|
|
204
|
+
module.exports = {
|
|
205
|
+
name: 'remote',
|
|
206
|
+
remotes: {
|
|
207
|
+
componentsLibrary: "componentsLibrary@http://localhost:3002/remoteEntry.js"
|
|
208
|
+
},
|
|
209
|
+
filename: 'remoteEntry.js',
|
|
210
|
+
shared: {
|
|
211
|
+
'react': {
|
|
212
|
+
singleton: true,
|
|
213
|
+
requiredVersion: dependencies['react'],
|
|
214
|
+
},
|
|
215
|
+
'react-dom': {
|
|
216
|
+
singleton: true,
|
|
217
|
+
requiredVersion: dependencies['react-dom'],
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
// index.tsx or In your page
|
|
224
|
+
import React, { Suspense, lazy } from 'react';
|
|
225
|
+
const Chip = lazy(() => import('componentsLibrary/Chip'));
|
|
226
|
+
|
|
227
|
+
// Implementation
|
|
228
|
+
<Suspense fallback="h1">
|
|
229
|
+
<Chip variant="primary" text="text" />
|
|
230
|
+
</Suspense>
|
|
231
|
+
```
|
|
232
|
+
|
|
168
233
|
## Useful Links
|
|
169
234
|
|
|
170
235
|
- [React Testing Library Documentation](https://testing-library.com/docs/react-testing-library/intro/)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "myrentokil-components-library",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.366",
|
|
4
4
|
"description": "myRentokil shared components library",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -12,7 +12,10 @@
|
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
+
"start": "node server.js",
|
|
15
16
|
"rollup": "rollup -c",
|
|
17
|
+
"build:mf": "rm -rf dist/ && prettier --write src/ && npm run build:module-federation && storybook build",
|
|
18
|
+
"build:module-federation": "webpack --config webpack.config.js",
|
|
16
19
|
"build": "rm -rf dist/ && prettier --write src/ && rollup -c && storybook build",
|
|
17
20
|
"build:esm": "tsc --module CommonJS --outDir dist/esm",
|
|
18
21
|
"build:cjs": "tsc --module CommonJS --outDir dist/cjs",
|
|
@@ -38,6 +41,7 @@
|
|
|
38
41
|
"@storybook/addon-interactions": "^7.0.24",
|
|
39
42
|
"@storybook/addon-links": "^7.0.24",
|
|
40
43
|
"@storybook/blocks": "^7.0.24",
|
|
44
|
+
"@storybook/client-api": "^7.6.16",
|
|
41
45
|
"@storybook/react": "^7.0.24",
|
|
42
46
|
"@storybook/react-webpack5": "^7.0.24",
|
|
43
47
|
"@storybook/testing-library": "^0.0.14-next.2",
|
|
@@ -54,6 +58,7 @@
|
|
|
54
58
|
"chromatic": "^7.4.0",
|
|
55
59
|
"eslint": "^8.46.0",
|
|
56
60
|
"eslint-plugin-react": "^7.33.1",
|
|
61
|
+
"express": "^4.18.2",
|
|
57
62
|
"file-loader": "^6.2.0",
|
|
58
63
|
"jest": "^29.5.0",
|
|
59
64
|
"jest-environment-jsdom": "^29.5.0",
|
|
@@ -68,7 +73,9 @@
|
|
|
68
73
|
"storybook": "^7.0.24",
|
|
69
74
|
"styled-components": "^5.3.9",
|
|
70
75
|
"ts-jest": "^29.1.1",
|
|
71
|
-
"
|
|
76
|
+
"ts-loader": "^9.5.1",
|
|
77
|
+
"typescript": "^4.4.4",
|
|
78
|
+
"webpack-cli": "^5.1.4"
|
|
72
79
|
},
|
|
73
80
|
"peerDependencies": {
|
|
74
81
|
"react": "^18.0.0",
|