weg-shared-layout 0.0.32 → 0.0.33
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 +5 -5
- 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 -263
- package/dist/collection/components/weg-footer/weg-footer.js +2 -2
- package/dist/collection/components/weg-header/weg-header.css +483 -483
- package/dist/collection/components/weg-header/weg-header.js +4 -4
- package/dist/collection/styles/shared.css +103 -103
- package/dist/components/weg-footer.js +1 -1
- package/dist/components/weg-header.js +1 -1
- package/dist/esm/weg-footer_2.entry.js +5 -5
- package/dist/weg-shared-layout/p-b38f951e.entry.js +1 -0
- package/dist/weg-shared-layout/weg-shared-layout.esm.js +1 -1
- package/docs/README.md +49 -51
- package/docs/angular.md +402 -258
- package/docs/nextjs.md +314 -314
- package/docs/publishing.md +65 -65
- package/docs/react.md +272 -272
- package/docs/vanilla.md +139 -139
- package/package.json +81 -81
- package/readme.md +95 -97
- package/src/constants/breakpoints.ts +7 -7
- package/src/styles/container.css +60 -60
- package/dist/weg-shared-layout/p-674d7d98.entry.js +0 -1
- package/docs/angular-16-compatibility.md +0 -250
- package/docs/angular-integration-guide.md +0 -1035
- /package/dist/types/Users/{rakin/Documents/WEG/repos → tan/Documents/code}/weg-shared-layout/.stencil/test-utils/axe.d.ts +0 -0
- /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,139 +1,139 @@
|
|
|
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` and package **`exports`** (TypeScript: `resolveJsonModule` + `moduleResolution` `bundler` or `node16` — see [angular
|
|
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
|
-
- **[Documentation index](./README.md)**
|
|
136
|
-
- **[React SPA](./react.md)**
|
|
137
|
-
- **[Next.js App Router](./nextjs.md)**
|
|
138
|
-
- **[Angular](./angular.md)** · **[Angular 16 demo](../demo/angular16/README.md)**
|
|
139
|
-
- **[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` and package **`exports`** (TypeScript: `resolveJsonModule` + `moduleResolution` `bundler` or `node16` — see [angular.md](./angular.md)):
|
|
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
|
+
- **[Documentation index](./README.md)**
|
|
136
|
+
- **[React SPA](./react.md)**
|
|
137
|
+
- **[Next.js App Router](./nextjs.md)**
|
|
138
|
+
- **[Angular](./angular.md)** · **[Angular 16 demo](../demo/angular16/README.md)**
|
|
139
|
+
- **[Package readme](../readme.md)**
|
package/package.json
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "weg-shared-layout",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Shared layout Web Components built with Stencil",
|
|
5
|
-
"main": "dist/index.cjs.js",
|
|
6
|
-
"module": "dist/index.js",
|
|
7
|
-
"types": "dist/types/components.d.ts",
|
|
8
|
-
"collection": "dist/collection/collection-manifest.json",
|
|
9
|
-
"collection:main": "dist/collection/index.js",
|
|
10
|
-
"unpkg": "dist/weg-shared-layout/weg-shared-layout.esm.js",
|
|
11
|
-
"exports": {
|
|
12
|
-
".": {
|
|
13
|
-
"types": "./dist/types/components.d.ts",
|
|
14
|
-
"import": "./dist/weg-shared-layout/weg-shared-layout.esm.js",
|
|
15
|
-
"require": "./dist/weg-shared-layout/weg-shared-layout.cjs.js"
|
|
16
|
-
},
|
|
17
|
-
"./weg-footer": {
|
|
18
|
-
"types": "./dist/components/weg-footer.d.ts",
|
|
19
|
-
"import": "./dist/components/weg-footer.js"
|
|
20
|
-
},
|
|
21
|
-
"./weg-header": {
|
|
22
|
-
"types": "./dist/components/weg-header.d.ts",
|
|
23
|
-
"import": "./dist/components/weg-header.js"
|
|
24
|
-
},
|
|
25
|
-
"./loader": {
|
|
26
|
-
"types": "./loader/index.d.ts",
|
|
27
|
-
"import": "./loader/index.js",
|
|
28
|
-
"require": "./loader/index.cjs.js"
|
|
29
|
-
},
|
|
30
|
-
"./dummy-data.json": "./src/assets/dummy-data.json",
|
|
31
|
-
"./layout-data": {
|
|
32
|
-
"types": "./dist/types/types/layout-data.d.ts"
|
|
33
|
-
},
|
|
34
|
-
"./styles/container.css": "./src/styles/container.css"
|
|
35
|
-
},
|
|
36
|
-
"repository": {
|
|
37
|
-
"type": "git",
|
|
38
|
-
"url": "git+https://github.com/jobsac/weg-shared-layout.git"
|
|
39
|
-
},
|
|
40
|
-
"bugs": {
|
|
41
|
-
"url": "https://github.com/jobsac/weg-shared-layout/issues"
|
|
42
|
-
},
|
|
43
|
-
"homepage": "https://github.com/jobsac/weg-shared-layout#readme",
|
|
44
|
-
"files": [
|
|
45
|
-
"dist/",
|
|
46
|
-
"docs/",
|
|
47
|
-
"loader/",
|
|
48
|
-
"src/assets/dummy-data.json",
|
|
49
|
-
"src/constants/",
|
|
50
|
-
"src/styles/container.css"
|
|
51
|
-
],
|
|
52
|
-
"scripts": {
|
|
53
|
-
"prepack": "npm run build",
|
|
54
|
-
"build": "stencil build",
|
|
55
|
-
"start": "stencil build --dev --watch --serve",
|
|
56
|
-
"test": "stencil-test --prod",
|
|
57
|
-
"test:watch": "stencil-test --prod --watch",
|
|
58
|
-
"generate": "stencil generate",
|
|
59
|
-
"demo:angular16:install": "npm install --prefix demo/angular16",
|
|
60
|
-
"demo:angular16:build": "npm run build && npm run build --prefix demo/angular16",
|
|
61
|
-
"demo:angular16": "npm run build && npm run start --prefix demo/angular16"
|
|
62
|
-
},
|
|
63
|
-
"devDependencies": {
|
|
64
|
-
"@csstools/postcss-global-data": "^4.0.0",
|
|
65
|
-
"@stencil-community/postcss": "^2.2.0",
|
|
66
|
-
"@stencil/core": "^4.27.1 || ^5.0.0-0",
|
|
67
|
-
"@stencil/vitest": "^1.8.3",
|
|
68
|
-
"@types/node": "^22.13.5",
|
|
69
|
-
"@vitest/browser-playwright": "^4.0.0",
|
|
70
|
-
"axe-core": "^4.11.4",
|
|
71
|
-
"playwright": "^1.52.0",
|
|
72
|
-
"postcss-custom-media": "^12.0.1",
|
|
73
|
-
"vitest": "^4.0.0"
|
|
74
|
-
},
|
|
75
|
-
"license": "MIT",
|
|
76
|
-
"author": "WEG",
|
|
77
|
-
"contributors": [
|
|
78
|
-
"Tan Ahmed <tan.ahmed@warwick.ac.uk>",
|
|
79
|
-
"Rakin Ahmed <rakin.ahmed@warwick.ac.uk>"
|
|
80
|
-
]
|
|
81
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "weg-shared-layout",
|
|
3
|
+
"version": "0.0.33",
|
|
4
|
+
"description": "Shared layout Web Components built with Stencil",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/types/components.d.ts",
|
|
8
|
+
"collection": "dist/collection/collection-manifest.json",
|
|
9
|
+
"collection:main": "dist/collection/index.js",
|
|
10
|
+
"unpkg": "dist/weg-shared-layout/weg-shared-layout.esm.js",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/types/components.d.ts",
|
|
14
|
+
"import": "./dist/weg-shared-layout/weg-shared-layout.esm.js",
|
|
15
|
+
"require": "./dist/weg-shared-layout/weg-shared-layout.cjs.js"
|
|
16
|
+
},
|
|
17
|
+
"./weg-footer": {
|
|
18
|
+
"types": "./dist/components/weg-footer.d.ts",
|
|
19
|
+
"import": "./dist/components/weg-footer.js"
|
|
20
|
+
},
|
|
21
|
+
"./weg-header": {
|
|
22
|
+
"types": "./dist/components/weg-header.d.ts",
|
|
23
|
+
"import": "./dist/components/weg-header.js"
|
|
24
|
+
},
|
|
25
|
+
"./loader": {
|
|
26
|
+
"types": "./loader/index.d.ts",
|
|
27
|
+
"import": "./loader/index.js",
|
|
28
|
+
"require": "./loader/index.cjs.js"
|
|
29
|
+
},
|
|
30
|
+
"./dummy-data.json": "./src/assets/dummy-data.json",
|
|
31
|
+
"./layout-data": {
|
|
32
|
+
"types": "./dist/types/types/layout-data.d.ts"
|
|
33
|
+
},
|
|
34
|
+
"./styles/container.css": "./src/styles/container.css"
|
|
35
|
+
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/jobsac/weg-shared-layout.git"
|
|
39
|
+
},
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/jobsac/weg-shared-layout/issues"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/jobsac/weg-shared-layout#readme",
|
|
44
|
+
"files": [
|
|
45
|
+
"dist/",
|
|
46
|
+
"docs/",
|
|
47
|
+
"loader/",
|
|
48
|
+
"src/assets/dummy-data.json",
|
|
49
|
+
"src/constants/",
|
|
50
|
+
"src/styles/container.css"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"prepack": "npm run build",
|
|
54
|
+
"build": "stencil build",
|
|
55
|
+
"start": "stencil build --dev --watch --serve",
|
|
56
|
+
"test": "stencil-test --prod",
|
|
57
|
+
"test:watch": "stencil-test --prod --watch",
|
|
58
|
+
"generate": "stencil generate",
|
|
59
|
+
"demo:angular16:install": "npm install --prefix demo/angular16",
|
|
60
|
+
"demo:angular16:build": "npm run build && npm run build --prefix demo/angular16",
|
|
61
|
+
"demo:angular16": "npm run build && npm run start --prefix demo/angular16"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@csstools/postcss-global-data": "^4.0.0",
|
|
65
|
+
"@stencil-community/postcss": "^2.2.0",
|
|
66
|
+
"@stencil/core": "^4.27.1 || ^5.0.0-0",
|
|
67
|
+
"@stencil/vitest": "^1.8.3",
|
|
68
|
+
"@types/node": "^22.13.5",
|
|
69
|
+
"@vitest/browser-playwright": "^4.0.0",
|
|
70
|
+
"axe-core": "^4.11.4",
|
|
71
|
+
"playwright": "^1.52.0",
|
|
72
|
+
"postcss-custom-media": "^12.0.1",
|
|
73
|
+
"vitest": "^4.0.0"
|
|
74
|
+
},
|
|
75
|
+
"license": "MIT",
|
|
76
|
+
"author": "WEG",
|
|
77
|
+
"contributors": [
|
|
78
|
+
"Tan Ahmed <tan.ahmed@warwick.ac.uk>",
|
|
79
|
+
"Rakin Ahmed <rakin.ahmed@warwick.ac.uk>"
|
|
80
|
+
]
|
|
81
|
+
}
|
package/readme.md
CHANGED
|
@@ -1,97 +1,95 @@
|
|
|
1
|
-
[](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'` — in TypeScript set `resolveJsonModule` and `moduleResolution` to `bundler` or `node16` (see [docs/angular
|
|
66
|
-
- **In this repo:** [`src/assets/dummy-data.json`](src/assets/dummy-data.json)
|
|
67
|
-
|
|
68
|
-
### Package imports (TypeScript / bundlers)
|
|
69
|
-
|
|
70
|
-
| Subpath | Use |
|
|
71
|
-
| --- | --- |
|
|
72
|
-
| `weg-shared-layout/loader` | `defineCustomElements()` — **recommended** |
|
|
73
|
-
| `weg-shared-layout/dummy-data.json` | Sample layout + `typeof` for app types |
|
|
74
|
-
| `weg-shared-layout/layout-data` | Types only (`LayoutData`, …) |
|
|
75
|
-
| `weg-shared-layout/weg-header` / `weg-footer` | Side-effect tag registration |
|
|
76
|
-
| `weg-shared-layout/styles/container.css` | Shared `.container` width and gutter utility |
|
|
77
|
-
|
|
78
|
-
## Documentation
|
|
79
|
-
|
|
80
|
-
Full index: **[docs/README.md](./docs/README.md)**.
|
|
81
|
-
|
|
82
|
-
| Guide | Doc |
|
|
83
|
-
| --- | --- |
|
|
84
|
-
| Angular
|
|
85
|
-
| Angular (
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
Details, checklist, and CI notes: **[docs/publishing.md](./docs/publishing.md)**.
|
|
1
|
+
[](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'` — in TypeScript set `resolveJsonModule` and `moduleResolution` to `bundler` or `node16` (see [docs/angular.md](./docs/angular.md)).
|
|
66
|
+
- **In this repo:** [`src/assets/dummy-data.json`](src/assets/dummy-data.json)
|
|
67
|
+
|
|
68
|
+
### Package imports (TypeScript / bundlers)
|
|
69
|
+
|
|
70
|
+
| Subpath | Use |
|
|
71
|
+
| --- | --- |
|
|
72
|
+
| `weg-shared-layout/loader` | `defineCustomElements()` — **recommended** |
|
|
73
|
+
| `weg-shared-layout/dummy-data.json` | Sample layout + `typeof` for app types |
|
|
74
|
+
| `weg-shared-layout/layout-data` | Types only (`LayoutData`, …) |
|
|
75
|
+
| `weg-shared-layout/weg-header` / `weg-footer` | Side-effect tag registration |
|
|
76
|
+
| `weg-shared-layout/styles/container.css` | Shared `.container` width and gutter utility |
|
|
77
|
+
|
|
78
|
+
## Documentation
|
|
79
|
+
|
|
80
|
+
Full index: **[docs/README.md](./docs/README.md)**.
|
|
81
|
+
|
|
82
|
+
| Guide | Doc |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| Angular 16 | [docs/angular.md](./docs/angular.md) |
|
|
85
|
+
| Angular 16 demo (runnable) | [demo/angular16/README.md](./demo/angular16/README.md) |
|
|
86
|
+
| React (SPA, client-only) | [docs/react.md](./docs/react.md) |
|
|
87
|
+
| Next.js (App Router) | [docs/nextjs.md](./docs/nextjs.md) |
|
|
88
|
+
| Plain HTML / vanilla JS | [docs/vanilla.md](./docs/vanilla.md) |
|
|
89
|
+
| Publishing (maintainers) | [docs/publishing.md](./docs/publishing.md) |
|
|
90
|
+
|
|
91
|
+
## Publishing (maintainers)
|
|
92
|
+
|
|
93
|
+
**`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.
|
|
94
|
+
|
|
95
|
+
Details, checklist, and CI notes: **[docs/publishing.md](./docs/publishing.md)**.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JS media-query strings aligned with `src/styles/breakpoints.css`.
|
|
3
|
-
*/
|
|
4
|
-
export const WEG_MD_MEDIA_QUERY = '(width >= 960px)' as const;
|
|
5
|
-
|
|
6
|
-
/** Primary input can hover (excludes most touch-only profiles). */
|
|
7
|
-
export const WEG_HOVER_CAPABLE_MEDIA_QUERY = '(hover: hover)' as const;
|
|
1
|
+
/**
|
|
2
|
+
* JS media-query strings aligned with `src/styles/breakpoints.css`.
|
|
3
|
+
*/
|
|
4
|
+
export const WEG_MD_MEDIA_QUERY = '(width >= 960px)' as const;
|
|
5
|
+
|
|
6
|
+
/** Primary input can hover (excludes most touch-only profiles). */
|
|
7
|
+
export const WEG_HOVER_CAPABLE_MEDIA_QUERY = '(hover: hover)' as const;
|