weg-shared-layout 0.0.24 → 0.0.26

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.
Files changed (43) hide show
  1. package/LICENSE +21 -21
  2. package/dist/cjs/weg-footer_2.cjs.entry.js +218 -193
  3. package/dist/collection/components/weg-footer/icons/instagram.svg +5 -5
  4. package/dist/collection/components/weg-footer/icons/linkedin.svg +3 -3
  5. package/dist/collection/components/weg-footer/icons/tiktok.svg +3 -3
  6. package/dist/collection/components/weg-footer/icons/youtube.svg +4 -4
  7. package/dist/collection/components/weg-footer/weg-footer.css +270 -218
  8. package/dist/collection/components/weg-footer/weg-footer.js +22 -26
  9. package/dist/collection/components/weg-header/weg-header.css +474 -473
  10. package/dist/collection/components/weg-header/weg-header.js +143 -139
  11. package/dist/collection/styles/shared.css +72 -72
  12. package/dist/collection/utils/layout.js +57 -9
  13. package/dist/components/p-BnMIy-A5.js +1 -0
  14. package/dist/components/weg-footer.js +1 -1
  15. package/dist/components/weg-header.js +1 -1
  16. package/dist/esm/weg-footer_2.entry.js +218 -193
  17. package/dist/types/components/weg-footer/weg-footer.d.ts +2 -2
  18. package/dist/types/components/weg-header/weg-header.d.ts +14 -11
  19. package/dist/types/components.d.ts +6 -6
  20. package/dist/types/types/layout-data.d.ts +13 -27
  21. package/dist/types/utils/layout.d.ts +9 -1
  22. package/dist/weg-shared-layout/p-e6eadfa1.entry.js +1 -0
  23. package/dist/weg-shared-layout/weg-shared-layout.esm.js +1 -1
  24. package/docs/angular-16-compatibility.md +235 -0
  25. package/docs/angular-integration-guide.md +1008 -1026
  26. package/docs/angular.md +232 -247
  27. package/docs/nextjs.md +306 -305
  28. package/docs/publishing.md +48 -48
  29. package/docs/react.md +261 -261
  30. package/docs/vanilla.md +138 -140
  31. package/package.json +5 -2
  32. package/readme.md +83 -108
  33. package/src/assets/dummy-data.json +221 -147
  34. package/src/constants/breakpoints.ts +7 -7
  35. package/dist/collection/components/weg-header/signed-in-layout.js +0 -13
  36. package/dist/collection/constants/weg-urls.js +0 -18
  37. package/dist/components/p-DbIEJ3IT.js +0 -1
  38. package/dist/types/components/weg-header/signed-in-layout.d.ts +0 -18
  39. package/dist/types/constants/weg-urls.d.ts +0 -18
  40. package/dist/weg-shared-layout/p-c6ec3888.entry.js +0 -1
  41. package/src/constants/weg-urls.ts +0 -23
  42. /package/dist/types/Users/{rakin/Documents/WEG/repos → tan/Documents/code}/weg-shared-layout/.stencil/test-utils/axe.d.ts +0 -0
  43. /package/dist/types/Users/{rakin/Documents/WEG/repos → tan/Documents/code}/weg-shared-layout/.stencil/test-utils/viewport.d.ts +0 -0
