feat(KB-167): add mobile scroll-snap CSS to board columns
- Add scroll-snap-type: x mandatory to .board in ≤768px media query - Set scroll-snap-align: start and flex-shrink: 0 on .column for swipe navigation - Enable -webkit-overflow-scrolling: touch for smooth iOS scrolling - Add mobile-scroll-snap test suite asserting snap rules inside @media block
This commit is contained in:
39
packages/dashboard/app/__tests__/mobile-scroll-snap.test.ts
Normal file
39
packages/dashboard/app/__tests__/mobile-scroll-snap.test.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import { describe, it, expect } from "vitest";
|
||||||
|
import { readFileSync } from "fs";
|
||||||
|
import { resolve } from "path";
|
||||||
|
|
||||||
|
const css = readFileSync(
|
||||||
|
resolve(__dirname, "../styles.css"),
|
||||||
|
"utf-8",
|
||||||
|
);
|
||||||
|
|
||||||
|
describe("mobile scroll-snap CSS", () => {
|
||||||
|
it("contains scroll-snap-type: x mandatory", () => {
|
||||||
|
expect(css).toContain("scroll-snap-type: x mandatory");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("contains scroll-snap-align: start", () => {
|
||||||
|
expect(css).toContain("scroll-snap-align: start");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("contains -webkit-overflow-scrolling: touch", () => {
|
||||||
|
expect(css).toContain("-webkit-overflow-scrolling: touch");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("contains flex-shrink: 0", () => {
|
||||||
|
expect(css).toContain("flex-shrink: 0");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("scroll-snap rules are inside a @media block", () => {
|
||||||
|
// Extract all @media blocks and verify snap rules exist within one
|
||||||
|
const mediaBlockRegex = /@media\s*\([^)]*max-width:\s*768px[^)]*\)\s*\{/g;
|
||||||
|
const mediaStart = css.search(mediaBlockRegex);
|
||||||
|
expect(mediaStart).toBeGreaterThanOrEqual(0);
|
||||||
|
|
||||||
|
// Get the content after the media query opening
|
||||||
|
const afterMedia = css.slice(mediaStart);
|
||||||
|
// Find the scroll-snap-type within this media block
|
||||||
|
expect(afterMedia).toContain("scroll-snap-type: x mandatory");
|
||||||
|
expect(afterMedia).toContain("scroll-snap-align: start");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1300,6 +1300,23 @@ html, body {
|
|||||||
On narrow viewports (≤768px) the modal goes full-screen, action buttons wrap,
|
On narrow viewports (≤768px) the modal goes full-screen, action buttons wrap,
|
||||||
and spacing is reduced to stay usable on screens as small as 320px. */
|
and spacing is reduced to stay usable on screens as small as 320px. */
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
|
/* Board: horizontal scroll-snap for swipe-between-columns */
|
||||||
|
.board {
|
||||||
|
display: flex;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
scroll-snap-type: x mandatory;
|
||||||
|
padding: 12px;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.board > .column {
|
||||||
|
min-width: 280px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
scroll-snap-align: start;
|
||||||
|
}
|
||||||
|
|
||||||
.modal-overlay {
|
.modal-overlay {
|
||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
|
|||||||
Reference in New Issue
Block a user