weg-shared-layout 0.0.38 → 0.0.39
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/docs/angular.md +26 -33
- package/docs/nextjs.md +14 -22
- package/docs/react.md +16 -26
- package/docs/vanilla.md +10 -25
- package/package.json +1 -1
- package/readme.md +5 -5
- package/src/assets/dummy-data.json +1 -2
package/docs/angular.md
CHANGED
|
@@ -16,10 +16,10 @@ Copy this while integrating:
|
|
|
16
16
|
- [ ] **Step 2** — `tsconfig`: `skipLibCheck`, `resolveJsonModule`, `moduleResolution`
|
|
17
17
|
- [ ] **Step 3** — `defineCustomElements()` in `main.ts` **before** bootstrap
|
|
18
18
|
- [ ] **Step 4** — `layout.types.ts` from package fixture
|
|
19
|
-
- [ ] **Step 5** — `auth.ts` with sign-
|
|
19
|
+
- [ ] **Step 5** — `auth.ts` with sign-out URL (optional; only if handling `wegAuthClick`)
|
|
20
20
|
- [ ] **Step 6** — `CUSTOM_ELEMENTS_SCHEMA` on the shell component
|
|
21
21
|
- [ ] **Step 7** — Template with **`[layout]`** property binding
|
|
22
|
-
- [ ] **Step 8** — Header: `[signedIn]`, `[userName]`, `(wegAuthClick)`
|
|
22
|
+
- [ ] **Step 8** — Header: `[signedIn]`, `[userName]`, `[accountBaseUrl]` (optional), `(wegAuthClick)`
|
|
23
23
|
- [ ] **Step 9** — Verify in DevTools: `$0.layout` is an object on `<weg-header>`
|
|
24
24
|
|
|
25
25
|
---
|
|
@@ -96,18 +96,13 @@ import type { LayoutData } from 'weg-shared-layout/layout-data';
|
|
|
96
96
|
|
|
97
97
|
---
|
|
98
98
|
|
|
99
|
-
## Step 5 —
|
|
99
|
+
## Step 5 — Sign-out URL (optional)
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
Sign-in is a normal nav link in your CMS layout — no host constants needed. Only define a sign-out redirect if you handle `wegAuthClick`:
|
|
102
102
|
|
|
103
103
|
```ts
|
|
104
104
|
// src/app/auth.ts
|
|
105
|
-
export const
|
|
106
|
-
label: 'Sign in',
|
|
107
|
-
href: 'https://account.warwickemploymentgroup.com/account/login',
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
export const ACCOUNT_LOGIN_HREF = HEADER_SIGN_IN.href;
|
|
105
|
+
export const ACCOUNT_SIGN_OUT_HREF = 'https://account.warwickemploymentgroup.com/account/login';
|
|
111
106
|
```
|
|
112
107
|
|
|
113
108
|
---
|
|
@@ -122,7 +117,7 @@ import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
|
122
117
|
import { RouterOutlet } from '@angular/router';
|
|
123
118
|
import layoutFixture from 'weg-shared-layout/dummy-data.json';
|
|
124
119
|
|
|
125
|
-
import {
|
|
120
|
+
import { ACCOUNT_SIGN_OUT_HREF } from './auth';
|
|
126
121
|
import type { LayoutData } from './layout.types';
|
|
127
122
|
|
|
128
123
|
@Component({
|
|
@@ -140,15 +135,11 @@ export class AppComponent {
|
|
|
140
135
|
|
|
141
136
|
onAuthClick(event: Event): void {
|
|
142
137
|
const customEvent = event as CustomEvent<{ action: 'sign-in' | 'sign-out' }>;
|
|
143
|
-
customEvent.
|
|
144
|
-
|
|
145
|
-
if (customEvent.detail.action === 'sign-out') {
|
|
146
|
-
this.signedIn = false;
|
|
147
|
-
window.location.href = ACCOUNT_LOGIN_HREF;
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
138
|
+
if (customEvent.detail.action !== 'sign-out') return;
|
|
150
139
|
|
|
151
|
-
|
|
140
|
+
customEvent.preventDefault();
|
|
141
|
+
this.signedIn = false;
|
|
142
|
+
window.location.href = ACCOUNT_SIGN_OUT_HREF;
|
|
152
143
|
}
|
|
153
144
|
}
|
|
154
145
|
```
|
|
@@ -180,7 +171,8 @@ Use **`[layout]="..."`** so Angular sets the JavaScript property, not an HTML at
|
|
|
180
171
|
| `[layout]` | CMS nav when signed out; same object for header and footer |
|
|
181
172
|
| `[signedIn]` | `true` → built-in signed-in nav (ignores CMS `header.menu`) |
|
|
182
173
|
| `[userName]` | First name on Manage Account when signed in |
|
|
183
|
-
| `
|
|
174
|
+
| `[accountBaseUrl]` | Account portal origin for signed-in links (optional; production default when omitted) |
|
|
175
|
+
| `(wegAuthClick)` | Optional — handle `sign-out` only; sign-in follows the link `href` |
|
|
184
176
|
|
|
185
177
|
Run the app — you should see header nav and footer.
|
|
186
178
|
|
|
@@ -197,9 +189,13 @@ import { Injectable } from '@angular/core';
|
|
|
197
189
|
import { HttpClient } from '@angular/common/http';
|
|
198
190
|
import { map, Observable } from 'rxjs';
|
|
199
191
|
|
|
200
|
-
import { HEADER_SIGN_IN } from './auth';
|
|
201
192
|
import type { LayoutData } from './layout.types';
|
|
202
193
|
|
|
194
|
+
const DEFAULT_SIGN_IN = {
|
|
195
|
+
label: 'Sign in',
|
|
196
|
+
href: 'https://account.warwickemploymentgroup.com/account/login',
|
|
197
|
+
};
|
|
198
|
+
|
|
203
199
|
@Injectable({ providedIn: 'root' })
|
|
204
200
|
export class LayoutService {
|
|
205
201
|
constructor(private http: HttpClient) {}
|
|
@@ -220,7 +216,7 @@ export class LayoutService {
|
|
|
220
216
|
if (hasSignIn) return data;
|
|
221
217
|
return {
|
|
222
218
|
...data,
|
|
223
|
-
header: { ...data.header, menu: [...menu,
|
|
219
|
+
header: { ...data.header, menu: [...menu, DEFAULT_SIGN_IN] },
|
|
224
220
|
};
|
|
225
221
|
}
|
|
226
222
|
}
|
|
@@ -234,7 +230,7 @@ import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
|
234
230
|
import { RouterOutlet } from '@angular/router';
|
|
235
231
|
import { Observable } from 'rxjs';
|
|
236
232
|
|
|
237
|
-
import {
|
|
233
|
+
import { ACCOUNT_SIGN_OUT_HREF } from './auth';
|
|
238
234
|
import type { LayoutData } from './layout.types';
|
|
239
235
|
import { LayoutService } from './layout.service';
|
|
240
236
|
|
|
@@ -256,15 +252,11 @@ export class AppComponent {
|
|
|
256
252
|
|
|
257
253
|
onAuthClick(event: Event): void {
|
|
258
254
|
const customEvent = event as CustomEvent<{ action: 'sign-in' | 'sign-out' }>;
|
|
259
|
-
customEvent.
|
|
260
|
-
|
|
261
|
-
if (customEvent.detail.action === 'sign-out') {
|
|
262
|
-
this.signedIn = false;
|
|
263
|
-
window.location.href = ACCOUNT_LOGIN_HREF;
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
255
|
+
if (customEvent.detail.action !== 'sign-out') return;
|
|
266
256
|
|
|
267
|
-
|
|
257
|
+
customEvent.preventDefault();
|
|
258
|
+
this.signedIn = false;
|
|
259
|
+
window.location.href = ACCOUNT_SIGN_OUT_HREF;
|
|
268
260
|
}
|
|
269
261
|
}
|
|
270
262
|
```
|
|
@@ -342,7 +334,7 @@ forkJoin({
|
|
|
342
334
|
footer: this.http.get<LayoutData['footer']>('/api/footer'),
|
|
343
335
|
}).pipe(
|
|
344
336
|
map(({ menuGroups, flatLinks, footer }) => ({
|
|
345
|
-
header: { menu: [...menuGroups, ...flatLinks,
|
|
337
|
+
header: { menu: [...menuGroups, ...flatLinks, DEFAULT_SIGN_IN] },
|
|
346
338
|
footer,
|
|
347
339
|
})),
|
|
348
340
|
);
|
|
@@ -359,6 +351,7 @@ forkJoin({
|
|
|
359
351
|
| Nav empty after passing data | `[layout]` must be `{ header, footer }`, not a bare array |
|
|
360
352
|
| Auth always Sign in | Bind `[signedIn]` from session state |
|
|
361
353
|
| Generic Manage Account | Pass `[userName]` when signed in |
|
|
354
|
+
| Staging account portal | Pass `[accountBaseUrl]` (e.g. `https://account-staging.example.com`) |
|
|
362
355
|
| `Mixin<const …>` / TS1139 in `stencil-public-runtime.d.ts` | Add `skipLibCheck: true` and/or upgrade to TypeScript 5.0+ |
|
|
363
356
|
| Cannot resolve `weg-shared-layout/loader` | Set `moduleResolution` to `bundler` or `node16` |
|
|
364
357
|
| SSR: `document is not defined` | Guard: `if (typeof window !== 'undefined') defineCustomElements()` |
|
|
@@ -387,7 +380,7 @@ export type LayoutData = typeof layoutFixture; // from dummy-data.json
|
|
|
387
380
|
| `src/main.ts` | `defineCustomElements()` then bootstrap |
|
|
388
381
|
| `tsconfig.json` | `skipLibCheck`, `resolveJsonModule`, `moduleResolution` |
|
|
389
382
|
| `src/app/layout.types.ts` | `export type LayoutData = typeof layoutFixture` |
|
|
390
|
-
| `src/app/auth.ts` | `
|
|
383
|
+
| `src/app/auth.ts` | `ACCOUNT_SIGN_OUT_HREF` (optional) |
|
|
391
384
|
| `src/app/layout.service.ts` | HTTP / API mapping (optional) |
|
|
392
385
|
| `src/app/app.component.ts` | Shell: schema, layout, auth handler |
|
|
393
386
|
| `src/app/app.component.html` | `<weg-header>`, `<router-outlet>`, `<weg-footer>` |
|
package/docs/nextjs.md
CHANGED
|
@@ -9,7 +9,7 @@ Guide for **Next.js 13+ App Router** (`app/` directory). For Vite/CRA-style clie
|
|
|
9
9
|
| `<weg-header>` | Site header — bundled logo, CMS nav (signed out), built-in nav (signed in), Sign in / Manage Account / Sign out |
|
|
10
10
|
| `<weg-footer>` | Site footer — social, menu, legal text |
|
|
11
11
|
|
|
12
|
-
Both accept **`layout`** (JSON string recommended in Next). `<weg-header>` also accepts **`signed-in`**, **`user-name`**, and emits **`wegAuthClick`**.
|
|
12
|
+
Both accept **`layout`** (JSON string recommended in Next). `<weg-header>` also accepts **`signed-in`**, **`user-name`**, **`account-base-url`**, and emits **`wegAuthClick`**.
|
|
13
13
|
|
|
14
14
|
## Why Next.js is different
|
|
15
15
|
|
|
@@ -51,18 +51,13 @@ const nextConfig: NextConfig = {
|
|
|
51
51
|
export default nextConfig;
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
## 2.
|
|
54
|
+
## 2. Sign-out URL (optional)
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
Sign-in comes from your CMS `header.menu` like any other link. Only define a redirect for custom sign-out handling:
|
|
57
57
|
|
|
58
58
|
```ts
|
|
59
59
|
// src/auth.ts
|
|
60
|
-
export const
|
|
61
|
-
label: 'Sign in',
|
|
62
|
-
href: 'https://account.warwickemploymentgroup.com/account/login',
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export const ACCOUNT_LOGIN_HREF = HEADER_SIGN_IN.href;
|
|
60
|
+
export const ACCOUNT_SIGN_OUT_HREF = 'https://account.warwickemploymentgroup.com/account/login';
|
|
66
61
|
```
|
|
67
62
|
|
|
68
63
|
## 3. Client layout components
|
|
@@ -73,7 +68,7 @@ export const ACCOUNT_LOGIN_HREF = HEADER_SIGN_IN.href;
|
|
|
73
68
|
|
|
74
69
|
import { useCallback } from 'react';
|
|
75
70
|
import { defineCustomElements } from 'weg-shared-layout/loader';
|
|
76
|
-
import {
|
|
71
|
+
import { ACCOUNT_SIGN_OUT_HREF } from '@/auth';
|
|
77
72
|
import 'weg-shared-layout/weg-header';
|
|
78
73
|
|
|
79
74
|
defineCustomElements();
|
|
@@ -95,17 +90,13 @@ export function Header({
|
|
|
95
90
|
}) {
|
|
96
91
|
const onAuthClick = useCallback(
|
|
97
92
|
(event: CustomEvent<{ action: 'sign-in' | 'sign-out' }>) => {
|
|
98
|
-
event.
|
|
93
|
+
if (event.detail.action !== 'sign-out') return;
|
|
99
94
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
window.location.href = HEADER_SIGN_IN.href;
|
|
95
|
+
event.preventDefault();
|
|
96
|
+
onSignedInChange?.(false);
|
|
97
|
+
window.location.href = ACCOUNT_SIGN_OUT_HREF;
|
|
107
98
|
},
|
|
108
|
-
[
|
|
99
|
+
[onSignedInChange],
|
|
109
100
|
);
|
|
110
101
|
|
|
111
102
|
return (
|
|
@@ -230,12 +221,13 @@ Wire **`signedIn`** and **`userName`** from your auth provider (session hook / c
|
|
|
230
221
|
|
|
231
222
|
| API | Signed out | Signed in |
|
|
232
223
|
| --- | --- | --- |
|
|
233
|
-
| `layout.header.menu` | CMS nav rendered (groups + flat links incl.
|
|
224
|
+
| `layout.header.menu` | CMS nav rendered (groups + flat links incl. sign-in) | Ignored — built-in nav used |
|
|
234
225
|
| `layout.header.logoSrc` | Logo image URL (bundled if omitted) | Built-in bundled logo |
|
|
235
226
|
| `layout.header.logoHref` | Logo link URL | WEG homepage |
|
|
236
227
|
| `signed-in` prop | `false` | `true` — session flag from host app |
|
|
237
228
|
| `user-name` prop | — | User's first name on Manage Account |
|
|
238
|
-
| `
|
|
229
|
+
| `account-base-url` prop | — | Account portal origin for signed-in links (optional) |
|
|
230
|
+
| `wegAuthClick` event | Sign-in follows link `href` | `'sign-out'` — handle in host if needed |
|
|
239
231
|
| `event.preventDefault()` | Skip default navigation | Skip default redirect |
|
|
240
232
|
|
|
241
233
|
**Signed-in nav (built into the component):** Find a job, Dashboard, Manage Account, Sign out.
|
|
@@ -300,7 +292,7 @@ declare module 'react' {
|
|
|
300
292
|
- [ ] `weg-shared-layout` installed
|
|
301
293
|
- [ ] `transpilePackages` in `next.config`
|
|
302
294
|
- [ ] Client `Header.tsx` / `Footer.tsx` with loader, tag imports, `JSON.stringify`, `suppressHydrationWarning`
|
|
303
|
-
- [ ] Auth: `signed-in`, `user-name`, and `wegAuthClick` handler on header
|
|
295
|
+
- [ ] Auth: `signed-in`, `user-name`, `account-base-url` (optional), and `wegAuthClick` handler on header
|
|
304
296
|
- [ ] Server `layout.tsx` imports client chrome only (no `defineCustomElements` on server)
|
|
305
297
|
- [ ] Layout fetched or imported server-side, passed as serializable props
|
|
306
298
|
- [ ] TypeScript augmentation for `'weg-header'` and `'weg-footer'`
|
package/docs/react.md
CHANGED
|
@@ -11,7 +11,7 @@ Guide for **client-rendered** React apps (Vite, Create React App, etc.). If you
|
|
|
11
11
|
|
|
12
12
|
Both are **presentational** [Stencil](https://stenciljs.com/) Web Components. They **do not fetch data** — your app passes a **`layout`** payload (API, CMS, or [`dummy-data.json`](../src/assets/dummy-data.json)).
|
|
13
13
|
|
|
14
|
-
`<weg-header>` additionally accepts **`signed-in`**, **`user-name`**, and emits **`wegAuthClick`**.
|
|
14
|
+
`<weg-header>` additionally accepts **`signed-in`**, **`user-name`**, **`account-base-url`**, and emits **`wegAuthClick`**.
|
|
15
15
|
|
|
16
16
|
## Requirements
|
|
17
17
|
|
|
@@ -75,29 +75,22 @@ export function SiteLayout({ children }: { children: React.ReactNode }) {
|
|
|
75
75
|
|
|
76
76
|
## 3. Header auth
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
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`.
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
// auth.ts
|
|
82
|
-
export const HEADER_SIGN_IN = {
|
|
83
|
-
label: 'Sign in',
|
|
84
|
-
href: 'https://account.warwickemploymentgroup.com/account/login',
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export const ACCOUNT_LOGIN_HREF = HEADER_SIGN_IN.href;
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Signed out
|
|
80
|
+
### Signed in
|
|
91
81
|
|
|
92
|
-
|
|
82
|
+
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.
|
|
93
83
|
|
|
94
|
-
|
|
84
|
+
Handle **`wegAuthClick`** only for custom sign-out behaviour:
|
|
95
85
|
|
|
96
|
-
|
|
86
|
+
```ts
|
|
87
|
+
// auth.ts
|
|
88
|
+
export const ACCOUNT_SIGN_OUT_HREF = 'https://account.warwickemploymentgroup.com/account/login';
|
|
89
|
+
```
|
|
97
90
|
|
|
98
91
|
```tsx
|
|
99
92
|
import { useCallback, useState } from 'react';
|
|
100
|
-
import {
|
|
93
|
+
import { ACCOUNT_SIGN_OUT_HREF } from './auth';
|
|
101
94
|
import 'weg-shared-layout/weg-header';
|
|
102
95
|
import layout from 'weg-shared-layout/dummy-data.json';
|
|
103
96
|
|
|
@@ -106,15 +99,11 @@ export function SiteHeader() {
|
|
|
106
99
|
const userName = signedIn ? 'Alex' : undefined;
|
|
107
100
|
|
|
108
101
|
const onAuthClick = useCallback((event: CustomEvent<{ action: 'sign-in' | 'sign-out' }>) => {
|
|
109
|
-
event.
|
|
102
|
+
if (event.detail.action !== 'sign-out') return;
|
|
110
103
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
window.location.href = HEADER_SIGN_IN.href;
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
setSignedIn(false);
|
|
106
|
+
window.location.href = ACCOUNT_SIGN_OUT_HREF;
|
|
118
107
|
}, []);
|
|
119
108
|
|
|
120
109
|
return (
|
|
@@ -132,7 +121,8 @@ export function SiteHeader() {
|
|
|
132
121
|
| --- | --- |
|
|
133
122
|
| `signedIn={boolean}` | Switches to signed-in nav when `true` |
|
|
134
123
|
| `userName={string}` | First name beside profile icon on Manage Account |
|
|
135
|
-
| `
|
|
124
|
+
| `accountBaseUrl={string}` | Account portal origin for signed-in links (optional) |
|
|
125
|
+
| `onWegAuthClick` | Optional — handle `sign-out`; sign-in follows link `href` |
|
|
136
126
|
|
|
137
127
|
**Ref fallback for the event** (if `onWegAuthClick` does not bind in your React version):
|
|
138
128
|
|
package/docs/vanilla.md
CHANGED
|
@@ -23,7 +23,6 @@ With a bundler that resolves `node_modules` and package **`exports`** (TypeScrip
|
|
|
23
23
|
<script type="module">
|
|
24
24
|
import { defineCustomElements } from 'weg-shared-layout/loader';
|
|
25
25
|
import layout from 'weg-shared-layout/dummy-data.json';
|
|
26
|
-
import { ACCOUNT_LOGIN_HREF, HEADER_SIGN_IN } from './auth.js';
|
|
27
26
|
|
|
28
27
|
defineCustomElements();
|
|
29
28
|
|
|
@@ -68,54 +67,40 @@ See [`dummy-data.json`](../src/assets/dummy-data.json) for production URL exampl
|
|
|
68
67
|
|
|
69
68
|
## Header auth (Sign in / Sign out)
|
|
70
69
|
|
|
71
|
-
Define auth URLs in `./auth.js`:
|
|
72
|
-
|
|
73
|
-
```js
|
|
74
|
-
export const HEADER_SIGN_IN = {
|
|
75
|
-
label: 'Sign in',
|
|
76
|
-
href: 'https://account.warwickemploymentgroup.com/account/login',
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export const ACCOUNT_LOGIN_HREF = HEADER_SIGN_IN.href;
|
|
80
|
-
```
|
|
81
|
-
|
|
82
70
|
### Signed out
|
|
83
71
|
|
|
84
|
-
Renders `header.menu` from `layout
|
|
72
|
+
Renders `header.menu` from `layout`. Add sign-in as a normal link — `{ "label": "Sign in", "href": "…" }` — like Register. The header recognizes it by label or login URL and follows `href` on click.
|
|
85
73
|
|
|
86
74
|
### Signed in
|
|
87
75
|
|
|
88
|
-
Set **`signedIn`** and optionally **`userName`**. CMS nav is ignored; built-in links are shown (Find a job, Dashboard, Manage Account, Sign out).
|
|
76
|
+
Set **`signedIn`** and optionally **`userName`**. CMS nav is ignored; built-in links are shown (Find a job, Dashboard, Manage Account, Sign out). Set **`accountBaseUrl`** when account links should use a non-production portal.
|
|
89
77
|
|
|
90
78
|
```js
|
|
91
79
|
header.signedIn = true;
|
|
92
80
|
header.userName = 'Alex';
|
|
81
|
+
// header.accountBaseUrl = 'https://account-staging.example.com';
|
|
93
82
|
// or
|
|
94
83
|
header.setAttribute('signed-in', '');
|
|
95
84
|
header.setAttribute('user-name', 'Alex');
|
|
96
85
|
```
|
|
97
86
|
|
|
98
|
-
Listen for **`wegAuthClick
|
|
87
|
+
Listen for **`wegAuthClick`** only when you need custom sign-out handling:
|
|
99
88
|
|
|
100
89
|
```js
|
|
101
|
-
import {
|
|
90
|
+
import { ACCOUNT_SIGN_OUT_HREF } from './auth.js';
|
|
102
91
|
|
|
103
92
|
header.addEventListener('wegAuthClick', (event) => {
|
|
104
|
-
event.
|
|
93
|
+
if (event.detail.action !== 'sign-out') return;
|
|
105
94
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
window.location.href = HEADER_SIGN_IN.href;
|
|
95
|
+
event.preventDefault();
|
|
96
|
+
header.signedIn = false;
|
|
97
|
+
window.location.href = ACCOUNT_SIGN_OUT_HREF;
|
|
113
98
|
});
|
|
114
99
|
```
|
|
115
100
|
|
|
116
101
|
| `event.detail.action` | Default behaviour if not prevented |
|
|
117
102
|
| --- | --- |
|
|
118
|
-
| `'sign-in'` | Browser follows the
|
|
103
|
+
| `'sign-in'` | Browser follows the link's `href` |
|
|
119
104
|
| `'sign-out'` | Redirects to built-in sign-out URL |
|
|
120
105
|
|
|
121
106
|
Logo **image** uses `header.logoSrc` (bundled if omitted). Logo **link** uses `header.logoHref` when provided; otherwise it goes to the WEG homepage.
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -18,7 +18,7 @@ Load layout JSON from your CMS/API (e.g. [`GET /api/layout`](https://weg-payload
|
|
|
18
18
|
|
|
19
19
|
### Layout shape (abbreviated)
|
|
20
20
|
|
|
21
|
-
Full reference: [`src/assets/dummy-data.json`](src/assets/dummy-data.json). Sign-in is a normal `header.menu`
|
|
21
|
+
Full reference: [`src/assets/dummy-data.json`](src/assets/dummy-data.json). Sign-in is a normal `header.menu` link (label **Sign in** or login `href`); `<weg-header>` recognizes it automatically. Signed-in nav is built into `<weg-header>` when `signed-in` is true.
|
|
22
22
|
|
|
23
23
|
```json
|
|
24
24
|
{
|
|
@@ -49,17 +49,17 @@ Full reference: [`src/assets/dummy-data.json`](src/assets/dummy-data.json). Sign
|
|
|
49
49
|
|
|
50
50
|
### Auth (Sign in / Sign out)
|
|
51
51
|
|
|
52
|
-
**Signed out**: renders `header.menu`.
|
|
52
|
+
**Signed out**: renders `header.menu`. Sign-in is a normal link — add `{ "label": "Sign in", "href": "…" }` like Register or Career advice. The header recognizes it by label or login URL and follows `href` on click.
|
|
53
53
|
|
|
54
54
|
**Signed in** (`signed-in` true): ignores CMS `header.menu` and shows built-in Find a job, Dashboard, Manage Account, and Sign out.
|
|
55
55
|
|
|
56
|
-
Set **`signed-in`** from your app session state. Pass **`user-name`** for Manage Account.
|
|
56
|
+
Set **`signed-in`** from your app session state. Pass **`user-name`** for Manage Account. Pass **`account-base-url`** when account links should point at a non-production portal (defaults to production when omitted). Handle **`wegAuthClick`** only when you need custom sign-out behaviour.
|
|
57
57
|
|
|
58
58
|
```js
|
|
59
59
|
header.addEventListener('wegAuthClick', (event) => {
|
|
60
|
+
if (event.detail.action !== 'sign-out') return;
|
|
60
61
|
event.preventDefault();
|
|
61
|
-
|
|
62
|
-
else window.location.href = HEADER_SIGN_IN.href;
|
|
62
|
+
logout();
|
|
63
63
|
});
|
|
64
64
|
```
|
|
65
65
|
|