@jskit-ai/shell-web 0.2.53 → 0.2.55

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.
@@ -1,6 +1,7 @@
1
1
  <script setup>
2
2
  // A button in each colour that has a container role and each variant, for its label's contrast at rest, hovered,
3
- // focused and pressed: a state layer is drawn under the label, so it is part of what the label is read against.
3
+ // focused and pressed: a state layer is drawn under the label, so it is part of what the label is read against. Each
4
+ // is there again active, as a button whose route is current or whose menu is open is drawn, with its activated layer.
4
5
  const COLORS = Object.freeze(["primary", "secondary", "tertiary", "error", "success", "warning", "info"]);
5
6
  const VARIANTS = Object.freeze(["flat", "elevated", "tonal", "outlined", "text"]);
6
7
  </script>
@@ -18,5 +19,17 @@ const VARIANTS = Object.freeze(["flat", "elevated", "tonal", "outlined", "text"]
18
19
  {{ variant }}
19
20
  </v-btn>
20
21
  </div>
22
+ <div v-for="color in COLORS" :key="`active-${color}`" class="d-flex flex-wrap ga-2">
23
+ <v-btn
24
+ v-for="variant in VARIANTS"
25
+ :key="variant"
26
+ :color="color"
27
+ :variant="variant"
28
+ active
29
+ :data-testid="`active-${color}-${variant}`"
30
+ >
31
+ {{ variant }}
32
+ </v-btn>
33
+ </div>
21
34
  </section>
22
35
  </template>
@@ -116,6 +116,15 @@ function jumpToLastBooking() {
116
116
  </v-list>
117
117
  </v-card>
118
118
  </v-menu>
119
+ <!-- A filled button's menu: Vuetify draws the button as active while its menu is open. -->
120
+ <v-menu>
121
+ <template #activator="{ props: menu }">
122
+ <v-btn color="primary" v-bind="menu">Filled menu</v-btn>
123
+ </template>
124
+ <v-list data-testid="fixture-filled-menu-list">
125
+ <v-list-item title="Second" />
126
+ </v-list>
127
+ </v-menu>
119
128
  </div>
120
129
 
121
130
  <v-btn disabled data-testid="fixture-disabled-button">Update password</v-btn>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/shell-web",
3
- "version": "0.2.53",
3
+ "version": "0.2.55",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "jskit test"
@@ -51,7 +51,7 @@
51
51
  "@jskit-ai/architecture-inspector": "0.1.34"
52
52
  },
53
53
  "devDependencies": {
54
- "@jskit-ai/material-web": "0.1.12",
54
+ "@jskit-ai/material-web": "0.1.14",
55
55
  "@vue/compiler-sfc": "3.5.44"
56
56
  },
57
57
  "peerDependencies": {
@@ -124,36 +124,89 @@ test("a menu mounted while closed covers nothing, and still opens and closes wit
124
124
  await items.evaluate((element) => Promise.all(element.closest(".v-overlay__content").getAnimations().map((animation) => animation.finished)));
125
125
 
126
126
  // Frame by frame from Escape until the overlay is gone: its content animates out while the overlay is still drawn.
127
- const frames = items.evaluate(async (element) => {
127
+ // The page takes the first frame before Escape is pressed: a sampler started beside the key press ran only after a
128
+ // second round trip, which the press overtook, and on a busy host found the menu already closed.
129
+ await items.evaluate((element) => {
128
130
  const content = element.closest(".v-overlay__content");
129
131
  const overlay = content.parentElement;
130
- const seen = [];
131
- const started = performance.now();
132
- while (performance.now() - started < 3000) {
133
- const animating = content.getAnimations().some((animation) => animation.playState === "running");
134
- seen.push({ overlay: getComputedStyle(overlay).display, content: content.style.display || "shown", animating });
135
- if (seen.at(-1).overlay === "none") {
136
- break;
132
+ globalThis.closingMenuFrames = (async () => {
133
+ const seen = [];
134
+ const started = performance.now();
135
+ while (performance.now() - started < 3000) {
136
+ const animating = content.getAnimations().some((animation) => animation.playState === "running");
137
+ seen.push({ overlay: getComputedStyle(overlay).display, content: content.style.display || "shown", animating });
138
+ if (seen.at(-1).overlay === "none") {
139
+ break;
140
+ }
141
+ await new Promise((resolve) => requestAnimationFrame(resolve));
137
142
  }
138
- await new Promise((resolve) => requestAnimationFrame(resolve));
139
- }
140
- return seen;
143
+ return seen;
144
+ })();
141
145
  });
142
146
  await page.keyboard.press("Escape");
143
- const seen = await frames;
147
+ const seen = await page.evaluate(() => globalThis.closingMenuFrames);
144
148
  assert.ok(seen.some((frame) => frame.overlay !== "none" && frame.content === "shown" && frame.animating),
145
149
  `the menu animates out while its overlay is drawn: ${JSON.stringify(seen.filter((_, index) => index % 4 === 0))}`);
146
150
  assert.equal(seen.at(-1).overlay, "none", "once closed, the menu's overlay is gone again");
147
151
  await expect(items).toBeAttached();
148
152
  });
149
153
 
150
- // A state layer lies under the label, so a hovered, focused or pressed button's label is read against its container
151
- // with the layer over it. Material 3's layers (hover 8%, focus and pressed 10%) keep every label at 4.5:1: a filled
152
- // button's on-colour over its colour, a tonal button's on-container colour over its tint.
153
- test("every button's label keeps 4.5:1 at rest, hovered, focused and pressed, in each colour, variant and theme", {
154
+ // An open menu lies over the page only where its content is. Vuetify holds the content in an overlay root that spans
155
+ // the whole window, transparent and taking no clicks, and axe read every text of the page under that root as
156
+ // undecided (bgOverlap): 36 texts on mobilynet's page with its "Add to project" menu open.
157
+ test("an open menu leaves every text beside it judged: only the menu's content lies over the page", {
154
158
  skip: SKIP,
155
- timeout: 180_000
159
+ timeout: 60_000
160
+ }, async (t) => {
161
+ const { vite, browser } = await open(t);
162
+ const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 1280, height: 900 }, reducedMotion: "reduce" });
163
+ t.after(() => page.close());
164
+ await page.goto("/home/components");
165
+ await expect(page.getByTestId("jskit-shell-page-title")).toBeVisible();
166
+ await expectJudged(page, "components at 1280", []);
167
+
168
+ // Each menu opened with the mouse, which stays over its button: Vuetify draws the button as active while its menu is
169
+ // open, and the label is read against the layers it then shows, once the click's ripple has gone (as the button
170
+ // contrast tests wait for it: a released press leaves it fading out for a moment).
171
+ await page.getByRole("button", { name: "Rich menu" }).click();
172
+ await expect(page.getByTestId("fixture-menu-panel")).toBeVisible();
173
+ await expect(page.locator(".v-ripple__container")).toHaveCount(0);
174
+ await expectJudged(page, "components at 1280 with a text button's menu open", []);
175
+ await page.keyboard.press("Escape");
176
+ await expect(page.getByTestId("fixture-menu-panel")).toBeHidden();
177
+
178
+ await page.getByRole("button", { name: "Filled menu" }).click();
179
+ await expect(page.getByTestId("fixture-filled-menu-list")).toBeVisible();
180
+ await expect(page.locator(".v-ripple__container")).toHaveCount(0);
181
+ await expectJudged(page, "components at 1280 with a filled button's menu open", []);
182
+ });
183
+
184
+ // A snackbar's message lies over the page only where it draws: Vuetify holds it in an overlay the size of the window,
185
+ // as it holds a menu. The form's Save reports one, as a saved form does.
186
+ test("a snackbar leaves every text beside it judged: only its message lies over the page", {
187
+ skip: SKIP,
188
+ timeout: 60_000
156
189
  }, async (t) => {
190
+ const { vite, browser } = await open(t);
191
+ const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 1280, height: 900 }, reducedMotion: "reduce" });
192
+ t.after(() => page.close());
193
+ await page.goto("/home/feedback");
194
+ await expect(page.getByTestId("fixture-feedback")).toBeVisible();
195
+ await expectJudged(page, "feedback at 1280", []);
196
+
197
+ // The page's own count is an <output>, a status too; the snackbar's message is the other one.
198
+ await page.getByTestId("fixture-form-save").click();
199
+ await expect(page.getByRole("status").filter({ hasText: "Integration configuration saved." })).toBeVisible();
200
+ await expect(page.locator(".v-ripple__container")).toHaveCount(0);
201
+ await expectJudged(page, "feedback at 1280 with a snackbar shown", []);
202
+ });
203
+
204
+ // A state layer lies under the label, so a hovered, focused or pressed button's label is read against its container
205
+ // with the layer over it. Material 3's layers (hover 8%, focus and pressed 10%) keep every label at 4.5:1: a filled
206
+ // button's on-colour over its colour, a tonal button's on-container colour over its tint. An active button shows one
207
+ // layer at a time over it too, as Material 3 does: Vuetify added its activated layer to the others, 18% or 20% of a
208
+ // text button's colour under its label, which took a primary label to 4.13:1.
209
+ async function expectEveryStateReadable(t, prefix) {
157
210
  const { vite, browser } = await open(t);
158
211
  const failures = [];
159
212
  let judged = 0;
@@ -168,7 +221,7 @@ test("every button's label keeps 4.5:1 at rest, hovered, focused and pressed, in
168
221
  await page.goto(`/home/button-contrast?theme=${theme}`);
169
222
  await expect(page.getByTestId("jskit-shell-page-title")).toHaveText("Button contrast");
170
223
  await page.addScriptTag({ path: AXE_PATH });
171
- const buttons = await page.locator("[data-testid^=contrast-]").all();
224
+ const buttons = await page.locator(`[data-testid^=${prefix}-]`).all();
172
225
  assert.equal(buttons.length, 35, "seven colours in five variants");
173
226
  for (const button of buttons) {
174
227
  const name = await button.getAttribute("data-testid");
@@ -208,4 +261,14 @@ test("every button's label keeps 4.5:1 at rest, hovered, focused and pressed, in
208
261
  }
209
262
  assert.equal(judged, 280, "every button judged in four states and two themes");
210
263
  assert.deepEqual(failures, [], "every label at 4.5:1 or more in every state");
211
- });
264
+ }
265
+
266
+ test("every button's label keeps 4.5:1 at rest, hovered, focused and pressed, in each colour, variant and theme", {
267
+ skip: SKIP,
268
+ timeout: 180_000
269
+ }, (t) => expectEveryStateReadable(t, "contrast"));
270
+
271
+ test("an active button's label keeps 4.5:1 at rest, hovered, focused and pressed, in each colour, variant and theme", {
272
+ skip: SKIP,
273
+ timeout: 180_000
274
+ }, (t) => expectEveryStateReadable(t, "active"));