@devopsplaybook.io/common-web 0.11.0 → 0.12.0-beta.20.8d8d60f
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/CHANGELOG.md +32 -0
- package/README.md +48 -7
- package/assets/css/app-shell.css +2 -0
- package/assets/css/tokens.css +4 -0
- package/components/AlertMessages.vue +86 -16
- package/components/AppNavigation.vue +24 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,38 @@ All notable changes to this project are documented here.
|
|
|
5
5
|
This project follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|
6
6
|
and [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.12.0] - 2026-11-01
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Per-message **Dismiss** button on `AlertMessages`: a native, keyboard-operable
|
|
13
|
+
`type="button"` with the accessible name `Dismiss`, so sticky alerts can be
|
|
14
|
+
closed with the mouse or the keyboard.
|
|
15
|
+
- Optional `label` prop on `AppNavigation` (default `Main navigation`), so two
|
|
16
|
+
navigations on one page are distinguishable to screen readers.
|
|
17
|
+
- `.page-layout` and `.page-alert-messages` class hooks in the app shell.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Dark mode defines `--color-primary` (`#ff8a80`) and `--color-primary-hover`
|
|
22
|
+
(`#ffb4ab`), which meet WCAG AA on the shipped dark surfaces.
|
|
23
|
+
- The contrast gate covers text, muted text, primary and primary hover on both
|
|
24
|
+
shipped surfaces in both themes, in addition to every status pair.
|
|
25
|
+
- `AlertMessages` clamps negative `durationMs` values to `0` and uses the
|
|
26
|
+
five-second default for non-finite values.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- M5: sticky alerts are dismissible instead of being kept forever.
|
|
31
|
+
- L3: dark-mode primary and hover text reach WCAG AA.
|
|
32
|
+
- L5: navigation instances are distinguishable and duplicate link targets no
|
|
33
|
+
longer break rendering.
|
|
34
|
+
- L6: error alerts are announced assertively in a sibling region and
|
|
35
|
+
`durationMs` is validated.
|
|
36
|
+
- L7: app-shell hooks are documented classes, with the legacy IDs retained.
|
|
37
|
+
|
|
38
|
+
No dependency changed and no OpenTelemetry metric is added in this release.
|
|
39
|
+
|
|
8
40
|
## [0.11.0] - 2026-11-01
|
|
9
41
|
|
|
10
42
|
### Added
|
package/README.md
CHANGED
|
@@ -26,16 +26,22 @@ required. The `playground/` directory demonstrates a consuming app.
|
|
|
26
26
|
| Component | Purpose |
|
|
27
27
|
| --- | --- |
|
|
28
28
|
| `<Loading size="small" />` | Accessible loading indicator; `size` is `small` or `large`. The animation is disabled under `prefers-reduced-motion: reduce`. |
|
|
29
|
-
| `<AlertMessages />` | Accessible live
|
|
30
|
-
| `<AppNavigation :links="links" :link-component="NuxtLink" />` | Navigation shell with a named `brand` slot
|
|
29
|
+
| `<AlertMessages />` | Accessible live regions displaying messages emitted on `EventBus`, each with a per-message **Dismiss** button. |
|
|
30
|
+
| `<AppNavigation :links="links" :link-component="NuxtLink" label="Primary" />` | Navigation shell with a named `brand` slot, configurable links (`label`, `to`, optional `icon` and `active`) and an optional accessible `label`. |
|
|
31
31
|
| `<OfflineBanner message="You are offline." />` | Announces offline status and accepts replacement content through its default slot. |
|
|
32
32
|
|
|
33
33
|
`AlertMessages` listens for `EventTypes.ALERT_MESSAGE` events. Its payload is
|
|
34
34
|
`{ text, type?, durationMs? }` with `type` limited to `info`, `success`,
|
|
35
35
|
`warning` or `error`. The default display duration is five seconds;
|
|
36
|
-
`durationMs: 0` keeps the message until
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
`durationMs: 0` keeps the message until the user activates its **Dismiss**
|
|
37
|
+
button. Negative durations are clamped to `0`, so they stay until dismissed;
|
|
38
|
+
non-finite values (`NaN`, `Infinity`) use the five-second default. Errors render
|
|
39
|
+
in an assertive `role="alert"` region and the other severities in a polite
|
|
40
|
+
`role="status"` region. The two regions are siblings and are always mounted, so
|
|
41
|
+
each message is announced exactly once. The Dismiss control is a native
|
|
42
|
+
`<button type="button">` with the accessible name `Dismiss` and a visible focus
|
|
43
|
+
ring. Identical `type` + `text` pairs are deduplicated and the queue keeps at
|
|
44
|
+
most five messages, dropping the oldest first. Alert styles use the prefixed
|
|
39
45
|
`.alert-message*` classes, so consumer stylesheets are not affected by the
|
|
40
46
|
layer's global styles. `handleError(error, { debug = false } = {})` logs a
|
|
41
47
|
sanitized summary (message, status, method, path without query string, and
|
|
@@ -59,6 +65,18 @@ const NuxtLink = resolveComponent("NuxtLink");
|
|
|
59
65
|
</template>
|
|
60
66
|
```
|
|
61
67
|
|
|
68
|
+
The `label` prop sets the navigation's accessible name and defaults to
|
|
69
|
+
`Main navigation`. Give each navigation on a page a distinct label so screen
|
|
70
|
+
reader users can tell them apart:
|
|
71
|
+
|
|
72
|
+
```vue
|
|
73
|
+
<AppNavigation :links="primaryLinks" label="Primary" />
|
|
74
|
+
<AppNavigation :links="secondaryLinks" label="Secondary" />
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Links are keyed by target and position, so duplicate `to` targets still render;
|
|
78
|
+
in development the component logs a warning when it detects duplicates.
|
|
79
|
+
|
|
62
80
|
`OfflineBanner` keeps its `role="status"` live region mounted at all times so
|
|
63
81
|
screen readers announce the transition; while online the region is visually
|
|
64
82
|
hidden. The banner renders hidden in server HTML and reflects the real
|
|
@@ -271,8 +289,12 @@ Tokens include `--color-*` (including the per-status foreground tokens
|
|
|
271
289
|
`--app-height`. Dark mode can be selected with `data-theme="dark"` or comes
|
|
272
290
|
from `prefers-color-scheme` when no explicit light preference is set. Status
|
|
273
291
|
colors meet WCAG AA against their `--color-on-*` foreground tokens in both
|
|
274
|
-
themes.
|
|
275
|
-
|
|
292
|
+
themes. `--color-primary` and `--color-primary-hover` are defined in both
|
|
293
|
+
themes and meet AA (4.5:1) on the shipped `--color-surface` and
|
|
294
|
+
`--color-surface-raised` backgrounds. `tests/contrast.spec.ts` gates text,
|
|
295
|
+
muted text, primary, primary hover and the status color pairs in the light and
|
|
296
|
+
both dark blocks. The `dpb-fade-in` and `dpb-blink` helper classes are disabled
|
|
297
|
+
under `prefers-reduced-motion: reduce`.
|
|
276
298
|
|
|
277
299
|
Load app-specific CSS after the layer and redefine only the values you need:
|
|
278
300
|
|
|
@@ -283,6 +305,25 @@ Load app-specific CSS after the layer and redefine only the values you need:
|
|
|
283
305
|
}
|
|
284
306
|
```
|
|
285
307
|
|
|
308
|
+
### App-shell hooks
|
|
309
|
+
|
|
310
|
+
The app-shell stylesheet ships class hooks for the page frame and the
|
|
311
|
+
floating alert container:
|
|
312
|
+
|
|
313
|
+
```vue
|
|
314
|
+
<div class="page-layout">
|
|
315
|
+
<AppNavigation :links="links" />
|
|
316
|
+
<main>
|
|
317
|
+
<NuxtPage />
|
|
318
|
+
<AlertMessages class="page-alert-messages" />
|
|
319
|
+
</main>
|
|
320
|
+
</div>
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
`#page-layout` and `#page-alert-messages` remain supported as legacy aliases
|
|
324
|
+
for existing consumers, so current markup keeps working. Prefer the classes in
|
|
325
|
+
new markup to avoid duplicate-ID collisions when several layouts mount.
|
|
326
|
+
|
|
286
327
|
## Overriding a component
|
|
287
328
|
|
|
288
329
|
Nuxt gives app-local components priority over layer components. Add a component
|
package/assets/css/app-shell.css
CHANGED
package/assets/css/tokens.css
CHANGED
|
@@ -47,6 +47,8 @@
|
|
|
47
47
|
|
|
48
48
|
:root[data-theme="dark"] {
|
|
49
49
|
color-scheme: dark;
|
|
50
|
+
--color-primary: #ff8a80;
|
|
51
|
+
--color-primary-hover: #ffb4ab;
|
|
50
52
|
--color-text: #e0e0e0;
|
|
51
53
|
--color-text-muted: #b0b0b0;
|
|
52
54
|
--color-text-inverse: #fff;
|
|
@@ -69,6 +71,8 @@
|
|
|
69
71
|
@media (prefers-color-scheme: dark) {
|
|
70
72
|
:root:not([data-theme="light"]) {
|
|
71
73
|
color-scheme: dark;
|
|
74
|
+
--color-primary: #ff8a80;
|
|
75
|
+
--color-primary-hover: #ffb4ab;
|
|
72
76
|
--color-text: #e0e0e0;
|
|
73
77
|
--color-text-muted: #b0b0b0;
|
|
74
78
|
--color-text-inverse: #fff;
|
|
@@ -1,30 +1,52 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
<div
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
>
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
<div class="alert-messages">
|
|
3
|
+
<div
|
|
4
|
+
v-for="region in regions"
|
|
5
|
+
:key="region.role"
|
|
6
|
+
:role="region.role"
|
|
7
|
+
:aria-live="region.live"
|
|
8
|
+
aria-atomic="false"
|
|
9
|
+
>
|
|
10
|
+
<div v-for="message in region.messages" :key="message.id">
|
|
11
|
+
<div
|
|
12
|
+
:class="
|
|
13
|
+
message.type
|
|
14
|
+
? `alert-message alert-message-${message.type}`
|
|
15
|
+
: 'alert-message'
|
|
16
|
+
"
|
|
17
|
+
>
|
|
18
|
+
<span class="alert-message-text">
|
|
19
|
+
<b v-if="message.type">{{ message.type }}</b>
|
|
20
|
+
{{ message.text }}
|
|
21
|
+
</span>
|
|
22
|
+
<button
|
|
23
|
+
type="button"
|
|
24
|
+
class="alert-message-dismiss"
|
|
25
|
+
aria-label="Dismiss"
|
|
26
|
+
@click="dismiss(message.id)"
|
|
27
|
+
>
|
|
28
|
+
<span aria-hidden="true">×</span>
|
|
29
|
+
</button>
|
|
30
|
+
</div>
|
|
15
31
|
</div>
|
|
16
32
|
</div>
|
|
17
33
|
</div>
|
|
18
34
|
</template>
|
|
19
35
|
|
|
20
36
|
<script setup lang="ts">
|
|
21
|
-
import { onMounted, onUnmounted, ref } from "vue";
|
|
37
|
+
import { computed, onMounted, onUnmounted, ref } from "vue";
|
|
22
38
|
import { EventBus, EventTypes, type AlertMessage } from "../composables/EventBus";
|
|
23
39
|
|
|
24
40
|
interface DisplayMessage extends AlertMessage {
|
|
25
41
|
id: number;
|
|
26
42
|
}
|
|
27
43
|
|
|
44
|
+
interface AlertRegion {
|
|
45
|
+
role: "status" | "alert";
|
|
46
|
+
live: "polite" | "assertive";
|
|
47
|
+
messages: DisplayMessage[];
|
|
48
|
+
}
|
|
49
|
+
|
|
28
50
|
const DEFAULT_DURATION_MS = 5000;
|
|
29
51
|
const MAX_MESSAGES = 5;
|
|
30
52
|
|
|
@@ -32,6 +54,25 @@ const messages = ref<DisplayMessage[]>([]);
|
|
|
32
54
|
const timers = new Map<number, ReturnType<typeof setTimeout>>();
|
|
33
55
|
let nextId = 1;
|
|
34
56
|
|
|
57
|
+
const regions = computed<AlertRegion[]>(() => [
|
|
58
|
+
{
|
|
59
|
+
role: "status",
|
|
60
|
+
live: "polite",
|
|
61
|
+
messages: messages.value.filter((message) => message.type !== "error"),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
role: "alert",
|
|
65
|
+
live: "assertive",
|
|
66
|
+
messages: messages.value.filter((message) => message.type === "error"),
|
|
67
|
+
},
|
|
68
|
+
]);
|
|
69
|
+
|
|
70
|
+
function normalizeDuration(durationMs: number | undefined): number {
|
|
71
|
+
if (durationMs === undefined) return DEFAULT_DURATION_MS;
|
|
72
|
+
if (!Number.isFinite(durationMs)) return DEFAULT_DURATION_MS;
|
|
73
|
+
return Math.max(0, Math.floor(durationMs));
|
|
74
|
+
}
|
|
75
|
+
|
|
35
76
|
function dismiss(id: number): void {
|
|
36
77
|
const timer = timers.get(id);
|
|
37
78
|
if (timer) {
|
|
@@ -55,11 +96,12 @@ function handleAlert(message: AlertMessage): void {
|
|
|
55
96
|
if (oldest) dismiss(oldest.id);
|
|
56
97
|
}
|
|
57
98
|
|
|
58
|
-
|
|
99
|
+
const duration = normalizeDuration(message.durationMs);
|
|
100
|
+
if (duration === 0) return;
|
|
59
101
|
const timer = setTimeout(() => {
|
|
60
102
|
timers.delete(entry.id);
|
|
61
103
|
dismiss(entry.id);
|
|
62
|
-
},
|
|
104
|
+
}, duration);
|
|
63
105
|
timers.set(entry.id, timer);
|
|
64
106
|
}
|
|
65
107
|
|
|
@@ -75,6 +117,7 @@ onUnmounted(() => {
|
|
|
75
117
|
.alert-message {
|
|
76
118
|
display: flex;
|
|
77
119
|
align-items: center;
|
|
120
|
+
gap: var(--space-sm, 0.5rem);
|
|
78
121
|
padding: var(--space-base, 1rem);
|
|
79
122
|
margin: var(--space-base, 1rem);
|
|
80
123
|
color: var(--color-text-inverse, #fff);
|
|
@@ -85,6 +128,33 @@ onUnmounted(() => {
|
|
|
85
128
|
flex: 1;
|
|
86
129
|
}
|
|
87
130
|
|
|
131
|
+
.alert-message-dismiss {
|
|
132
|
+
display: inline-flex;
|
|
133
|
+
align-items: center;
|
|
134
|
+
justify-content: center;
|
|
135
|
+
flex-shrink: 0;
|
|
136
|
+
min-width: 1.75rem;
|
|
137
|
+
min-height: 1.75rem;
|
|
138
|
+
padding: 0;
|
|
139
|
+
color: inherit;
|
|
140
|
+
font: inherit;
|
|
141
|
+
font-size: 1.25rem;
|
|
142
|
+
line-height: 1;
|
|
143
|
+
background: transparent;
|
|
144
|
+
border: 0;
|
|
145
|
+
border-radius: var(--radius-sm, 0.25rem);
|
|
146
|
+
cursor: pointer;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.alert-message-dismiss:hover {
|
|
150
|
+
background: rgb(255 255 255 / 20%);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.alert-message-dismiss:focus-visible {
|
|
154
|
+
outline: 2px solid currentColor;
|
|
155
|
+
outline-offset: 2px;
|
|
156
|
+
}
|
|
157
|
+
|
|
88
158
|
.alert-message-info,
|
|
89
159
|
.alert-message-success {
|
|
90
160
|
background-color: var(--color-success, #2e7d32);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<nav class="app-navigation" aria-label="
|
|
2
|
+
<nav class="app-navigation" :aria-label="label">
|
|
3
3
|
<div class="app-navigation-brand">
|
|
4
4
|
<slot name="brand" />
|
|
5
5
|
</div>
|
|
6
6
|
<ul class="app-navigation-links">
|
|
7
|
-
<li v-for="link in links" :key="link.to">
|
|
7
|
+
<li v-for="(link, index) in links" :key="`${link.to}::${index}`">
|
|
8
8
|
<component
|
|
9
9
|
:is="linkComponent"
|
|
10
10
|
v-bind="linkProps(link)"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
</template>
|
|
21
21
|
|
|
22
22
|
<script setup lang="ts">
|
|
23
|
-
import type
|
|
23
|
+
import { watch, type Component } from "vue";
|
|
24
24
|
|
|
25
25
|
interface AppNavigationLink {
|
|
26
26
|
label: string;
|
|
@@ -33,8 +33,28 @@ const props = withDefaults(
|
|
|
33
33
|
defineProps<{
|
|
34
34
|
links: AppNavigationLink[];
|
|
35
35
|
linkComponent?: string | Component;
|
|
36
|
+
label?: string;
|
|
36
37
|
}>(),
|
|
37
|
-
{ linkComponent: "a" },
|
|
38
|
+
{ linkComponent: "a", label: "Main navigation" },
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
watch(
|
|
42
|
+
() => props.links,
|
|
43
|
+
(links) => {
|
|
44
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const seen = new Set<string>();
|
|
48
|
+
for (const link of links) {
|
|
49
|
+
if (seen.has(link.to)) {
|
|
50
|
+
console.warn(
|
|
51
|
+
`[AppNavigation] duplicate link target "${link.to}"; links are keyed by target and position.`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
seen.add(link.to);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{ immediate: true, deep: true },
|
|
38
58
|
);
|
|
39
59
|
|
|
40
60
|
function linkProps(link: AppNavigationLink): { href: string } | { to: string } {
|