weg-shared-layout 0.0.26 → 0.0.28
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/LICENSE +21 -21
- package/dist/cjs/weg-footer_2.cjs.entry.js +7 -7
- package/dist/collection/components/weg-footer/icons/instagram.svg +5 -5
- package/dist/collection/components/weg-footer/icons/linkedin.svg +3 -3
- package/dist/collection/components/weg-footer/icons/tiktok.svg +3 -3
- package/dist/collection/components/weg-footer/icons/youtube.svg +4 -4
- package/dist/collection/components/weg-footer/weg-footer.css +263 -270
- package/dist/collection/components/weg-footer/weg-footer.js +2 -2
- package/dist/collection/components/weg-header/weg-header.css +475 -474
- package/dist/collection/components/weg-header/weg-header.js +4 -4
- package/dist/collection/styles/shared.css +96 -72
- package/dist/components/weg-footer.js +1 -1
- package/dist/components/weg-header.js +1 -1
- package/dist/esm/weg-footer_2.entry.js +7 -7
- package/dist/weg-shared-layout/p-9665af6f.entry.js +1 -0
- package/dist/weg-shared-layout/weg-shared-layout.esm.js +1 -1
- package/docs/README.md +51 -0
- package/docs/angular-16-compatibility.md +250 -235
- package/docs/angular-integration-guide.md +1035 -1008
- package/docs/angular.md +258 -232
- package/docs/nextjs.md +314 -306
- package/docs/publishing.md +65 -48
- package/docs/react.md +272 -261
- package/docs/vanilla.md +139 -138
- package/package.json +81 -76
- package/readme.md +97 -83
- package/src/constants/breakpoints.ts +7 -7
- package/src/styles/container.css +53 -0
- package/dist/weg-shared-layout/p-e6eadfa1.entry.js +0 -1
- /package/dist/types/Users/{tan/Documents/code → rakin/Documents/WEG/repos}/weg-shared-layout/.stencil/test-utils/axe.d.ts +0 -0
- /package/dist/types/Users/{tan/Documents/code → rakin/Documents/WEG/repos}/weg-shared-layout/.stencil/test-utils/viewport.d.ts +0 -0
package/docs/angular.md
CHANGED
|
@@ -1,232 +1,258 @@
|
|
|
1
|
-
# Angular
|
|
2
|
-
|
|
3
|
-
Short quick start for Angular 16+. For the full **step-by-step** guide (HTTP, API mapping, testing, SSR, troubleshooting), see **[angular-integration-guide.md](./angular-integration-guide.md)**.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- [ ] `
|
|
13
|
-
- [ ] `
|
|
14
|
-
- [ ] `
|
|
15
|
-
- [ ]
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
181
|
-
|
|
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
|
-
-
|
|
1
|
+
# Angular
|
|
2
|
+
|
|
3
|
+
Short quick start for Angular 16+. For the full **step-by-step** guide (HTTP, API mapping, testing, SSR, troubleshooting), see **[angular-integration-guide.md](./angular-integration-guide.md)**.
|
|
4
|
+
|
|
5
|
+
| Demo | When |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| **[demo/angular16/README.md](../demo/angular16/README.md)** | Angular **16** — same imports as `npm i` (in-repo: `file:../..`) |
|
|
8
|
+
| [weg-angular-demo](https://github.com/jobsac/weg-angular-demo) | Newer Angular (signals) |
|
|
9
|
+
|
|
10
|
+
## Integration checklist
|
|
11
|
+
|
|
12
|
+
- [ ] `npm i weg-shared-layout`
|
|
13
|
+
- [ ] `defineCustomElements()` in `main.ts` **before** bootstrap
|
|
14
|
+
- [ ] `skipLibCheck`, `resolveJsonModule`, `moduleResolution: "bundler"` (or `node16`) — see [Step 3 in integration guide](./angular-integration-guide.md#step-3--typescript-import-layout-json)
|
|
15
|
+
- [ ] `auth.ts` with `HEADER_SIGN_IN` / `ACCOUNT_LOGIN_HREF` (host app constants)
|
|
16
|
+
- [ ] `CUSTOM_ELEMENTS_SCHEMA` on the shell component that uses the tags
|
|
17
|
+
- [ ] `[layout]="layoutObject"` on `<weg-header>` and `<weg-footer>`
|
|
18
|
+
- [ ] Header: `[signedIn]`, `[userName]`, `(wegAuthClick)` when using auth
|
|
19
|
+
|
|
20
|
+
## Components
|
|
21
|
+
|
|
22
|
+
| Tag | Purpose |
|
|
23
|
+
| --- | --- |
|
|
24
|
+
| `<weg-header>` | Header — CMS nav (signed out), built-in nav (signed in), auth |
|
|
25
|
+
| `<weg-footer>` | Footer — social, menu, credits, copyright |
|
|
26
|
+
|
|
27
|
+
Both accept the same `layout` payload ([`dummy-data.json`](../src/assets/dummy-data.json) or your API). `<weg-header>` also accepts **`signed-in`**, **`user-name`**, and emits **`wegAuthClick`**.
|
|
28
|
+
|
|
29
|
+
## 1. Install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm i weg-shared-layout
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 2. Register custom elements (once, before bootstrap)
|
|
36
|
+
|
|
37
|
+
**Recommended** — loader in `src/main.ts`:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { bootstrapApplication } from '@angular/platform-browser';
|
|
41
|
+
import { defineCustomElements } from 'weg-shared-layout/loader';
|
|
42
|
+
|
|
43
|
+
import { appConfig } from './app/app.config';
|
|
44
|
+
import { App } from './app/app';
|
|
45
|
+
|
|
46
|
+
defineCustomElements();
|
|
47
|
+
|
|
48
|
+
bootstrapApplication(App, appConfig).catch((err) => console.error(err));
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Alternative** — side-effect imports (one of these approaches, not both; needs `moduleResolution` `bundler` / `node16`):
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import 'weg-shared-layout/weg-header';
|
|
55
|
+
import 'weg-shared-layout/weg-footer';
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 3. Layout types + TypeScript
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
// src/app/layout.types.ts
|
|
62
|
+
import layoutFixture from 'weg-shared-layout/dummy-data.json';
|
|
63
|
+
|
|
64
|
+
export type LayoutData = typeof layoutFixture;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
// tsconfig.json (or tsconfig.app.json) — required for JSON + package subpaths
|
|
69
|
+
{
|
|
70
|
+
"compilerOptions": {
|
|
71
|
+
"skipLibCheck": true,
|
|
72
|
+
"resolveJsonModule": true,
|
|
73
|
+
"moduleResolution": "bundler"
|
|
74
|
+
},
|
|
75
|
+
"include": ["src/**/*.ts"]
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Angular 16 pitfalls (Stencil `.d.ts`, classic `node` resolution): **[angular-16-compatibility.md](./angular-16-compatibility.md)**.
|
|
80
|
+
|
|
81
|
+
## 4. Allow custom elements in templates
|
|
82
|
+
|
|
83
|
+
Add `schemas: [CUSTOM_ELEMENTS_SCHEMA]` to every `@Component` (or `@NgModule`) whose template uses `<weg-header>` or `<weg-footer>`. Does **not** cascade to `router-outlet` children.
|
|
84
|
+
|
|
85
|
+
## 5. Auth constants
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
// src/app/auth.ts
|
|
89
|
+
export const HEADER_SIGN_IN = {
|
|
90
|
+
label: 'Sign in',
|
|
91
|
+
href: 'https://account.warwickemploymentgroup.com/account/login',
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const ACCOUNT_LOGIN_HREF = HEADER_SIGN_IN.href;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## 6. Layout shell — pick one
|
|
98
|
+
|
|
99
|
+
Use **`[layout]="..."`** so Angular sets the JavaScript `layout` property, not an HTML attribute.
|
|
100
|
+
|
|
101
|
+
| Variant | Angular | Template bindings |
|
|
102
|
+
| --- | --- | --- |
|
|
103
|
+
| **6A** Plain properties | 16+ | `[layout]="layoutData"` |
|
|
104
|
+
| **6B** Signals | 16.1+ | `[layout]="layoutData()"` |
|
|
105
|
+
|
|
106
|
+
Full HTTP examples: integration guide **[Step 7A / 7B](./angular-integration-guide.md#step-7--load-layout-from-your-api)**.
|
|
107
|
+
|
|
108
|
+
### 6A — Plain properties (Angular 16+)
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
// src/app/app.ts
|
|
112
|
+
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
113
|
+
import { RouterOutlet } from '@angular/router';
|
|
114
|
+
import layoutFixture from 'weg-shared-layout/dummy-data.json';
|
|
115
|
+
|
|
116
|
+
import { ACCOUNT_LOGIN_HREF, HEADER_SIGN_IN } from './auth';
|
|
117
|
+
|
|
118
|
+
@Component({
|
|
119
|
+
selector: 'app-root',
|
|
120
|
+
imports: [RouterOutlet],
|
|
121
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
122
|
+
templateUrl: './app.html',
|
|
123
|
+
})
|
|
124
|
+
export class App {
|
|
125
|
+
layoutData = layoutFixture;
|
|
126
|
+
|
|
127
|
+
signedIn = false;
|
|
128
|
+
userName?: string;
|
|
129
|
+
|
|
130
|
+
onAuthClick(event: Event): void {
|
|
131
|
+
const customEvent = event as CustomEvent<{ action: 'sign-in' | 'sign-out' }>;
|
|
132
|
+
customEvent.preventDefault();
|
|
133
|
+
|
|
134
|
+
if (customEvent.detail.action === 'sign-out') {
|
|
135
|
+
this.signedIn = false;
|
|
136
|
+
window.location.href = ACCOUNT_LOGIN_HREF;
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
window.location.href = HEADER_SIGN_IN.href;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
```html
|
|
146
|
+
<!-- src/app/app.html -->
|
|
147
|
+
<weg-header
|
|
148
|
+
[layout]="layoutData"
|
|
149
|
+
[signedIn]="signedIn"
|
|
150
|
+
[userName]="userName"
|
|
151
|
+
(wegAuthClick)="onAuthClick($event)"
|
|
152
|
+
></weg-header>
|
|
153
|
+
|
|
154
|
+
<router-outlet />
|
|
155
|
+
|
|
156
|
+
<weg-footer [layout]="layoutData"></weg-footer>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
In production, load the same shape from your API — see **[Step 7A](./angular-integration-guide.md#step-7a--http-with-rxjs--async-pipe-pairs-with-6a)**. If your API returns separate arrays, see **[mapping section](./angular-integration-guide.md#optional-api-returns-separate-arrays-not-one-layout-object)**.
|
|
160
|
+
|
|
161
|
+
### 6B — Signals (Angular 16.1+)
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
// src/app/app.ts
|
|
165
|
+
import { Component, CUSTOM_ELEMENTS_SCHEMA, signal } from '@angular/core';
|
|
166
|
+
import { RouterOutlet } from '@angular/router';
|
|
167
|
+
import layoutFixture from 'weg-shared-layout/dummy-data.json';
|
|
168
|
+
|
|
169
|
+
import { ACCOUNT_LOGIN_HREF, HEADER_SIGN_IN } from './auth';
|
|
170
|
+
import type { LayoutData } from './layout.types';
|
|
171
|
+
|
|
172
|
+
@Component({
|
|
173
|
+
selector: 'app-root',
|
|
174
|
+
imports: [RouterOutlet],
|
|
175
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
176
|
+
templateUrl: './app.html',
|
|
177
|
+
})
|
|
178
|
+
export class App {
|
|
179
|
+
readonly layoutData = signal<LayoutData>(layoutFixture);
|
|
180
|
+
|
|
181
|
+
readonly signedIn = signal(false);
|
|
182
|
+
readonly userName = signal<string | undefined>(undefined);
|
|
183
|
+
|
|
184
|
+
onAuthClick(event: Event): void {
|
|
185
|
+
const customEvent = event as CustomEvent<{ action: 'sign-in' | 'sign-out' }>;
|
|
186
|
+
customEvent.preventDefault();
|
|
187
|
+
|
|
188
|
+
if (customEvent.detail.action === 'sign-out') {
|
|
189
|
+
this.signedIn.set(false);
|
|
190
|
+
this.userName.set(undefined);
|
|
191
|
+
window.location.href = ACCOUNT_LOGIN_HREF;
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
window.location.href = HEADER_SIGN_IN.href;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
```html
|
|
201
|
+
<!-- src/app/app.html -->
|
|
202
|
+
<weg-header
|
|
203
|
+
[layout]="layoutData()"
|
|
204
|
+
[signedIn]="signedIn()"
|
|
205
|
+
[userName]="userName()"
|
|
206
|
+
(wegAuthClick)="onAuthClick($event)"
|
|
207
|
+
></weg-header>
|
|
208
|
+
|
|
209
|
+
<router-outlet />
|
|
210
|
+
|
|
211
|
+
<weg-footer [layout]="layoutData()"></weg-footer>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
HTTP with signals: **[Step 7B](./angular-integration-guide.md#step-7b--http-with-signals--tosignal-pairs-with-6b)** (`toSignal` + same `LayoutService`).
|
|
215
|
+
|
|
216
|
+
## Header: `signed-in`, `user-name`, `wegAuthClick`
|
|
217
|
+
|
|
218
|
+
| Input / output | Binding (6A) | Binding (6B) | Notes |
|
|
219
|
+
| --- | --- | --- | --- |
|
|
220
|
+
| CMS nav | `[layout]="layoutData"` | `[layout]="layoutData()"` | `header.menu` — groups (`items`) and flat links (`href`) when signed out |
|
|
221
|
+
| Session state | `[signedIn]="signedIn"` | `[signedIn]="signedIn()"` | `true` → built-in signed-in nav |
|
|
222
|
+
| User name | `[userName]="userName"` | `[userName]="userName()"` | Manage Account label when signed in |
|
|
223
|
+
| Auth click | `(wegAuthClick)="onAuthClick($event)"` | `detail.action`: `'sign-in'` \| `'sign-out'` |
|
|
224
|
+
| Prevent default | `preventDefault()` in handler | Stops component default navigation |
|
|
225
|
+
|
|
226
|
+
**Signed-in nav (built in):** Find a job, Dashboard, Manage Account, Sign out.
|
|
227
|
+
|
|
228
|
+
Logo **image** uses `layout.header.logoSrc` (bundled if omitted). Logo **link** always goes to WEG home.
|
|
229
|
+
|
|
230
|
+
## Footer
|
|
231
|
+
|
|
232
|
+
`<weg-footer>` only needs `[layout]`. See [`dummy-data.json`](../src/assets/dummy-data.json) for `footer` shape.
|
|
233
|
+
|
|
234
|
+
## Troubleshooting
|
|
235
|
+
|
|
236
|
+
| Symptom | Cause / fix |
|
|
237
|
+
| --- | --- |
|
|
238
|
+
| `'weg-header'` / `'weg-footer'` is not a known element | `CUSTOM_ELEMENTS_SCHEMA` on the template's component |
|
|
239
|
+
| Header/footer empty | `defineCustomElements()` before bootstrap, or missing `[layout]` |
|
|
240
|
+
| Nav empty after passing an array | `[layout]` must be `{ header, footer }`, not a bare array |
|
|
241
|
+
| Auth always Sign in | `[signedIn]` not bound or still `false` |
|
|
242
|
+
| Manage Account generic | `[userName]` not set when signed in |
|
|
243
|
+
| SSR: `document is not defined` | Guard `defineCustomElements()` with `typeof window !== 'undefined'` |
|
|
244
|
+
| `stencil-public-runtime.d.ts` / `Mixin<const …>` errors | TypeScript 4.9 vs Stencil 5 `.d.ts` | **[angular-16-compatibility.md](./angular-16-compatibility.md)** |
|
|
245
|
+
| Cannot resolve `weg-shared-layout/weg-header` | Old `moduleResolution` | Loader in `main.ts` or `bundler` / `node16` — **[angular-16-compatibility.md](./angular-16-compatibility.md)** |
|
|
246
|
+
|
|
247
|
+
More detail: **[integration guide § Troubleshooting](./angular-integration-guide.md#troubleshooting)**.
|
|
248
|
+
|
|
249
|
+
## See also
|
|
250
|
+
|
|
251
|
+
- **[Documentation index](./README.md)**
|
|
252
|
+
- **[In-repo Angular 16 demo](../demo/angular16/README.md)**
|
|
253
|
+
- **[Angular 16 / TS 4.9 compatibility](./angular-16-compatibility.md)** — `stencil-public-runtime` errors, subpath imports
|
|
254
|
+
- **[Angular integration guide (step-by-step)](./angular-integration-guide.md)**
|
|
255
|
+
- **[React SPA](./react.md)**
|
|
256
|
+
- **[Next.js App Router](./nextjs.md)**
|
|
257
|
+
- **[Plain HTML / vanilla JS](./vanilla.md)**
|
|
258
|
+
- **[Package readme](../readme.md)**
|