package/docs/vanilla.md CHANGED
@@ -1,140 +1,138 @@
1
- # Plain HTML / vanilla JS
2
-
3
- ## What you get
4
-
5
- | Tag | Purpose |
6
- | --- | --- |
7
- | `<weg-header>` | Site header — bundled logo, CMS nav (signed out), built-in nav (signed in), Sign in / Manage Account / Sign out |
8
- | `<weg-footer>` | Site footer — social links, columns, credits, copyright |
9
-
10
- Both components are **presentational**: they do **not** fetch data. Pass the same `layout` payload to each.
11
-
12
- Payload shape: [`dummy-data.json`](../src/assets/dummy-data.json) (see [readme](../readme.md#how-it-works)).
13
-
14
- ## Install & register
15
-
16
- With a bundler that resolves `node_modules` imports:
17
-
18
- ```html
19
- <weg-header id="header"></weg-header>
20
- <main><!-- your content --></main>
21
- <weg-footer id="footer"></weg-footer>
22
-
23
- <script type="module">
24
- import { defineCustomElements } from 'weg-shared-layout/loader';
25
- import layout from 'weg-shared-layout/dummy-data.json';
26
- import { ACCOUNT_LOGIN_HREF, HEADER_SIGN_IN } from './auth.js';
27
-
28
- defineCustomElements();
29
-
30
- const header = document.getElementById('header');
31
- const footer = document.getElementById('footer');
32
-
33
- header.layout = layout;
34
- footer.layout = layout;
35
- </script>
36
- ```
37
-
38
- Side-effect imports (no loader) if you only need specific tags:
39
-
40
- ```js
41
- import 'weg-shared-layout/weg-header';
42
- import 'weg-shared-layout/weg-footer';
43
- ```
44
-
45
- ## `layout` property vs attribute
46
-
47
- Assign the **`layout` JavaScript property** (recommended):
48
-
49
- ```js
50
- element.layout = layoutObject;
51
- ```
52
-
53
- Or pass a JSON **string** on the `layout` attribute:
54
-
55
- ```html
56
- <weg-header layout='{"header":{"links":[]}}'></weg-header>
57
- ```
58
-
59
- ## Header layout fields (signed out)
60
-
61
- | Field | Purpose |
62
- | --- | --- |
63
- | `header.logoHref` | Logo link target (defaults to WEG home) |
64
- | `header.dropdowns` | Dropdown menus from CMS |
65
- | `header.links` | Flat nav links from CMS |
66
- | `header.signIn` | Sign in button `{ label, href }` |
67
-
68
- See [`dummy-data.json`](../src/assets/dummy-data.json) for production URL examples.
69
-
70
- ## Header auth (Sign in / Sign out)
71
-
72
- Define auth URLs in `./auth.js`:
73
-
74
- ```js
75
- export const HEADER_SIGN_IN = {
76
- label: 'Sign in',
77
- href: 'https://account.warwickemploymentgroup.com/account/login',
78
- };
79
-
80
- export const ACCOUNT_LOGIN_HREF = HEADER_SIGN_IN.href;
81
- ```
82
-
83
- ### Signed out
84
-
85
- Renders `dropdowns`, `links`, and `signIn` from `layout`.
86
-
87
- ### Signed in
88
-
89
- Set **`signedIn`** and optionally **`userName`**. CMS nav is ignored; built-in links are shown (Find a job, Dashboard, Manage Account, Sign out).
90
-
91
- ```js
92
- header.signedIn = true;
93
- header.userName = 'Alex';
94
- // or
95
- header.setAttribute('signed-in', '');
96
- header.setAttribute('user-name', 'Alex');
97
- ```
98
-
99
- Listen for **`wegAuthClick`**:
100
-
101
- ```js
102
- import { ACCOUNT_LOGIN_HREF, HEADER_SIGN_IN } from './auth.js';
103
-
104
- header.addEventListener('wegAuthClick', (event) => {
105
- event.preventDefault();
106
-
107
- if (event.detail.action === 'sign-out') {
108
- header.signedIn = false;
109
- window.location.href = ACCOUNT_LOGIN_HREF;
110
- return;
111
- }
112
-
113
- window.location.href = layout.header.signIn?.href ?? HEADER_SIGN_IN.href;
114
- });
115
- ```
116
-
117
- | `event.detail.action` | Default behaviour if not prevented |
118
- | --- | --- |
119
- | `'sign-in'` | Browser follows `signIn.href` |
120
- | `'sign-out'` | Redirects to built-in sign-out URL |
121
-
122
- Logo **image** is bundled. Logo **link** uses `layout.header.logoHref` when signed out.
123
-
124
- ## Without a bundler
125
-
126
- Copy `dummy-data.json` to your static assets, `fetch` it, parse JSON, then assign properties:
127
-
128
- ```js
129
- const res = await fetch('/assets/dummy-data.json');
130
- const layout = await res.json();
131
- document.getElementById('header').layout = layout;
132
- document.getElementById('footer').layout = layout;
133
- ```
134
-
135
- ## See also
136
-
137
- - **[React SPA](./react.md)**
138
- - **[Next.js App Router](./nextjs.md)**
139
- - **[Angular](./angular.md)**
140
- - **[Package readme](../readme.md)**
1
+ # Plain HTML / vanilla JS
2
+
3
+ ## What you get
4
+
5
+ | Tag | Purpose |
6
+ | --- | --- |
7
+ | `<weg-header>` | Site header — bundled logo, CMS nav (signed out), built-in nav (signed in), Sign in / Manage Account / Sign out |
8
+ | `<weg-footer>` | Site footer — social links, menu, credits, copyright |
9
+
10
+ Both components are **presentational**: they do **not** fetch data. Pass the same `layout` payload to each.
11
+
12
+ Payload shape: [`dummy-data.json`](../src/assets/dummy-data.json) (see [readme](../readme.md#how-it-works)).
13
+
14
+ ## Install & register
15
+
16
+ With a bundler that resolves `node_modules` imports:
17
+
18
+ ```html
19
+ <weg-header id="header"></weg-header>
20
+ <main><!-- your content --></main>
21
+ <weg-footer id="footer"></weg-footer>
22
+
23
+ <script type="module">
24
+ import { defineCustomElements } from 'weg-shared-layout/loader';
25
+ import layout from 'weg-shared-layout/dummy-data.json';
26
+ import { ACCOUNT_LOGIN_HREF, HEADER_SIGN_IN } from './auth.js';
27
+
28
+ defineCustomElements();
29
+
30
+ const header = document.getElementById('header');
31
+ const footer = document.getElementById('footer');
32
+
33
+ header.layout = layout;
34
+ footer.layout = layout;
35
+ </script>
36
+ ```
37
+
38
+ Side-effect imports (no loader) if you only need specific tags:
39
+
40
+ ```js
41
+ import 'weg-shared-layout/weg-header';
42
+ import 'weg-shared-layout/weg-footer';
43
+ ```
44
+
45
+ ## `layout` property vs attribute
46
+
47
+ Assign the **`layout` JavaScript property** (recommended):
48
+
49
+ ```js
50
+ element.layout = layoutObject;
51
+ ```
52
+
53
+ Or pass a JSON **string** on the `layout` attribute:
54
+
55
+ ```html
56
+ <weg-header layout='{"header":{"menu":[]}}'></weg-header>
57
+ ```
58
+
59
+ ## Header layout fields (signed out)
60
+
61
+ | Field | Purpose |
62
+ | --- | --- |
63
+ | `header.logoSrc` | Logo image URL (bundled if omitted) |
64
+ | `header.menu` | Unified nav — groups with `items[]`, flat links with `href` (incl. Sign in) |
65
+
66
+ See [`dummy-data.json`](../src/assets/dummy-data.json) for production URL examples.
67
+
68
+ ## Header auth (Sign in / Sign out)
69
+
70
+ Define auth URLs in `./auth.js`:
71
+
72
+ ```js
73
+ export const HEADER_SIGN_IN = {
74
+ label: 'Sign in',
75
+ href: 'https://account.warwickemploymentgroup.com/account/login',
76
+ };
77
+
78
+ export const ACCOUNT_LOGIN_HREF = HEADER_SIGN_IN.href;
79
+ ```
80
+
81
+ ### Signed out
82
+
83
+ Renders `header.menu` from `layout` — dropdown groups, flat links, and the Sign in entry (label **Sign in** fires `wegAuthClick`).
84
+
85
+ ### Signed in
86
+
87
+ Set **`signedIn`** and optionally **`userName`**. CMS nav is ignored; built-in links are shown (Find a job, Dashboard, Manage Account, Sign out).
88
+
89
+ ```js
90
+ header.signedIn = true;
91
+ header.userName = 'Alex';
92
+ // or
93
+ header.setAttribute('signed-in', '');
94
+ header.setAttribute('user-name', 'Alex');
95
+ ```
96
+
97
+ Listen for **`wegAuthClick`**:
98
+
99
+ ```js
100
+ import { ACCOUNT_LOGIN_HREF, HEADER_SIGN_IN } from './auth.js';
101
+
102
+ header.addEventListener('wegAuthClick', (event) => {
103
+ event.preventDefault();
104
+
105
+ if (event.detail.action === 'sign-out') {
106
+ header.signedIn = false;
107
+ window.location.href = ACCOUNT_LOGIN_HREF;
108
+ return;
109
+ }
110
+
111
+ window.location.href = HEADER_SIGN_IN.href;
112
+ });
113
+ ```
114
+
115
+ | `event.detail.action` | Default behaviour if not prevented |
116
+ | --- | --- |
117
+ | `'sign-in'` | Browser follows the Sign in menu entry's `href` |
118
+ | `'sign-out'` | Redirects to built-in sign-out URL |
119
+
120
+ Logo **image** uses `header.logoSrc` (bundled if omitted). Logo **link** always goes to WEG home.
121
+
122
+ ## Without a bundler
123
+
124
+ Copy `dummy-data.json` to your static assets, `fetch` it, parse JSON, then assign properties:
125
+
126
+ ```js
127
+ const res = await fetch('/assets/dummy-data.json');
128
+ const layout = await res.json();
129
+ document.getElementById('header').layout = layout;
130
+ document.getElementById('footer').layout = layout;
131
+ ```
132
+
133
+ ## See also
134
+
135
+ - **[React SPA](./react.md)**
136
+ - **[Next.js App Router](./nextjs.md)**
137
+ - **[Angular](./angular.md)**
138
+ - **[Package readme](../readme.md)**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weg-shared-layout",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "description": "Shared layout Web Components built with Stencil",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -27,7 +27,10 @@
27
27
  "import": "./loader/index.js",
28
28
  "require": "./loader/index.cjs.js"
29
29
  },
30
- "./dummy-data.json": "./src/assets/dummy-data.json"
30
+ "./dummy-data.json": "./src/assets/dummy-data.json",
31
+ "./layout-data": {
32
+ "types": "./dist/types/types/layout-data.d.ts"
33
+ }
31
34
  },
32
35
  "repository": {
33
36
  "type": "git",
package/readme.md CHANGED
@@ -1,108 +1,83 @@
1
- [![Built With Stencil](https://img.shields.io/badge/-Built%20With%20Stencil-16161d.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjIuMSwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1MTIgNTEyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI%2BCjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI%2BCgkuc3Qwe2ZpbGw6I0ZGRkZGRjt9Cjwvc3R5bGU%2BCjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik00MjQuNywzNzMuOWMwLDM3LjYtNTUuMSw2OC42LTkyLjcsNjguNkgxODAuNGMtMzcuOSwwLTkyLjctMzAuNy05Mi43LTY4LjZ2LTMuNmgzMzYuOVYzNzMuOXoiLz4KPHBhdGggY2xhc3M9InN0MCIgZD0iTTQyNC43LDI5Mi4xSDE4MC40Yy0zNy42LDAtOTIuNy0zMS05Mi43LTY4LjZ2LTMuNkgzMzJjMzcuNiwwLDkyLjcsMzEsOTIuNyw2OC42VjI5Mi4xeiIvPgo8cGF0aCBjbGFzcz0ic3QwIiBkPSJNNDI0LjcsMTQxLjdIODcuN3YtMy42YzAtMzcuNiw1NC44LTY4LjYsOTIuNy02OC42SDMzMmMzNy45LDAsOTIuNywzMC43LDkyLjcsNjguNlYxNDEuN3oiLz4KPC9zdmc%2BCg%3D%3D&colorA=16161d&style=flat-square)](https://stenciljs.com)
2
-
3
- # weg-shared-layout
4
-
5
- > Shared layout Web Components.
6
-
7
- ## Install
8
-
9
- ```bash
10
- npm i weg-shared-layout
11
- ```
12
-
13
- ## How it works
14
-
15
- `<weg-header>` and `<weg-footer>` are **presentational** Web Components: they do **not** fetch data.
16
-
17
- Load layout JSON from your CMS/API (e.g. [`GET /api/layout`](https://weg-payload-test.vercel.app/api/layout) from WEG CMS) or import [`dummy-data.json`](src/assets/dummy-data.json), then pass it to `layout` on each tag.
18
-
19
- ### Layout shape (abbreviated)
20
-
21
- Full reference: [`src/assets/dummy-data.json`](src/assets/dummy-data.json). This package keeps auth URLs in [`src/constants/weg-urls.ts`](src/constants/weg-urls.ts) for the signed-in nav and docs — **host apps should define their own constants file** (e.g. `auth.ts`) rather than importing from the package.
22
-
23
- ```json
24
- {
25
- "header": {
26
- "logoHref": "…",
27
- "dropdowns": [{ "label": "Find a job", "items": [{ "label": "Graduates", "href": "…" }] }],
28
- "links": [{ "label": "Career advice", "href": "…" }, { "label": "Register", "href": "…" }],
29
- "signIn": { "label": "Sign in", "href": "…" }
30
- },
31
- "footer": {
32
- "social": [{ "platform": "LinkedIn", "href": "…" }],
33
- "columns": [{ "links": [{ "label": "About WEG", "href": "…" }] }],
34
- "credits": "…",
35
- "copyright": "…"
36
- }
37
- }
38
- ```
39
-
40
- Use **`dummy-data.json`** for full production URLs. In your app, keep sign-in/out URLs in a local constants file:
41
-
42
- ```ts
43
- // auth.ts (host app — example)
44
- export const HEADER_SIGN_IN = {
45
- label: 'Sign in',
46
- href: 'https://account.warwickemploymentgroup.com/account/login',
47
- };
48
-
49
- export const ACCOUNT_LOGIN_HREF = HEADER_SIGN_IN.href;
50
- ```
51
-
52
- | Field | Used when | Notes |
53
- | --- | --- | --- |
54
- | `header.logoHref` | Always (signed out) | Logo link target. Defaults to WEG home if omitted. Logo image is bundled. |
55
- | `header.dropdowns` | Signed out | CMS-managed dropdown menus |
56
- | `header.links` | Signed out | CMS-managed flat nav links |
57
- | `header.signIn` | Signed out | Sign in button label + href |
58
- | `footer.*` | Always | Social, columns, credits, copyright |
59
-
60
- ### Auth (Sign in / Sign out)
61
-
62
- **Signed out** (`signed-in` false): renders `dropdowns`, `links`, and `signIn` from `layout`.
63
-
64
- **Signed in** (`signed-in` true): **ignores** CMS nav and shows built-in links:
65
-
66
- - Find a job
67
- - Dashboard
68
- - Manage Account (profile icon + `user-name`, or "Manage Account" if omitted)
69
- - Sign out (with icon)
70
-
71
- Set **`signed-in`** from your app session state. Pass **`user-name`** with the user's first name for Manage Account.
72
-
73
- Listen for **`wegAuthClick`** to handle sign-in routing or sign-out logic. Call `event.preventDefault()` to stop default navigation.
74
-
75
- ```js
76
- // auth.ts
77
- const HEADER_SIGN_IN = {
78
- label: 'Sign in',
79
- href: 'https://account.warwickemploymentgroup.com/account/login',
80
- };
81
-
82
- header.signedIn = true;
83
- header.userName = 'Alex';
84
- header.addEventListener('wegAuthClick', (event) => {
85
- event.preventDefault();
86
- if (event.detail.action === 'sign-out') logout();
87
- else window.location.href = layout.header.signIn?.href ?? HEADER_SIGN_IN.href;
88
- });
89
- ```
90
-
91
- - **From npm:** `import layout from 'weg-shared-layout/dummy-data.json'` (enable `resolveJsonModule` in TypeScript if needed).
92
- - **In this repo:** [`src/assets/dummy-data.json`](src/assets/dummy-data.json)
93
-
94
- ## Framework guides
95
-
96
- | Guide | Doc |
97
- | --- | --- |
98
- | Angular (quick start) | [docs/angular.md](./docs/angular.md) |
99
- | Angular (step-by-step integration) | [docs/angular-integration-guide.md](./docs/angular-integration-guide.md) |
100
- | React (SPA, client-only) | [docs/react.md](./docs/react.md) |
101
- | Next.js (App Router) | [docs/nextjs.md](./docs/nextjs.md) |
102
- | Plain HTML / vanilla JS | [docs/vanilla.md](./docs/vanilla.md) |
103
-
104
- ## Publishing (maintainers)
105
-
106
- **`npm publish` does not run `npm run build` by itself** — it packs what is on disk. This package uses a **`prepack`** script so a full Stencil build runs before every `npm pack` / `npm publish`, avoiding incomplete tarballs.
107
-
108
- Details, checklist, and CI notes: **[docs/publishing.md](./docs/publishing.md)**.
1
+ [![Built With Stencil](https://img.shields.io/badge/-Built%20With%20Stencil-16161d.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjIuMSwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1MTIgNTEyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI%2BCjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI%2BCgkuc3Qwe2ZpbGw6I0ZGRkZGRjt9Cjwvc3R5bGU%2BCjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik00MjQuNywzNzMuOWMwLDM3LjYtNTUuMSw2OC42LTkyLjcsNjguNkgxODAuNGMtMzcuOSwwLTkyLjctMzAuNy05Mi43LTY4LjZ2LTMuNmgzMzYuOVYzNzMuOXoiLz4KPHBhdGggY2xhc3M9InN0MCIgZD0iTTQyNC43LDI5Mi4xSDE4MC40Yy0zNy42LDAtOTIuNy0zMS05Mi43LTY4LjZ2LTMuNkgzMzJjMzcuNiwwLDkyLjcsMzEsOTIuNyw2OC42VjI5Mi4xeiIvPgo8cGF0aCBjbGFzcz0ic3QwIiBkPSJNNDI0LjcsMTQxLjdIODcuN3YtMy42YzAtMzcuNiw1NC44LTY4LjYsOTIuNy02OC42SDMzMmMzNy45LDAsOTIuNywzMC43LDkyLjcsNjguNlYxNDEuN3oiLz4KPC9zdmc%2BCg%3D%3D&colorA=16161d&style=flat-square)](https://stenciljs.com)
2
+
3
+ # weg-shared-layout
4
+
5
+ > Shared layout Web Components.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm i weg-shared-layout
11
+ ```
12
+
13
+ ## How it works
14
+
15
+ `<weg-header>` and `<weg-footer>` are **presentational** Web Components: they do **not** fetch data.
16
+
17
+ Load layout JSON from your CMS/API (e.g. [`GET /api/layout`](https://weg-payload-test.vercel.app/api/layout) from WEG CMS) or import [`dummy-data.json`](src/assets/dummy-data.json), then pass it to `layout` on each tag.
18
+
19
+ ### Layout shape (abbreviated)
20
+
21
+ Full reference: [`src/assets/dummy-data.json`](src/assets/dummy-data.json). Sign-in is a normal `header.menu` entry labelled **Sign in**; it fires `wegAuthClick`. Signed-in nav is built into `<weg-header>` when `signed-in` is true.
22
+
23
+ ```json
24
+ {
25
+ "header": {
26
+ "menu": [
27
+ { "label": "Find a job", "items": [{ "label": "Graduates", "href": "…" }] },
28
+ { "label": "Career advice", "href": "…" },
29
+ { "label": "Sign in", "href": "…" }
30
+ ]
31
+ },
32
+ "footer": {
33
+ "menu": [[{ "label": "About WEG", "href": "…" }]],
34
+ "social": [{ "platform": "LinkedIn", "href": "…" }],
35
+ "credits": "…",
36
+ "copyright": "…"
37
+ }
38
+ }
39
+ ```
40
+
41
+ | Field | Used when | Notes |
42
+ | --- | --- | --- |
43
+ | `header.logoSrc` | Signed out | Optional CMS logo URL; bundled PNG if omitted |
44
+ | `header.menu` | Signed out | Groups use `items`; flat links use `href` |
45
+ | `footer.menu` | Always | `LayoutLink[][]` — one column per inner array |
46
+ | `footer.social` | Always | LinkedIn, Instagram, TikTok, or YouTube |
47
+ | `footer.credits` / `footer.copyright` | Always | Legal copy |
48
+
49
+ ### Auth (Sign in / Sign out)
50
+
51
+ **Signed out**: renders `header.menu`. The Sign in entry fires `wegAuthClick` with action `sign-in`.
52
+
53
+ **Signed in** (`signed-in` true): ignores CMS `header.menu` and shows built-in Find a job, Dashboard, Manage Account, and Sign out.
54
+
55
+ Set **`signed-in`** from your app session state. Pass **`user-name`** for Manage Account.
56
+
57
+ ```js
58
+ header.addEventListener('wegAuthClick', (event) => {
59
+ event.preventDefault();
60
+ if (event.detail.action === 'sign-out') logout();
61
+ else window.location.href = HEADER_SIGN_IN.href;
62
+ });
63
+ ```
64
+
65
+ - **From npm:** `import layout from 'weg-shared-layout/dummy-data.json'` (enable `resolveJsonModule` in TypeScript if needed).
66
+ - **In this repo:** [`src/assets/dummy-data.json`](src/assets/dummy-data.json)
67
+
68
+ ## Framework guides
69
+
70
+ | Guide | Doc |
71
+ | --- | --- |
72
+ | Angular (quick start) | [docs/angular.md](./docs/angular.md) |
73
+ | Angular (step-by-step integration) | [docs/angular-integration-guide.md](./docs/angular-integration-guide.md) |
74
+ | Angular 16 / TypeScript 4.9 | [docs/angular-16-compatibility.md](./docs/angular-16-compatibility.md) |
75
+ | React (SPA, client-only) | [docs/react.md](./docs/react.md) |
76
+ | Next.js (App Router) | [docs/nextjs.md](./docs/nextjs.md) |
77
+ | Plain HTML / vanilla JS | [docs/vanilla.md](./docs/vanilla.md) |
78
+
79
+ ## Publishing (maintainers)
80
+
81
+ **`npm publish` does not run `npm run build` by itself** — it packs what is on disk. This package uses a **`prepack`** script so a full Stencil build runs before every `npm pack` / `npm publish`, avoiding incomplete tarballs.
82
+
83
+ Details, checklist, and CI notes: **[docs/publishing.md](./docs/publishing.md)**.