fix(webui): make sidebar actions discoverable on touch devices
This commit is contained in:
1 parent
948ce38246
commit
6b24ed80ad
5 files changed
+75
-5
No files matched your search
@@ -7,6 +7,37 @@ import loadConfig from "tailwindcss/loadConfig";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
describe("sidebar touch hover isolation", () => {
|
||||
it("shows sidebar actions with roomy targets only for coarse pointers", async () => {
|
||||
const config = loadConfig(resolve(process.cwd(), "tailwind.config.js"));
|
||||
const source = readFileSync(resolve(process.cwd(), "src/globals.css"), "utf8");
|
||||
const result = await postcss([tailwindcss({ ...config, content: [{
|
||||
raw: 'class="sidebar-action-trigger touch-target opacity-0 h-6 w-6"',
|
||||
}] })]).process(source, { from: undefined });
|
||||
let hiddenIndex = -1;
|
||||
let visibleIndex = -1;
|
||||
let index = 0;
|
||||
let touchTarget = false;
|
||||
result.root.walkRules((rule) => {
|
||||
index++;
|
||||
if (rule.selector === ".opacity-0") hiddenIndex = index;
|
||||
if (rule.selector === ".sidebar-action-trigger") {
|
||||
visibleIndex = index;
|
||||
expect(rule.parent).toMatchObject({ type: "atrule", name: "media", params: "(pointer: coarse)" });
|
||||
expect(rule.nodes).toContainEqual(expect.objectContaining({ prop: "opacity", value: "1" }));
|
||||
}
|
||||
if (rule.selector === ".touch-target") {
|
||||
touchTarget = true;
|
||||
expect(rule.parent).toMatchObject({ type: "atrule", name: "media", params: "(pointer: coarse)" });
|
||||
for (const prop of ["min-width", "min-height"]) {
|
||||
expect(rule.nodes).toContainEqual(expect.objectContaining({ prop, value: "2.75rem" }));
|
||||
}
|
||||
}
|
||||
});
|
||||
expect(hiddenIndex).toBeGreaterThan(0);
|
||||
expect(visibleIndex).toBeGreaterThan(hiddenIndex);
|
||||
expect(touchTarget).toBe(true);
|
||||
});
|
||||
|
||||
it("gates ordinary and named-group hover CSS without gating keyboard focus", async () => {
|
||||
const config = loadConfig(resolve(process.cwd(), "tailwind.config.js"));
|
||||
const source = readFileSync(
|
||||
|
||||
Reference in new issue
Block a user