@nuskin/nextgen-header 1.0.0-library-setup.1 → 1.1.0
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/package-dist/2630a3e3eab21c607e21.svg +14 -0
- package/package-dist/295183786cd8a1389865.woff +0 -0
- package/package-dist/a4e97f5a2a64f0ab1323.eot +0 -0
- package/package-dist/c94f7671dcc99dce43e2.ttf +0 -0
- package/package-dist/fb6f3c230cb846e25247.gif +0 -0
- package/package-dist/index.css +347 -19
- package/package-dist/index.css.map +1 -1
- package/package-dist/index.d.ts +66 -41
- package/package-dist/index.js +69516 -245
- package/package-dist/index.js.map +1 -1
- package/package-dist/index.mjs +69220 -208
- package/package-dist/index.mjs.map +1 -1
- package/package.json +10 -12
- package/readme.md +40 -18
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuskin/nextgen-header",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Header micro-frontend and npm component library",
|
|
5
5
|
"main": "package-dist/index.js",
|
|
6
6
|
"module": "package-dist/index.mjs",
|
|
7
7
|
"types": "package-dist/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"start": "nodemon --watch src --ext js,jsx,css --delay 2 --exec \"yarn
|
|
10
|
-
"
|
|
11
|
-
"build": "cross-env CMS_ENV=
|
|
12
|
-
"build-
|
|
13
|
-
"build-test": "cross-env CMS_ENV=test NODE_ENV=production yarn build:server:dev && cross-env CMS_ENV=test NODE_ENV=production yarn build:client:dev",
|
|
9
|
+
"start": "nodemon --watch src --ext js,jsx,css --delay 2 --exec \"yarn build && node server-launcher.js\"",
|
|
10
|
+
"build": "cross-env CMS_ENV=local yarn build:server:dev && yarn build:client:dev",
|
|
11
|
+
"build-dev": "cross-env CMS_ENV=dev yarn build:server:dev && cross-env CMS_ENV=dev yarn build:client:dev",
|
|
12
|
+
"build-test": "cross-env CMS_ENV=test yarn build:server:dev && cross-env CMS_ENV=test yarn build:client:dev",
|
|
14
13
|
"build-prod": "cross-env CMS_ENV=prod NODE_ENV=production yarn build:server:prod && cross-env CMS_ENV=prod NODE_ENV=production yarn build:client:prod",
|
|
15
14
|
"build:client:dev": "rimraf --glob dist/*.js dist/*.js.map dist/loadable-stats.json dist/index.html && yarn webpack --mode development --progress --config config/webpack.client.js",
|
|
16
15
|
"build:client:prod": "rimraf --glob dist/*.js dist/*.js.map dist/loadable-stats.json dist/index.html && yarn webpack --mode production --progress --config config/webpack.client.js",
|
|
@@ -19,8 +18,7 @@
|
|
|
19
18
|
"test": "jest",
|
|
20
19
|
"integration-test": "echo 'Integration test not yet implemented'",
|
|
21
20
|
"lint": "eslint src/ --ext .js,.jsx",
|
|
22
|
-
"build:package": "rimraf package-dist &&
|
|
23
|
-
"prepublishOnly": "yarn build:package"
|
|
21
|
+
"build:package": "rimraf package-dist && webpack --mode production --config config/webpack.library.js && shx cp src/library/index.d.ts package-dist/index.d.ts"
|
|
24
22
|
},
|
|
25
23
|
"keywords": [
|
|
26
24
|
"react",
|
|
@@ -58,8 +56,7 @@
|
|
|
58
56
|
"contentstack": "^3.26.0",
|
|
59
57
|
"prop-types": "^15.8.0",
|
|
60
58
|
"react": "^18.2.0",
|
|
61
|
-
"react-dom": "^18.2.0"
|
|
62
|
-
"react-router-dom": "^7.7.0"
|
|
59
|
+
"react-dom": "^18.2.0"
|
|
63
60
|
},
|
|
64
61
|
"engines": {
|
|
65
62
|
"node": ">=24.0.0"
|
|
@@ -73,6 +70,8 @@
|
|
|
73
70
|
"@loadable/babel-plugin": "^5.13.2",
|
|
74
71
|
"@loadable/component": "^5.16.4",
|
|
75
72
|
"@loadable/server": "^5.16.5",
|
|
73
|
+
"@nuskin/foundation-theme": "1.8.0",
|
|
74
|
+
"@nuskin/foundation-ui-components": "^2.2.0",
|
|
76
75
|
"contentstack": "^3.26.2",
|
|
77
76
|
"core-js": "^3.39.0",
|
|
78
77
|
"cross-env": "7.0.3",
|
|
@@ -90,7 +89,6 @@
|
|
|
90
89
|
"react": "^18.2.0",
|
|
91
90
|
"react-dom": "^18.2.0",
|
|
92
91
|
"react-gtm-module": "^2.0.11",
|
|
93
|
-
"react-router-dom": "^7.7.1",
|
|
94
92
|
"regenerator-runtime": "0.14.1"
|
|
95
93
|
},
|
|
96
94
|
"devDependencies": {
|
|
@@ -115,12 +113,12 @@
|
|
|
115
113
|
"file-loader": "^6.2.0",
|
|
116
114
|
"html-webpack-plugin": "^5.5.0",
|
|
117
115
|
"identity-obj-proxy": "^3.0.0",
|
|
116
|
+
"mini-css-extract-plugin": "^2.9.2",
|
|
118
117
|
"nodemon": "^3.1.14",
|
|
119
118
|
"process": "^0.11.10",
|
|
120
119
|
"rimraf": "5.0.8",
|
|
121
120
|
"shx": "^0.4.0",
|
|
122
121
|
"style-loader": "^3.3.0",
|
|
123
|
-
"tsup": "^8.5.1",
|
|
124
122
|
"typescript": "^5.9.3",
|
|
125
123
|
"webpack": "^5.88.0",
|
|
126
124
|
"webpack-cli": "^5.1.0",
|
package/readme.md
CHANGED
|
@@ -7,6 +7,22 @@ This repository produces **two** deployables:
|
|
|
7
7
|
|
|
8
8
|
The UI is intentionally minimal (`HeaderPlaceholder`). Replace it when navigation, Contentstack types, and analytics are defined.
|
|
9
9
|
|
|
10
|
+
## Domain language (header UI)
|
|
11
|
+
|
|
12
|
+
Shared vocabulary for Nu Skin header work—use these names in code, docs, and Contentstack discussions so everyone means the same region of the UI.
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
| Term | Description |
|
|
17
|
+
|------|-------------|
|
|
18
|
+
| **Logo** | Brand mark (e.g. NU SKIN), top-left. |
|
|
19
|
+
| **Utility bar** | Top-right strip: currency / language, Nu Skin Rewards, account (Sign Up / Sign In), cart with badge. |
|
|
20
|
+
| **Search bar** | Product search field (e.g. “Product Search”). Kept **separate from the utility bar** so future features can be added between or around them without coupling. |
|
|
21
|
+
| **Top navigation** | Primary horizontal category row under the logo (e.g. Devices, Beauty & Skincare, Health & Wellness). |
|
|
22
|
+
| **Jump to** | Left column in the expanded mega-menu: quick links (e.g. Most Popular, Science, Kits & Bundles). |
|
|
23
|
+
| **Categories** | Horizontal row inside the mega-menu that expresses the active hierarchy (e.g. Skincare → Concerns → Key ingredients). |
|
|
24
|
+
| **Sub categories** | Vertical link lists under each **Categories** heading (e.g. Anti-Aging, Lines & Wrinkles, Dry Skin under Concerns). |
|
|
25
|
+
|
|
10
26
|
## Prerequisites
|
|
11
27
|
|
|
12
28
|
- **Node.js 24+** (see `engines` in `package.json` and `.nvmrc` for `nvm` / `fnm`)
|
|
@@ -21,22 +37,27 @@ yarn install
|
|
|
21
37
|
|
|
22
38
|
## NPM library (`@nuskin/nextgen-header`)
|
|
23
39
|
|
|
24
|
-
Install in a host application that already provides the peer dependencies (React 18, Emotion,
|
|
40
|
+
Install in a host application that already provides the peer dependencies (React 18, Emotion, Contentstack SDKs):
|
|
25
41
|
|
|
26
42
|
```bash
|
|
27
43
|
yarn add @nuskin/nextgen-header
|
|
28
44
|
```
|
|
29
45
|
|
|
46
|
+
**Public export** (see [`src/library/index.js`](src/library/index.js)):
|
|
47
|
+
|
|
48
|
+
| Export | Description |
|
|
49
|
+
|--------|-------------|
|
|
50
|
+
| **`Header`** | **`AppContainer`** styling plus **market/language** resolution (browser URL or explicit props; SSR via **`requestUrl`** in **`renderAndExtractContext`**). Renders the header placeholder inside. |
|
|
51
|
+
|
|
30
52
|
**Example**
|
|
31
53
|
|
|
32
54
|
```jsx
|
|
33
|
-
import {
|
|
34
|
-
HeaderPlaceholder,
|
|
35
|
-
Main,
|
|
36
|
-
getLocale,
|
|
37
|
-
getStackConfig,
|
|
38
|
-
} from "@nuskin/nextgen-header";
|
|
55
|
+
import { Header } from "@nuskin/nextgen-header";
|
|
39
56
|
import "@nuskin/nextgen-header/index.css";
|
|
57
|
+
|
|
58
|
+
// CSR: optional market/language; SSR: pass props or wire `requestUrl` in `renderAndExtractContext`.
|
|
59
|
+
<Header />
|
|
60
|
+
<Header market="US" language="en" />
|
|
40
61
|
```
|
|
41
62
|
|
|
42
63
|
- **Exports** are defined in [`src/library/index.js`](src/library/index.js) (barrel for the published API).
|
|
@@ -49,15 +70,17 @@ import "@nuskin/nextgen-header/index.css";
|
|
|
49
70
|
yarn build:package
|
|
50
71
|
```
|
|
51
72
|
|
|
52
|
-
**Publish** (
|
|
73
|
+
**Publish** (GitLab **release** / **pre-release** jobs run `yarn build:package` in `before_script` before publish; align with your org’s versioning and `yarn npm publish` / tags. For a local publish, run `yarn build:package` first.)
|
|
53
74
|
|
|
54
75
|
### Peer dependencies
|
|
55
76
|
|
|
56
|
-
Declared in `package.json` under `peerDependencies`: `react`, `react-dom`, `prop-types`,
|
|
77
|
+
Declared in `package.json` under `peerDependencies`: `react`, `react-dom`, `prop-types`, `@emotion/react`, `@emotion/styled`, Contentstack packages, and `contentstack`. Your app must install compatible versions.
|
|
57
78
|
|
|
58
79
|
## Environment variables
|
|
59
80
|
|
|
60
|
-
|
|
81
|
+
For the **webpack / MFE** build, dotenv files are loaded per build via `CMS_ENV` (see `package.json` scripts): `.env.local`, `.env.dev`, `.env.test`, `.env.prod`. The **npm library** does not expose these values on its public API; consumers still configure the usual `CONTENTSTACK_*` variables in their own environment so internal Contentstack helpers can run.
|
|
82
|
+
|
|
83
|
+
### MFE / webpack (`CMS_ENV`)
|
|
61
84
|
|
|
62
85
|
| Variable | Purpose |
|
|
63
86
|
|----------|---------|
|
|
@@ -65,8 +88,7 @@ Dotenv files are loaded per **webpack** build via `CMS_ENV` (see `package.json`
|
|
|
65
88
|
| `CONTENTSTACK_DELIVERY_TOKEN` | Delivery token |
|
|
66
89
|
| `CONTENTSTACK_ENVIRONMENT` | Environment name |
|
|
67
90
|
| `CONTENTSTACK_PREVIEW_TOKEN` | Preview token (Visual Builder / live preview) |
|
|
68
|
-
| `
|
|
69
|
-
| `REACT_APP_GTM_KEY_DEV` / `REACT_APP_GTM_KEY_TEST` | Optional; used by `src/utils/datalayer.js` if present |
|
|
91
|
+
| `REACT_APP_GTM_KEY` | Optional; used by `src/utils/datalayer.js` if present |
|
|
70
92
|
|
|
71
93
|
`REACT_APP_BASENAME` is injected at build time from the client webpack config (static asset path segment).
|
|
72
94
|
|
|
@@ -75,8 +97,8 @@ Dotenv files are loaded per **webpack** build via `CMS_ENV` (see `package.json`
|
|
|
75
97
|
| Command | Description |
|
|
76
98
|
|---------|-------------|
|
|
77
99
|
| `yarn start` | Rebuild and run the Express server (see `server-launcher.js`) |
|
|
78
|
-
| `yarn build` |
|
|
79
|
-
| `yarn build:package` | **Library** build to `package-dist/` (
|
|
100
|
+
| `yarn build` | Client + server **webpack** build in **development** mode with `CMS_ENV=local` (same as `build:*:dev`). Use **`yarn build-prod`** for production mode + minification. |
|
|
101
|
+
| `yarn build:package` | **Library** build to `package-dist/` via [`config/webpack.library.js`](config/webpack.library.js) (dual CJS/ESM + extracted CSS + copied `index.d.ts`); required before `npm publish` |
|
|
80
102
|
| `yarn test` | Jest + coverage |
|
|
81
103
|
| `yarn lint` | ESLint on `src/` |
|
|
82
104
|
|
|
@@ -90,15 +112,15 @@ Dotenv files are loaded per **webpack** build via `CMS_ENV` (see `package.json`
|
|
|
90
112
|
|
|
91
113
|
The host must load `remoteEntry.js` and consume the `./App` expose.
|
|
92
114
|
|
|
93
|
-
|
|
115
|
+
**Locale:** The npm **`Header`** export accepts **`market`** / **`language`** (see [`src/utils/locale.js`](src/utils/locale.js) `resolveHeaderLocale`). On **SSR**, pass them explicitly or rely on Express passing **`requestUrl`** into **`renderAndExtractContext`**. On **CSR**, they are optional; URL parsing **throws** if `window` is missing or the path is invalid. The header does not ship React Router; the host owns routing.
|
|
94
116
|
|
|
95
117
|
## Contentstack
|
|
96
118
|
|
|
97
119
|
- `src/utils/contentstack.js` — stack proxy, `getContent`, `initLivePreview`, `onEntryChange`, `isEditingMode`
|
|
98
|
-
- `src/utils/config.js` — `getStackConfig()`
|
|
99
|
-
- `src/constants.js` —
|
|
120
|
+
- `src/utils/config.js` — `getStackConfig()` returns a fixed header content type (internal to that module) and locale from the URL
|
|
121
|
+
- `src/constants.js` — Contentstack credentials from env (used by the webpack/MFE build and internally by `contentstack.js`; not exported from the npm package)
|
|
100
122
|
|
|
101
|
-
No header entry is fetched in the UI yet; wire `getContent` when the slug/UID strategy is decided.
|
|
123
|
+
The **npm library** currently exports only **`Header`** (the `Main` shell under that name); Contentstack helpers are not part of the published API yet. No header entry is fetched in the UI yet; wire `getContent` when the slug/UID strategy is decided.
|
|
102
124
|
|
|
103
125
|
## GitLab CI
|
|
104
126
|
|