weg-shared-layout 0.0.23 → 0.0.24
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/loader.cjs.js +1 -1
- package/dist/cjs/weg-footer_2.cjs.entry.js +121 -58
- package/dist/cjs/weg-shared-layout.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +0 -1
- 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 +218 -201
- package/dist/collection/components/weg-footer/weg-footer.js +2 -2
- package/dist/collection/components/weg-header/weg-header.css +473 -365
- package/dist/collection/components/weg-header/weg-header.js +114 -58
- package/dist/collection/constants/breakpoints.js +6 -0
- package/dist/collection/styles/shared.css +72 -78
- package/dist/components/weg-footer.js +1 -1
- package/dist/components/weg-header.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/weg-footer_2.entry.js +121 -58
- package/dist/esm/weg-shared-layout.js +1 -1
- package/dist/types/components/weg-header/weg-header.d.ts +20 -7
- package/dist/types/components.d.ts +0 -42
- package/dist/types/constants/breakpoints.d.ts +6 -0
- package/dist/weg-shared-layout/p-c6ec3888.entry.js +1 -0
- package/dist/weg-shared-layout/weg-shared-layout.esm.js +1 -1
- package/docs/angular-integration-guide.md +1026 -0
- package/docs/angular.md +247 -138
- package/docs/nextjs.md +305 -305
- package/docs/publishing.md +48 -48
- package/docs/react.md +261 -261
- package/docs/vanilla.md +140 -140
- package/package.json +12 -8
- package/readme.md +108 -107
- package/src/assets/dummy-data.json +147 -147
- package/src/constants/breakpoints.ts +7 -0
- package/src/constants/weg-urls.ts +23 -23
- package/dist/cjs/my-component.cjs.entry.js +0 -33
- package/dist/collection/components/my-component/my-component.css +0 -3
- package/dist/collection/components/my-component/my-component.js +0 -95
- package/dist/components/my-component.d.ts +0 -11
- package/dist/components/my-component.js +0 -1
- package/dist/esm/my-component.entry.js +0 -31
- package/dist/types/components/my-component/my-component.d.ts +0 -16
- package/dist/weg-shared-layout/p-80fa529c.entry.js +0 -1
- package/dist/weg-shared-layout/p-d61033bd.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,138 +1,247 @@
|
|
|
1
|
-
# Angular
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
export
|
|
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
|
-
-
|
|
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
|
+
Reference demo: [weg-angular-demo](https://github.com/jobsac/weg-angular-demo).
|
|
6
|
+
|
|
7
|
+
## Integration checklist
|
|
8
|
+
|
|
9
|
+
- [ ] `npm i weg-shared-layout`
|
|
10
|
+
- [ ] `defineCustomElements()` in `main.ts` **before** bootstrap
|
|
11
|
+
- [ ] `resolveJsonModule` in `tsconfig.app.json` (if importing JSON)
|
|
12
|
+
- [ ] `auth.ts` with `HEADER_SIGN_IN` / `ACCOUNT_LOGIN_HREF` (host app constants)
|
|
13
|
+
- [ ] `CUSTOM_ELEMENTS_SCHEMA` on the shell component that uses the tags
|
|
14
|
+
- [ ] `[layout]="layoutObject"` on `<weg-header>` and `<weg-footer>`
|
|
15
|
+
- [ ] Header: `[signedIn]`, `[userName]`, `(wegAuthClick)` when using auth
|
|
16
|
+
|
|
17
|
+
## Components
|
|
18
|
+
|
|
19
|
+
| Tag | Purpose |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| `<weg-header>` | Header — CMS nav (signed out), built-in nav (signed in), auth |
|
|
22
|
+
| `<weg-footer>` | Footer — social, columns, credits, copyright |
|
|
23
|
+
|
|
24
|
+
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`**.
|
|
25
|
+
|
|
26
|
+
## 1. Install
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm i weg-shared-layout
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 2. Register custom elements (once, before bootstrap)
|
|
33
|
+
|
|
34
|
+
**Recommended** — loader in `src/main.ts`:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { bootstrapApplication } from '@angular/platform-browser';
|
|
38
|
+
import { defineCustomElements } from 'weg-shared-layout/loader';
|
|
39
|
+
|
|
40
|
+
import { appConfig } from './app/app.config';
|
|
41
|
+
import { App } from './app/app';
|
|
42
|
+
|
|
43
|
+
defineCustomElements();
|
|
44
|
+
|
|
45
|
+
bootstrapApplication(App, appConfig).catch((err) => console.error(err));
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Alternative** — side-effect imports (one of these approaches, not both):
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import 'weg-shared-layout/weg-header';
|
|
52
|
+
import 'weg-shared-layout/weg-footer';
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## 3. Allow custom elements in templates
|
|
56
|
+
|
|
57
|
+
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.
|
|
58
|
+
|
|
59
|
+
## 4. Auth constants
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
// src/app/auth.ts
|
|
63
|
+
export const HEADER_LOGO_HREF = 'https://www.warwickemploymentgroup.com/';
|
|
64
|
+
|
|
65
|
+
export const HEADER_SIGN_IN = {
|
|
66
|
+
label: 'Sign in',
|
|
67
|
+
href: 'https://account.warwickemploymentgroup.com/account/login',
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const ACCOUNT_LOGIN_HREF = HEADER_SIGN_IN.href;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 5. Layout shell — pick one
|
|
74
|
+
|
|
75
|
+
Use **`[layout]="..."`** so Angular sets the JavaScript `layout` property, not an HTML attribute.
|
|
76
|
+
|
|
77
|
+
| Variant | Angular | Template bindings |
|
|
78
|
+
| --- | --- | --- |
|
|
79
|
+
| **5A** Plain properties | 16+ | `[layout]="layoutData"` |
|
|
80
|
+
| **5B** Signals | 16.1+ | `[layout]="layoutData()"` |
|
|
81
|
+
|
|
82
|
+
Full HTTP examples: integration guide **[Step 7A / 7B](./angular-integration-guide.md#step-7--load-layout-from-your-api)**.
|
|
83
|
+
|
|
84
|
+
### 5A — Plain properties (Angular 16+)
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
// src/app/app.ts
|
|
88
|
+
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
89
|
+
import { RouterOutlet } from '@angular/router';
|
|
90
|
+
import layoutFixture from 'weg-shared-layout/dummy-data.json';
|
|
91
|
+
|
|
92
|
+
import { ACCOUNT_LOGIN_HREF, HEADER_LOGO_HREF, HEADER_SIGN_IN } from './auth';
|
|
93
|
+
|
|
94
|
+
@Component({
|
|
95
|
+
selector: 'app-root',
|
|
96
|
+
imports: [RouterOutlet],
|
|
97
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
98
|
+
templateUrl: './app.html',
|
|
99
|
+
})
|
|
100
|
+
export class App {
|
|
101
|
+
layoutData = {
|
|
102
|
+
...layoutFixture,
|
|
103
|
+
header: {
|
|
104
|
+
...layoutFixture.header,
|
|
105
|
+
logoHref: HEADER_LOGO_HREF,
|
|
106
|
+
signIn: HEADER_SIGN_IN,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
signedIn = false;
|
|
111
|
+
userName?: string;
|
|
112
|
+
|
|
113
|
+
onAuthClick(event: Event): void {
|
|
114
|
+
const customEvent = event as CustomEvent<{ action: 'sign-in' | 'sign-out' }>;
|
|
115
|
+
customEvent.preventDefault();
|
|
116
|
+
|
|
117
|
+
if (customEvent.detail.action === 'sign-out') {
|
|
118
|
+
this.signedIn = false;
|
|
119
|
+
window.location.href = ACCOUNT_LOGIN_HREF;
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
window.location.href =
|
|
124
|
+
this.layoutData.header?.signIn?.href ?? HEADER_SIGN_IN.href;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
```html
|
|
130
|
+
<!-- src/app/app.html -->
|
|
131
|
+
<weg-header
|
|
132
|
+
[layout]="layoutData"
|
|
133
|
+
[signedIn]="signedIn"
|
|
134
|
+
[userName]="userName"
|
|
135
|
+
(wegAuthClick)="onAuthClick($event)"
|
|
136
|
+
></weg-header>
|
|
137
|
+
|
|
138
|
+
<router-outlet />
|
|
139
|
+
|
|
140
|
+
<weg-footer [layout]="layoutData"></weg-footer>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Enable `resolveJsonModule` in `tsconfig.app.json` if you import `dummy-data.json`.
|
|
144
|
+
|
|
145
|
+
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)**.
|
|
146
|
+
|
|
147
|
+
### 5B — Signals (Angular 16.1+)
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
// src/app/app.ts
|
|
151
|
+
import { Component, CUSTOM_ELEMENTS_SCHEMA, signal } from '@angular/core';
|
|
152
|
+
import { RouterOutlet } from '@angular/router';
|
|
153
|
+
import layoutFixture from 'weg-shared-layout/dummy-data.json';
|
|
154
|
+
|
|
155
|
+
import { ACCOUNT_LOGIN_HREF, HEADER_LOGO_HREF, HEADER_SIGN_IN } from './auth';
|
|
156
|
+
import type { LayoutData } from './layout.types';
|
|
157
|
+
|
|
158
|
+
@Component({
|
|
159
|
+
selector: 'app-root',
|
|
160
|
+
imports: [RouterOutlet],
|
|
161
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
162
|
+
templateUrl: './app.html',
|
|
163
|
+
})
|
|
164
|
+
export class App {
|
|
165
|
+
readonly layoutData = signal<LayoutData>({
|
|
166
|
+
...layoutFixture,
|
|
167
|
+
header: {
|
|
168
|
+
...layoutFixture.header,
|
|
169
|
+
logoHref: HEADER_LOGO_HREF,
|
|
170
|
+
signIn: HEADER_SIGN_IN,
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
readonly signedIn = signal(false);
|
|
175
|
+
readonly userName = signal<string | undefined>(undefined);
|
|
176
|
+
|
|
177
|
+
onAuthClick(event: Event): void {
|
|
178
|
+
const customEvent = event as CustomEvent<{ action: 'sign-in' | 'sign-out' }>;
|
|
179
|
+
customEvent.preventDefault();
|
|
180
|
+
|
|
181
|
+
if (customEvent.detail.action === 'sign-out') {
|
|
182
|
+
this.signedIn.set(false);
|
|
183
|
+
this.userName.set(undefined);
|
|
184
|
+
window.location.href = ACCOUNT_LOGIN_HREF;
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
window.location.href =
|
|
189
|
+
this.layoutData().header?.signIn?.href ?? HEADER_SIGN_IN.href;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
```html
|
|
195
|
+
<!-- src/app/app.html -->
|
|
196
|
+
<weg-header
|
|
197
|
+
[layout]="layoutData()"
|
|
198
|
+
[signedIn]="signedIn()"
|
|
199
|
+
[userName]="userName()"
|
|
200
|
+
(wegAuthClick)="onAuthClick($event)"
|
|
201
|
+
></weg-header>
|
|
202
|
+
|
|
203
|
+
<router-outlet />
|
|
204
|
+
|
|
205
|
+
<weg-footer [layout]="layoutData()"></weg-footer>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
HTTP with signals: **[Step 7B](./angular-integration-guide.md#step-7b--http-with-signals--tosignal-pairs-with-6b)** (`toSignal` + same `LayoutService`).
|
|
209
|
+
|
|
210
|
+
## Header: `signed-in`, `user-name`, `wegAuthClick`
|
|
211
|
+
|
|
212
|
+
| Input / output | Binding (5A) | Binding (5B) | Notes |
|
|
213
|
+
| --- | --- | --- | --- |
|
|
214
|
+
| CMS nav | `[layout]="layoutData"` | `[layout]="layoutData()"` | `dropdowns`, `links`, `signIn` when signed out |
|
|
215
|
+
| Session state | `[signedIn]="signedIn"` | `[signedIn]="signedIn()"` | `true` → built-in signed-in nav |
|
|
216
|
+
| User name | `[userName]="userName"` | `[userName]="userName()"` | Manage Account label when signed in |
|
|
217
|
+
| Auth click | `(wegAuthClick)="onAuthClick($event)"` | `detail.action`: `'sign-in'` \| `'sign-out'` |
|
|
218
|
+
| Prevent default | `preventDefault()` in handler | Stops component default navigation |
|
|
219
|
+
|
|
220
|
+
**Signed-in nav (built in):** Find a job, Dashboard, Manage Account, Sign out.
|
|
221
|
+
|
|
222
|
+
Logo **image** is bundled. Logo **link** uses `layout.header.logoHref` when signed out.
|
|
223
|
+
|
|
224
|
+
## Footer
|
|
225
|
+
|
|
226
|
+
`<weg-footer>` only needs `[layout]`. See [`dummy-data.json`](../src/assets/dummy-data.json) for `footer` shape.
|
|
227
|
+
|
|
228
|
+
## Troubleshooting
|
|
229
|
+
|
|
230
|
+
| Symptom | Cause / fix |
|
|
231
|
+
| --- | --- |
|
|
232
|
+
| `'weg-header'` / `'weg-footer'` is not a known element | `CUSTOM_ELEMENTS_SCHEMA` on the template's component |
|
|
233
|
+
| Header/footer empty | `defineCustomElements()` before bootstrap, or missing `[layout]` |
|
|
234
|
+
| Nav empty after passing an array | `[layout]` must be `{ header, footer }`, not a bare array |
|
|
235
|
+
| Auth always Sign in | `[signedIn]` not bound or still `false` |
|
|
236
|
+
| Manage Account generic | `[userName]` not set when signed in |
|
|
237
|
+
| SSR: `document is not defined` | Guard `defineCustomElements()` with `typeof window !== 'undefined'` |
|
|
238
|
+
|
|
239
|
+
More detail: **[integration guide § Troubleshooting](./angular-integration-guide.md#troubleshooting)**.
|
|
240
|
+
|
|
241
|
+
## See also
|
|
242
|
+
|
|
243
|
+
- **[Angular integration guide (step-by-step)](./angular-integration-guide.md)**
|
|
244
|
+
- **[React SPA](./react.md)**
|
|
245
|
+
- **[Next.js App Router](./nextjs.md)**
|
|
246
|
+
- **[Plain HTML / vanilla JS](./vanilla.md)**
|
|
247
|
+
- **[Package readme](../readme.md)**
|