Compare commits

...

2 Commits

Author SHA1 Message Date
Nico
635347bea2 fix: clarify member map empty state 2026-06-04 21:05:48 -07:00
Nico
4c753579dd fix: stabilize map toolbar controls 2026-06-04 20:54:53 -07:00
5 changed files with 70 additions and 43 deletions

View File

@ -87,7 +87,11 @@ export function LocationMapLayerPanel({ filters, setFilters }) {
setFilters((current) => ({ ...current, [key]: !current[key] })) setFilters((current) => ({ ...current, [key]: !current[key] }))
} }
> >
{label} <span
className={`location-map-layer-state ${filters[key] ? "is-on" : ""}`}
aria-hidden="true"
/>
<span className="location-map-layer-label">{label}</span>
</button> </button>
))} ))}
</div> </div>

View File

@ -15,10 +15,11 @@ export default function LocationMapSetupPanel({
const createBlankLabel = savingAction === "create-blank" ? "Creating..." : "Create Blank Map"; const createBlankLabel = savingAction === "create-blank" ? "Creating..." : "Create Blank Map";
const createZonesButtonLabel = savingAction === "create-zones" ? "Creating..." : createFromZonesLabel; const createZonesButtonLabel = savingAction === "create-zones" ? "Creating..." : createFromZonesLabel;
const publishLabel = savingAction === "publish" ? "Publishing..." : "Publish"; const publishLabel = savingAction === "publish" ? "Publishing..." : "Publish";
const heading = hasAnyMap ? "Draft Map" : canManage ? "No Map" : "No Published Map";
return ( return (
<section className="location-map-setup"> <section className="location-map-setup">
<h2>{hasAnyMap ? "Draft Map" : "No Map"}</h2> <h2>{heading}</h2>
{canManage ? ( {canManage ? (
<div className="location-map-setup-rows" role="group" aria-label="Map setup details"> <div className="location-map-setup-rows" role="group" aria-label="Map setup details">
<div className="location-map-setup-row"> <div className="location-map-setup-row">

View File

@ -66,12 +66,11 @@ export default function LocationMapToolbar({
}) { }) {
const isAtMinZoom = zoom <= MIN_MAP_ZOOM; const isAtMinZoom = zoom <= MIN_MAP_ZOOM;
const isAtMaxZoom = zoom >= MAX_MAP_ZOOM; const isAtMaxZoom = zoom >= MAX_MAP_ZOOM;
const showHistorySlot = canManage && hasAnyMap; const canUseHistoryControls = mode === "edit" && canManage && hasAnyMap;
const canUseHistoryControls = mode === "edit" && showHistorySlot;
return ( return (
<section <section
className={`location-map-toolbar ${showHistorySlot ? "has-history-slot" : ""}`} className={`location-map-toolbar ${canUseHistoryControls ? "has-history-slot" : ""}`}
aria-label="Map controls" aria-label="Map controls"
> >
<div className="location-map-mode-group"> <div className="location-map-mode-group">
@ -100,11 +99,10 @@ export default function LocationMapToolbar({
) : null} ) : null}
</div> </div>
</div> </div>
{showHistorySlot ? ( {canUseHistoryControls ? (
<div <div
className={`location-map-history-buttons ${canUseHistoryControls ? "" : "is-inactive"}`} className="location-map-history-buttons"
aria-label="Edit history" aria-label="Edit history"
aria-hidden={!canUseHistoryControls}
> >
<button <button
type="button" type="button"

View File

@ -200,11 +200,6 @@
gap: 0.3rem; gap: 0.3rem;
} }
.location-map-history-buttons.is-inactive {
visibility: hidden;
pointer-events: none;
}
.location-map-history-buttons button { .location-map-history-buttons button {
min-width: 40px; min-width: 40px;
padding-inline: 0.55rem; padding-inline: 0.55rem;
@ -600,7 +595,7 @@
min-height: 40px; min-height: 40px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: flex-start;
gap: 0.35rem; gap: 0.35rem;
padding: 0.35rem 0.45rem; padding: 0.35rem 0.45rem;
border: 1px solid var(--color-border-light); border: 1px solid var(--color-border-light);
@ -612,6 +607,31 @@
cursor: pointer; cursor: pointer;
} }
.location-map-layer-state {
flex: 0 0 auto;
width: 0.85rem;
height: 0.85rem;
display: inline-flex;
align-items: center;
justify-content: center;
border: 1px solid rgba(148, 163, 184, 0.68);
border-radius: 999px;
background: rgba(2, 6, 23, 0.3);
}
.location-map-layer-state.is-on {
border-color: rgba(96, 165, 250, 0.95);
background: var(--color-primary);
box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.16);
}
.location-map-layer-label {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.location-map-display-controls button.active { .location-map-display-controls button.active {
border-color: rgba(96, 165, 250, 0.76); border-color: rgba(96, 165, 250, 0.76);
background: rgba(59, 130, 246, 0.32); background: rgba(59, 130, 246, 0.32);
@ -1002,7 +1022,7 @@
@media (max-width: 839px) { @media (max-width: 839px) {
.location-map-toolbar { .location-map-toolbar {
--location-map-mode-slot: clamp(132px, 24vw, 188px); --location-map-mode-slot: clamp(168px, 24vw, 188px);
--location-map-history-slot: 84px; --location-map-history-slot: 84px;
display: grid; display: grid;
grid-template-columns: var(--location-map-mode-slot) minmax(0, 1fr); grid-template-columns: var(--location-map-mode-slot) minmax(0, 1fr);
@ -1150,7 +1170,7 @@
} }
.location-map-toolbar { .location-map-toolbar {
--location-map-mode-slot: 132px; --location-map-mode-slot: 168px;
--location-map-history-slot: 84px; --location-map-history-slot: 84px;
column-gap: 0.15rem; column-gap: 0.15rem;
row-gap: 0.35rem; row-gap: 0.35rem;
@ -1169,6 +1189,13 @@
min-width: 28px; min-width: 28px;
} }
.location-map-toolbar.has-history-slot .location-map-zoom-controls {
grid-column: 1 / -1;
width: 100%;
justify-self: stretch;
justify-content: space-between;
}
.location-map-display-controls { .location-map-display-controls {
grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-columns: repeat(2, minmax(0, 1fr));
} }

View File

@ -1409,7 +1409,6 @@ test("mobile keeps viewing draft status compact in the topbar", async ({ page })
const toolbarBox = await toolbar.boundingBox(); const toolbarBox = await toolbar.boundingBox();
const modeGroupBox = await modeGroup.boundingBox(); const modeGroupBox = await modeGroup.boundingBox();
const modeBox = await modeButtons.boundingBox(); const modeBox = await modeButtons.boundingBox();
const reservedHistoryBox = await historyActions.boundingBox();
const zoomBox = await zoomControls.boundingBox(); const zoomBox = await zoomControls.boundingBox();
expect(topbarBox).not.toBeNull(); expect(topbarBox).not.toBeNull();
expect(backButtonBox).not.toBeNull(); expect(backButtonBox).not.toBeNull();
@ -1418,7 +1417,6 @@ test("mobile keeps viewing draft status compact in the topbar", async ({ page })
expect(toolbarBox).not.toBeNull(); expect(toolbarBox).not.toBeNull();
expect(modeGroupBox).not.toBeNull(); expect(modeGroupBox).not.toBeNull();
expect(modeBox).not.toBeNull(); expect(modeBox).not.toBeNull();
expect(reservedHistoryBox).not.toBeNull();
expect(zoomBox).not.toBeNull(); expect(zoomBox).not.toBeNull();
if ( if (
!topbarBox || !topbarBox ||
@ -1428,7 +1426,6 @@ test("mobile keeps viewing draft status compact in the topbar", async ({ page })
!toolbarBox || !toolbarBox ||
!modeGroupBox || !modeGroupBox ||
!modeBox || !modeBox ||
!reservedHistoryBox ||
!zoomBox !zoomBox
) { ) {
throw new Error("Mobile map controls layout was not measurable"); throw new Error("Mobile map controls layout was not measurable");
@ -1440,19 +1437,15 @@ test("mobile keeps viewing draft status compact in the topbar", async ({ page })
expect(statusBox.y).toBeLessThan(titleBox.y + titleBox.height); expect(statusBox.y).toBeLessThan(titleBox.y + titleBox.height);
expect(statusBox.x).toBeGreaterThan(titleBox.x); expect(statusBox.x).toBeGreaterThan(titleBox.x);
expect(toolbarBox.height).toBeLessThanOrEqual(64); expect(toolbarBox.height).toBeLessThanOrEqual(64);
expect(modeBox.width).toBeGreaterThanOrEqual(130); expect(modeBox.width).toBeGreaterThanOrEqual(166);
expect(modeBox.width).toBeLessThanOrEqual(136); expect(modeBox.width).toBeLessThanOrEqual(172);
expect(reservedHistoryBox.width).toBeGreaterThanOrEqual(82); await expect(historyActions).toHaveCount(0);
expect(reservedHistoryBox.x).toBeGreaterThan(modeBox.x + modeBox.width - 1);
await expect(historyActions).toHaveCSS("visibility", "hidden");
await expect(historyActions.locator('button[aria-label="Undo"]')).toBeDisabled();
await expect(historyActions.locator('button[aria-label="Redo"]')).toBeDisabled();
expect(zoomBox.y).toBeLessThan(modeBox.y + modeBox.height); expect(zoomBox.y).toBeLessThan(modeBox.y + modeBox.height);
expect(zoomBox.x).toBeGreaterThan(reservedHistoryBox.x + reservedHistoryBox.width - 1); expect(zoomBox.x).toBeGreaterThan(modeBox.x + modeBox.width - 1);
expect(zoomBox.x + zoomBox.width).toBeLessThanOrEqual(toolbarBox.x + toolbarBox.width + 1); expect(zoomBox.x + zoomBox.width).toBeLessThanOrEqual(toolbarBox.x + toolbarBox.width + 1);
await page.getByRole("button", { name: "Edit Draft" }).click(); await page.getByRole("button", { name: "Edit Draft" }).click();
await expect(historyActions).toHaveCSS("visibility", "visible"); await expect(historyActions).toHaveCount(1);
await expect(historyActions.getByRole("button", { name: "Undo" })).toBeVisible(); await expect(historyActions.getByRole("button", { name: "Undo" })).toBeVisible();
await expect(historyActions.getByRole("button", { name: "Redo" })).toBeVisible(); await expect(historyActions.getByRole("button", { name: "Redo" })).toBeVisible();
const editToolbarBox = await toolbar.boundingBox(); const editToolbarBox = await toolbar.boundingBox();
@ -1471,11 +1464,13 @@ test("mobile keeps viewing draft status compact in the topbar", async ({ page })
expect(Math.abs(editModeBox.x - modeBox.x)).toBeLessThanOrEqual(1); expect(Math.abs(editModeBox.x - modeBox.x)).toBeLessThanOrEqual(1);
expect(Math.abs(editModeGroupBox.width - modeGroupBox.width)).toBeLessThanOrEqual(1); expect(Math.abs(editModeGroupBox.width - modeGroupBox.width)).toBeLessThanOrEqual(1);
expect(Math.abs(editModeBox.width - modeBox.width)).toBeLessThanOrEqual(1); expect(Math.abs(editModeBox.width - modeBox.width)).toBeLessThanOrEqual(1);
expect(editModeBox.width).toBeGreaterThanOrEqual(130); expect(editModeBox.width).toBeGreaterThanOrEqual(166);
expect(editModeBox.width).toBeLessThanOrEqual(136); expect(editModeBox.width).toBeLessThanOrEqual(172);
expect(Math.abs(editHistoryBox.width - reservedHistoryBox.width)).toBeLessThanOrEqual(1); expect(editHistoryBox.width).toBeGreaterThanOrEqual(82);
expect(editHistoryBox.x).toBeGreaterThan(editModeBox.x + editModeBox.width); expect(editHistoryBox.x).toBeGreaterThan(editModeBox.x + editModeBox.width);
expect(editZoomBox.x).toBeGreaterThan(editHistoryBox.x + editHistoryBox.width); expect(editHistoryBox.x + editHistoryBox.width).toBeLessThanOrEqual(editToolbarBox.x + editToolbarBox.width + 1);
expect(editZoomBox.y).toBeGreaterThan(editModeBox.y + editModeBox.height - 1);
expect(editZoomBox.x).toBeGreaterThanOrEqual(editToolbarBox.x);
expect(editZoomBox.x + editZoomBox.width).toBeLessThanOrEqual(editToolbarBox.x + editToolbarBox.width + 1); expect(editZoomBox.x + editZoomBox.width).toBeLessThanOrEqual(editToolbarBox.x + editToolbarBox.width + 1);
}); });
@ -1531,8 +1526,8 @@ test("narrow mobile toolbar keeps map controls tappable without overflow", async
expect(toolbarBox.x).toBeGreaterThanOrEqual(0); expect(toolbarBox.x).toBeGreaterThanOrEqual(0);
expect(toolbarBox.x + toolbarBox.width).toBeLessThanOrEqual(361); expect(toolbarBox.x + toolbarBox.width).toBeLessThanOrEqual(361);
expect(modeBox.width).toBeGreaterThanOrEqual(130); expect(modeBox.width).toBeGreaterThanOrEqual(166);
expect(modeBox.width).toBeLessThanOrEqual(136); expect(modeBox.width).toBeLessThanOrEqual(172);
expect(modeBox.x + modeBox.width).toBeLessThanOrEqual(historyBox.x); expect(modeBox.x + modeBox.width).toBeLessThanOrEqual(historyBox.x);
expect(zoomBox.y).toBeGreaterThan(modeBox.y + modeBox.height - 1); expect(zoomBox.y).toBeGreaterThan(modeBox.y + modeBox.height - 1);
expect(zoomBox.x).toBeGreaterThanOrEqual(toolbarBox.x); expect(zoomBox.x).toBeGreaterThanOrEqual(toolbarBox.x);
@ -2708,11 +2703,14 @@ test("viewer wraps long zone labels and keeps item counts visible", async ({ pag
await page.getByRole("button", { name: "Layers" }).click(); await page.getByRole("button", { name: "Layers" }).click();
const labelsToggle = page.getByRole("button", { name: "Labels" }); const labelsToggle = page.getByRole("button", { name: "Labels" });
await expect(page.locator(".location-map-display-controls .location-map-layer-state")).toHaveCount(8);
await expect(labelsToggle).toHaveAttribute("aria-pressed", "true"); await expect(labelsToggle).toHaveAttribute("aria-pressed", "true");
await expect(labelsToggle.locator(".location-map-layer-state.is-on")).toHaveCount(1);
await expect(page.getByRole("button", { name: "Bought" })).toBeVisible(); await expect(page.getByRole("button", { name: "Bought" })).toBeVisible();
await expect(page.getByRole("button", { name: "Done" })).toHaveCount(0); await expect(page.getByRole("button", { name: "Done" })).toHaveCount(0);
await labelsToggle.click(); await labelsToggle.click();
await expect(labelsToggle).toHaveAttribute("aria-pressed", "false"); await expect(labelsToggle).toHaveAttribute("aria-pressed", "false");
await expect(labelsToggle.locator(".location-map-layer-state.is-on")).toHaveCount(0);
await expect(page.getByRole("button", { name: "Layers, 1 changed" })).toBeVisible(); await expect(page.getByRole("button", { name: "Layers, 1 changed" })).toBeVisible();
await expect(produceArea.locator(".location-map-label")).toHaveCount(0); await expect(produceArea.locator(".location-map-label")).toHaveCount(0);
await expect(produceArea.locator(".location-map-count")).toHaveText("2 items"); await expect(produceArea.locator(".location-map-count")).toHaveText("2 items");
@ -3926,22 +3924,19 @@ test("compact tablet map starts fitted on first load", async ({ page }) => {
const historyActions = page.locator(".location-map-history-buttons"); const historyActions = page.locator(".location-map-history-buttons");
const zoomControls = page.locator(".location-map-zoom-controls"); const zoomControls = page.locator(".location-map-zoom-controls");
const viewModeBox = await modeButtons.boundingBox(); const viewModeBox = await modeButtons.boundingBox();
const reservedHistoryBox = await historyActions.boundingBox();
const viewZoomBox = await zoomControls.boundingBox(); const viewZoomBox = await zoomControls.boundingBox();
expect(viewModeBox).not.toBeNull(); expect(viewModeBox).not.toBeNull();
expect(reservedHistoryBox).not.toBeNull();
expect(viewZoomBox).not.toBeNull(); expect(viewZoomBox).not.toBeNull();
if (!viewModeBox || !reservedHistoryBox || !viewZoomBox) { if (!viewModeBox || !viewZoomBox) {
throw new Error("Compact tablet toolbar layout was not measurable"); throw new Error("Compact tablet toolbar layout was not measurable");
} }
expect(viewModeBox.width).toBeGreaterThanOrEqual(180); expect(viewModeBox.width).toBeGreaterThanOrEqual(180);
expect(viewModeBox.width).toBeLessThanOrEqual(190); expect(viewModeBox.width).toBeLessThanOrEqual(190);
await expect(historyActions).toHaveCSS("visibility", "hidden"); await expect(historyActions).toHaveCount(0);
expect(reservedHistoryBox.x).toBeGreaterThan(viewModeBox.x + viewModeBox.width - 1); expect(viewZoomBox.x).toBeGreaterThan(viewModeBox.x + viewModeBox.width - 1);
expect(viewZoomBox.x).toBeGreaterThan(reservedHistoryBox.x + reservedHistoryBox.width - 1);
await page.getByRole("button", { name: "Edit Draft" }).click(); await page.getByRole("button", { name: "Edit Draft" }).click();
await expect(historyActions).toHaveCSS("visibility", "visible"); await expect(historyActions).toHaveCount(1);
const toolbarBox = await toolbar.boundingBox(); const toolbarBox = await toolbar.boundingBox();
const editModeBox = await modeButtons.boundingBox(); const editModeBox = await modeButtons.boundingBox();
const editHistoryBox = await historyActions.boundingBox(); const editHistoryBox = await historyActions.boundingBox();
@ -4288,7 +4283,8 @@ test("members see a clean empty state when no map is published", async ({ page }
await page.goto("/stores/100/locations/10/map"); await page.goto("/stores/100/locations/10/map");
await expect(page.getByRole("heading", { name: "No Map" })).toBeVisible(); await expect(page.getByRole("heading", { name: "No Published Map" })).toBeVisible();
await expect(page.getByRole("heading", { name: "No Map" })).toHaveCount(0);
await expect(page.getByRole("group", { name: "Map setup details" })).toHaveCount(0); await expect(page.getByRole("group", { name: "Map setup details" })).toHaveCount(0);
await expect(page.getByText("Not published")).toHaveCount(0); await expect(page.getByText("Not published")).toHaveCount(0);
await expect(page.getByText("A household admin has not published a map yet.")).toHaveCount(0); await expect(page.getByText("A household admin has not published a map yet.")).toHaveCount(0);
@ -4330,7 +4326,8 @@ test("members do not see unpublished draft maps", async ({ page }) => {
await page.goto("/stores/100/locations/10/map"); await page.goto("/stores/100/locations/10/map");
await expect(page.getByRole("heading", { name: "No Map" })).toBeVisible(); await expect(page.getByRole("heading", { name: "No Published Map" })).toBeVisible();
await expect(page.getByRole("heading", { name: "No Map" })).toHaveCount(0);
await expect(page.getByRole("group", { name: "Map setup details" })).toHaveCount(0); await expect(page.getByRole("group", { name: "Map setup details" })).toHaveCount(0);
await expect(page.getByText("Not published")).toHaveCount(0); await expect(page.getByText("Not published")).toHaveCount(0);
await expect(page.getByText("A household admin has not published a map yet.")).toHaveCount(0); await expect(page.getByText("A household admin has not published a map yet.")).toHaveCount(0);