weg-shared-layout 0.0.46 → 0.0.47
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/dist/collection/types/menus-data.js +1 -0
- package/dist/collection/utils/menus.js +39 -0
- package/dist/test-utils/layout-fixtures.js +48 -0
- package/dist/types/Users/rakin/Documents/WEG/repos/weg-shared-layout/.stencil/test-utils/layout-fixtures.d.ts +8 -0
- package/dist/types/types/layout-data.d.ts +2 -1
- package/dist/types/types/menus-data.d.ts +37 -0
- package/dist/types/utils/menus.d.ts +18 -0
- package/docs/README.md +54 -51
- package/docs/angular.md +440 -451
- package/docs/nextjs.md +313 -312
- package/docs/publishing.md +65 -65
- package/docs/react.md +291 -287
- package/docs/vanilla.md +159 -155
- package/package.json +93 -81
- package/readme.md +121 -108
- package/src/assets/weg21-bootstrap.json +12 -0
- package/src/assets/weg21-menus.json +19 -0
- package/src/types/menus-data.ts +44 -0
- package/src/utils/menus.ts +65 -0
- package/src/assets/dummy-data.json +0 -221
package/docs/react.md
CHANGED
|
@@ -1,287 +1,291 @@
|
|
|
1
|
-
# React (SPA)
|
|
2
|
-
|
|
3
|
-
Guide for **client-rendered** React apps (Vite, Create React App, etc.). If you use **Next.js App Router**, see **[Next.js](./nextjs.md)** — SSR and Server Components require a different integration.
|
|
4
|
-
|
|
5
|
-
## Components
|
|
6
|
-
|
|
7
|
-
| Tag | Purpose |
|
|
8
|
-
| --- | --- |
|
|
9
|
-
| `<weg-header>` | Site header — bundled logo, CMS nav (signed out), built-in nav (signed in), Sign in / Manage Account / Sign out |
|
|
10
|
-
| `<weg-footer>` | Site footer — social links, menu, credits, copyright |
|
|
11
|
-
|
|
12
|
-
Both are **presentational** [Stencil](https://stenciljs.com/) Web Components. They **do not fetch data** — your app passes a **`layout`** payload
|
|
13
|
-
|
|
14
|
-
`<weg-header>` additionally accepts **`signed-in`**, **`user-name`**, **`account-base-url`**, **`current-path`**, and emits **`wegAuthClick`**.
|
|
15
|
-
|
|
16
|
-
## Requirements
|
|
17
|
-
|
|
18
|
-
| Requirement | Notes |
|
|
19
|
-
| --- | --- |
|
|
20
|
-
| **React 19+** | React 19 maps custom-element props to DOM **properties** when possible. Older React often sets props as string **attributes**, which breaks object payloads. |
|
|
21
|
-
| **Bundler** | Must resolve `node_modules` ESM/CJS from `weg-shared-layout`. |
|
|
22
|
-
| **TypeScript (optional)** | `resolveJsonModule` + `moduleResolution` `bundler` / `node16` for JSON/subpath imports; module augmentation below. |
|
|
23
|
-
|
|
24
|
-
## Install
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npm i weg-shared-layout
|
|
28
|
-
# or
|
|
29
|
-
pnpm add weg-shared-layout
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## 1. Register custom elements (once)
|
|
33
|
-
|
|
34
|
-
Call `defineCustomElements()` **once** before the first render — typically in `main.tsx` / `index.tsx`:
|
|
35
|
-
|
|
36
|
-
```ts
|
|
37
|
-
import { defineCustomElements } from 'weg-shared-layout/loader';
|
|
38
|
-
|
|
39
|
-
defineCustomElements();
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
**Alternative** — side-effect imports per tag (requires modern `moduleResolution`; see [angular.md § Troubleshooting](./angular.md#troubleshooting)):
|
|
43
|
-
|
|
44
|
-
```ts
|
|
45
|
-
import 'weg-shared-layout/weg-header';
|
|
46
|
-
import 'weg-shared-layout/weg-footer';
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## 2. Layout shell
|
|
50
|
-
|
|
51
|
-
### Recommended: pass `layout` as an object (React 19+)
|
|
52
|
-
|
|
53
|
-
```tsx
|
|
54
|
-
import 'weg-shared-layout/weg-header';
|
|
55
|
-
import 'weg-shared-layout/weg-footer';
|
|
56
|
-
import
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<weg-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
import {
|
|
89
|
-
import '
|
|
90
|
-
import
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
event.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
{
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
|
124
|
-
|
|
|
125
|
-
| `
|
|
126
|
-
| `
|
|
127
|
-
| `
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
|
160
|
-
|
|
|
161
|
-
|
|
|
162
|
-
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
import '
|
|
181
|
-
import
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
})
|
|
200
|
-
.
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
|
275
|
-
|
|
|
276
|
-
|
|
|
277
|
-
|
|
|
278
|
-
|
|
|
279
|
-
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
- **[
|
|
1
|
+
# React (SPA)
|
|
2
|
+
|
|
3
|
+
Guide for **client-rendered** React apps (Vite, Create React App, etc.). If you use **Next.js App Router**, see **[Next.js](./nextjs.md)** — SSR and Server Components require a different integration.
|
|
4
|
+
|
|
5
|
+
## Components
|
|
6
|
+
|
|
7
|
+
| Tag | Purpose |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| `<weg-header>` | Site header — bundled logo, CMS nav (signed out), built-in nav (signed in), Sign in / Manage Account / Sign out |
|
|
10
|
+
| `<weg-footer>` | Site footer — social links, menu, credits, copyright |
|
|
11
|
+
|
|
12
|
+
Both are **presentational** [Stencil](https://stenciljs.com/) Web Components. They **do not fetch data** — your app passes a **`layout`** payload from the WEG CMS WEG21 API (via [`fetchWeg21Layout`](../src/utils/menus.ts)) or [`weg21-bootstrap.json`](../src/assets/weg21-bootstrap.json) and [`weg21-menus.json`](../src/assets/weg21-menus.json) as offline fallback.
|
|
13
|
+
|
|
14
|
+
`<weg-header>` additionally accepts **`signed-in`**, **`user-name`**, **`account-base-url`**, **`current-path`**, and emits **`wegAuthClick`**.
|
|
15
|
+
|
|
16
|
+
## Requirements
|
|
17
|
+
|
|
18
|
+
| Requirement | Notes |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
| **React 19+** | React 19 maps custom-element props to DOM **properties** when possible. Older React often sets props as string **attributes**, which breaks object payloads. |
|
|
21
|
+
| **Bundler** | Must resolve `node_modules` ESM/CJS from `weg-shared-layout`. |
|
|
22
|
+
| **TypeScript (optional)** | `resolveJsonModule` + `moduleResolution` `bundler` / `node16` for JSON/subpath imports; module augmentation below. |
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm i weg-shared-layout
|
|
28
|
+
# or
|
|
29
|
+
pnpm add weg-shared-layout
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 1. Register custom elements (once)
|
|
33
|
+
|
|
34
|
+
Call `defineCustomElements()` **once** before the first render — typically in `main.tsx` / `index.tsx`:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { defineCustomElements } from 'weg-shared-layout/loader';
|
|
38
|
+
|
|
39
|
+
defineCustomElements();
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Alternative** — side-effect imports per tag (requires modern `moduleResolution`; see [angular.md § Troubleshooting](./angular.md#troubleshooting)):
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import 'weg-shared-layout/weg-header';
|
|
46
|
+
import 'weg-shared-layout/weg-footer';
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 2. Layout shell
|
|
50
|
+
|
|
51
|
+
### Recommended: pass `layout` as an object (React 19+)
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import 'weg-shared-layout/weg-header';
|
|
55
|
+
import 'weg-shared-layout/weg-footer';
|
|
56
|
+
import { dummyWeg21LayoutData } from 'weg-shared-layout/menus';
|
|
57
|
+
const layout = dummyWeg21LayoutData();
|
|
58
|
+
|
|
59
|
+
export function SiteLayout({ children }: { children: React.ReactNode }) {
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
<weg-header layout={layout} />
|
|
63
|
+
{children}
|
|
64
|
+
<weg-footer layout={layout} />
|
|
65
|
+
</>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Fallback: `JSON.stringify` (React 18 or empty components)
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
<weg-header layout={JSON.stringify(layout)} />
|
|
74
|
+
<weg-footer layout={JSON.stringify(layout)} />
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 3. Header auth
|
|
78
|
+
|
|
79
|
+
Sign-in is a normal `header.menu` link — add it in your CMS like Register. The header recognizes **Sign in** by label or login URL and navigates to `href`.
|
|
80
|
+
|
|
81
|
+
### Signed in
|
|
82
|
+
|
|
83
|
+
Set **`signed-in`** and optionally **`user-name`**. The component **ignores CMS nav** and shows built-in links: Find a job, Dashboard, Manage Account, Sign out. Pass **`account-base-url`** when account links should use a non-production portal.
|
|
84
|
+
|
|
85
|
+
Handle **`wegAuthClick`** for sign-out (call your logout API, then redirect):
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { useCallback, useState } from 'react';
|
|
89
|
+
import { useLocation } from 'react-router-dom';
|
|
90
|
+
import 'weg-shared-layout/weg-header';
|
|
91
|
+
import { dummyWeg21LayoutData } from 'weg-shared-layout/menus';
|
|
92
|
+
const layout = dummyWeg21LayoutData();
|
|
93
|
+
|
|
94
|
+
export function SiteHeader() {
|
|
95
|
+
const { pathname, search } = useLocation();
|
|
96
|
+
const currentPath = search ? `${pathname}${search}` : pathname;
|
|
97
|
+
const [signedIn, setSignedIn] = useState(false);
|
|
98
|
+
const userName = signedIn ? 'Alex' : undefined;
|
|
99
|
+
|
|
100
|
+
const onAuthClick = useCallback(async (event: CustomEvent<{ action: 'sign-in' | 'sign-out' }>) => {
|
|
101
|
+
if (event.detail.action !== 'sign-out') return;
|
|
102
|
+
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
await logout();
|
|
105
|
+
setSignedIn(false);
|
|
106
|
+
window.location.assign('/');
|
|
107
|
+
}, []);
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<weg-header
|
|
111
|
+
layout={layout}
|
|
112
|
+
signedIn={signedIn}
|
|
113
|
+
currentPath={currentPath}
|
|
114
|
+
{...(userName ? { userName } : {})}
|
|
115
|
+
onWegAuthClick={onAuthClick}
|
|
116
|
+
/>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Without React Router, pass `window.location.pathname` (+ `search` when needed) or your router’s equivalent.
|
|
122
|
+
|
|
123
|
+
| Prop / event | Purpose |
|
|
124
|
+
| --- | --- |
|
|
125
|
+
| `signedIn={boolean}` | Switches to signed-in nav when `true` |
|
|
126
|
+
| `userName={string}` | First name beside profile icon on Manage Account |
|
|
127
|
+
| `accountBaseUrl={string}` | Account portal origin for signed-in links (optional) |
|
|
128
|
+
| `currentPath={string}` | Current path — highlights active nav (e.g. `/career-advice/foo`) |
|
|
129
|
+
| `onWegAuthClick` | Required for sign-out — call logout API and redirect; sign-in follows link `href` |
|
|
130
|
+
|
|
131
|
+
**Ref fallback for the event** (if `onWegAuthClick` does not bind in your React version):
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
import { useEffect, useRef } from 'react';
|
|
135
|
+
|
|
136
|
+
const ref = useRef<HTMLWegHeaderElement>(null);
|
|
137
|
+
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
const el = ref.current;
|
|
140
|
+
if (!el) return;
|
|
141
|
+
|
|
142
|
+
const handler = (event: Event) => {
|
|
143
|
+
const e = event as CustomEvent<{ action: 'sign-in' | 'sign-out' }>;
|
|
144
|
+
e.preventDefault();
|
|
145
|
+
// ...
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
el.addEventListener('wegAuthClick', handler);
|
|
149
|
+
return () => el.removeEventListener('wegAuthClick', handler);
|
|
150
|
+
}, []);
|
|
151
|
+
|
|
152
|
+
return <weg-header ref={ref} layout={layout} signedIn={signedIn} userName="Alex" />;
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## 4. Nav active state
|
|
156
|
+
|
|
157
|
+
Pass **`currentPath`** so the header highlights the current page. Use your router’s pathname; include the query string when matching dropdown links with search params (e.g. `/search?category=graduates`).
|
|
158
|
+
|
|
159
|
+
| Link type | Match rule |
|
|
160
|
+
| --- | --- |
|
|
161
|
+
| Flat nav link | Prefix — `/career-advice` matches `/career-advice/foo` |
|
|
162
|
+
| Dropdown child | Exact pathname (+ query when href includes `?`) |
|
|
163
|
+
| Dropdown parent | Active background when any child matches |
|
|
164
|
+
| Sign in / Sign out | Never highlighted |
|
|
165
|
+
|
|
166
|
+
Active links use **`weg-purple-200`** (`#CDCFF8`). Omit `currentPath` to disable active styling.
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
import { useLocation } from 'react-router-dom';
|
|
170
|
+
|
|
171
|
+
const { pathname, search } = useLocation();
|
|
172
|
+
const currentPath = search ? `${pathname}${search}` : pathname;
|
|
173
|
+
|
|
174
|
+
<weg-header layout={layout} currentPath={currentPath} />
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## 5. Production: fetch layout from your API
|
|
178
|
+
|
|
179
|
+
```tsx
|
|
180
|
+
import { useEffect, useState } from 'react';
|
|
181
|
+
import 'weg-shared-layout/weg-header';
|
|
182
|
+
import 'weg-shared-layout/weg-footer';
|
|
183
|
+
import { dummyWeg21LayoutData } from 'weg-shared-layout/menus';
|
|
184
|
+
const layoutFixture = dummyWeg21LayoutData();
|
|
185
|
+
|
|
186
|
+
type LayoutData = typeof layoutFixture;
|
|
187
|
+
|
|
188
|
+
const WEG21_API = 'https://warwickemploymentgroup.com/api/v1/weg21';
|
|
189
|
+
|
|
190
|
+
export function SiteLayout({ children }: { children: React.ReactNode }) {
|
|
191
|
+
const [layout, setLayout] = useState<LayoutData | null>(null);
|
|
192
|
+
|
|
193
|
+
useEffect(() => {
|
|
194
|
+
let cancelled = false;
|
|
195
|
+
fetch(LAYOUT_URL)
|
|
196
|
+
.then((res) => {
|
|
197
|
+
if (!res.ok) throw new Error(`layout fetch failed: ${res.status}`);
|
|
198
|
+
return res.json() as Promise<LayoutData>;
|
|
199
|
+
})
|
|
200
|
+
.then((data) => {
|
|
201
|
+
if (!cancelled) setLayout(data);
|
|
202
|
+
})
|
|
203
|
+
.catch(console.error);
|
|
204
|
+
return () => {
|
|
205
|
+
cancelled = true;
|
|
206
|
+
};
|
|
207
|
+
}, []);
|
|
208
|
+
|
|
209
|
+
if (!layout) return null;
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<>
|
|
213
|
+
<weg-header layout={layout} />
|
|
214
|
+
{children}
|
|
215
|
+
<weg-footer layout={layout} />
|
|
216
|
+
</>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Keep the mapped object shape aligned with `menusToLayoutData` output.
|
|
222
|
+
|
|
223
|
+
## TypeScript
|
|
224
|
+
|
|
225
|
+
### JSON + package subpaths
|
|
226
|
+
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"compilerOptions": {
|
|
230
|
+
"resolveJsonModule": true,
|
|
231
|
+
"moduleResolution": "bundler"
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
```ts
|
|
237
|
+
import { dummyWeg21LayoutData } from 'weg-shared-layout/menus';
|
|
238
|
+
const layoutFixture = dummyWeg21LayoutData();
|
|
239
|
+
export type LayoutData = typeof layoutFixture;
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Or types only: `import type { LayoutData } from 'weg-shared-layout/layout-data'`.
|
|
243
|
+
|
|
244
|
+
### JSX module augmentation
|
|
245
|
+
|
|
246
|
+
Add once (e.g. `src/types/weg-shared-layout-jsx.d.ts`):
|
|
247
|
+
|
|
248
|
+
```ts
|
|
249
|
+
import type { JSX as WegSharedLayoutJSX } from 'weg-shared-layout';
|
|
250
|
+
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
|
|
251
|
+
|
|
252
|
+
declare module 'react' {
|
|
253
|
+
namespace JSX {
|
|
254
|
+
interface IntrinsicElements extends WegSharedLayoutJSX.IntrinsicElements {
|
|
255
|
+
'weg-header': WegSharedLayoutJSX.IntrinsicElements['weg-header'] &
|
|
256
|
+
DetailedHTMLProps<HTMLAttributes<HTMLWegHeaderElement>, HTMLWegHeaderElement>;
|
|
257
|
+
'weg-footer': WegSharedLayoutJSX.IntrinsicElements['weg-footer'] &
|
|
258
|
+
DetailedHTMLProps<HTMLAttributes<HTMLWegFooterElement>, HTMLWegFooterElement>;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## `layout` prop vs attribute
|
|
265
|
+
|
|
266
|
+
| How data is set | Works with object? |
|
|
267
|
+
| --- | --- |
|
|
268
|
+
| **Property** `el.layout = obj` / React 19 `layout={obj}` | Yes |
|
|
269
|
+
| **Attribute** `layout="[object Object]"` / React 18 `layout={obj}` | No — components stay empty |
|
|
270
|
+
| **Attribute** `layout={JSON.stringify(obj)}` | Yes — component parses JSON |
|
|
271
|
+
|
|
272
|
+
## Troubleshooting
|
|
273
|
+
|
|
274
|
+
| Symptom | Likely cause | Fix |
|
|
275
|
+
| --- | --- | --- |
|
|
276
|
+
| Empty header/footer | Loader/tag import missing | `defineCustomElements()` + tag imports. |
|
|
277
|
+
| Empty despite correct data | React set `layout` as attribute | React 19+, or `JSON.stringify`, or ref assignment. |
|
|
278
|
+
| Logo missing on header | Old build without inlined logo | Upgrade package; logo is bundled in `logo-data.ts`. |
|
|
279
|
+
| Auth always Sign in | `signed-in` not set | Bind `signedIn={!!session}`. |
|
|
280
|
+
| Manage Account shows label not name | `user-name` not set | Pass `userName` when signed in. |
|
|
281
|
+
| Nav never highlights active page | `current-path` not set | Pass `currentPath` from your router (pathname + query when needed). |
|
|
282
|
+
| `onWegAuthClick` not firing | React CE event binding | Use `addEventListener` on a ref. |
|
|
283
|
+
| TS: unknown element | No augmentation | Add `weg-shared-layout-jsx.d.ts`. |
|
|
284
|
+
|
|
285
|
+
## See also
|
|
286
|
+
|
|
287
|
+
- **[Documentation index](./README.md)**
|
|
288
|
+
- **[Next.js App Router](./nextjs.md)**
|
|
289
|
+
- **[Angular](./angular.md)** · **[Angular 16 demo](../demo/angular16/README.md)**
|
|
290
|
+
- **[Plain HTML / vanilla JS](./vanilla.md)**
|
|
291
|
+
- **[Package readme](../readme.md)**
|