diff --git a/app/sections/accordion/accordion-item.tsx b/app/sections/accordion/accordion-item.tsx index 22f90e16..0ab6bdf0 100644 --- a/app/sections/accordion/accordion-item.tsx +++ b/app/sections/accordion/accordion-item.tsx @@ -55,7 +55,7 @@ const AccordionItem = forwardRef( if (isSvgString(icon)) { return ( ); @@ -64,7 +64,7 @@ const AccordionItem = forwardRef( return ( {title}( )} > {renderIcon()} - + {title} -
+
(
{headingContent && ( diff --git a/app/sections/instagram/image.tsx b/app/sections/instagram/image.tsx index 67b0f1f6..66e769f3 100644 --- a/app/sections/instagram/image.tsx +++ b/app/sections/instagram/image.tsx @@ -8,6 +8,7 @@ import { forwardRef } from "react"; import { Link as RemixLink } from "react-router"; import { Image } from "~/components/image"; import { useHrefWithLocale } from "~/components/link"; +import { MEDIA_DESKTOP, MEDIA_FROM_TABLET } from "~/utils/breakpoints"; import { sectionImage } from "~/utils/section-placeholder"; interface InstagramImageProps extends HydrogenComponentProps { @@ -29,7 +30,7 @@ const InstagramImage = forwardRef( data={imageData} alt={altText || imageData.altText || ""} className="h-full w-full" - sizes="(min-width: 64rem) 260px, (min-width: 744px) 22vw, calc((100vw - 48px) / 2)" + sizes={`${MEDIA_DESKTOP} 260px, ${MEDIA_FROM_TABLET} 22vw, calc((100vw - 48px) / 2)`} /> diff --git a/app/sections/instagram/index.tsx b/app/sections/instagram/index.tsx index 5abdb699..3fcaac69 100644 --- a/app/sections/instagram/index.tsx +++ b/app/sections/instagram/index.tsx @@ -42,7 +42,7 @@ const Instagram = forwardRef((props, ref) => { width="full" className="instagram-section" > -
+
{children}
diff --git a/app/sections/instagram/slider.tsx b/app/sections/instagram/slider.tsx index 259f7395..00cf7d00 100644 --- a/app/sections/instagram/slider.tsx +++ b/app/sections/instagram/slider.tsx @@ -11,7 +11,7 @@ const InstagramGrid = forwardRef( {...rest} className="instagram-grid-wrap w-full min-w-0 md:flex-1" > -
+
{children}
diff --git a/tests/accordion-style-2.browser.mjs b/tests/accordion-style-2.browser.mjs index 3e1990ff..abfcb05a 100644 --- a/tests/accordion-style-2.browser.mjs +++ b/tests/accordion-style-2.browser.mjs @@ -279,3 +279,75 @@ test("new item presets start at 12px without injecting defaults into existing it await browser.close(); } }); + +test("new accordion items center SVG and image icons beside wrapped text with 24px toggles", async () => { + const browser = await chromium.launch(); + const title = + "A long customer service question that wraps across multiple lines on narrow screens"; + const svg = + ''; + try { + for (const width of [390, 767, 768, 1032, 1033, 1440]) { + const page = await fixture(browser, width); + for (const layout of ["row", "column"]) { + for (const icon of [ + svg, + `data:image/svg+xml,${encodeURIComponent(svg)}`, + ]) { + const itemTitle = `${title} (${layout}, ${icon === svg ? "SVG" : "image"})`; + await page.evaluate((settings) => window.renderAccordion(settings), { + layout, + itemSettings: [{ title: itemTitle, icon }], + }); + const trigger = page + .getByRole("button") + .filter({ hasText: itemTitle }) + .filter({ visible: true }); + await expect(trigger).toBeVisible(); + const geometry = await trigger.evaluate((button) => { + const [iconElement, text, toggle] = button.children; + const bounds = (element) => { + const rect = element.getBoundingClientRect(); + return { + width: rect.width, + height: rect.height, + center: rect.y + rect.height / 2, + }; + }; + return { + icon: bounds(iconElement), + graphic: bounds(iconElement.querySelector("svg") || iconElement), + text: bounds(text), + toggle: bounds(toggle), + overflow: button.scrollWidth > button.clientWidth, + }; + }); + expect(geometry.icon.width).toBe(20); + expect(geometry.icon.height).toBe(20); + expect(geometry.graphic.width).toBe(20); + expect(geometry.graphic.height).toBe(20); + expect(geometry.toggle.width).toBe(24); + expect(geometry.toggle.height).toBe(24); + expect( + Math.abs(geometry.icon.center - geometry.text.center), + ).toBeLessThan(1); + expect( + Math.abs(geometry.toggle.center - geometry.text.center), + ).toBeLessThan(1); + expect(geometry.overflow).toBe(false); + const initialState = await trigger.getAttribute("data-state"); + await trigger.click(); + await expect(trigger).toHaveAttribute( + "data-state", + initialState === "open" ? "closed" : "open", + ); + await trigger.click(); + await expect(trigger).toHaveAttribute("data-state", initialState); + } + } + await page.close(); + } + } finally { + await browser.close(); + } +}); diff --git a/tests/instagram-responsive-layout.browser.mjs b/tests/instagram-responsive-layout.browser.mjs index 901f2735..756f4558 100644 --- a/tests/instagram-responsive-layout.browser.mjs +++ b/tests/instagram-responsive-layout.browser.mjs @@ -87,8 +87,7 @@ test("Instagram real content keeps long merchant handles inside the card", async try { for (const width of [ 390, - 743, - 744, + 767, 768, 820, TABLET_MAX_PX, @@ -153,6 +152,8 @@ test("Instagram tablet keeps content beside a usable horizontal image grid", asy 744, 820, 834, + 1023, + 1024, TABLET_MAX_PX, DESKTOP_MIN_PX, 1440, @@ -178,6 +179,10 @@ test("Instagram tablet keeps content beside a usable horizontal image grid", asy columns: getComputedStyle( row.querySelector(".instagram-grid"), ).gridTemplateColumns.split(" ").length, + rowGap: Number.parseFloat(style.gap), + imageGap: Number.parseFloat( + getComputedStyle(row.querySelector(".instagram-grid")).gap, + ), tiles: [...row.querySelectorAll(".instagram-tile")].map((tile) => ({ width: tile.getBoundingClientRect().width, height: tile.getBoundingClientRect().height, @@ -186,11 +191,16 @@ test("Instagram tablet keeps content beside a usable horizontal image grid", asy }; }); assert.equal(geometry.overflow, false); - assert.equal(geometry.columns, width < 744 ? 2 : 4); + assert.equal(geometry.columns, width < 768 ? 2 : 4); + assert.equal( + geometry.rowGap, + width < 768 ? 20 : width < DESKTOP_MIN_PX ? 16 : 24, + ); + assert.equal(geometry.imageGap, width < DESKTOP_MIN_PX ? 8 : 20); for (const tile of geometry.tiles) { assert.ok(Math.abs(tile.width - tile.height) < 1); } - if (width < 744) { + if (width < 768) { assert.equal( geometry.grid.width, geometry.innerWidth,