Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/sections/accordion/accordion-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(
if (isSvgString(icon)) {
return (
<span
className="h-5 w-5"
className="flex size-5 shrink-0 items-center justify-center [&>svg]:block [&>svg]:size-full"
dangerouslySetInnerHTML={{ __html: icon }}
/>
);
Expand All @@ -64,7 +64,7 @@ const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(
return (
<Image
src={icon}
className="h-5 w-5"
className="block size-5 shrink-0 object-contain"
alt={title}
width={20}
height={20}
Expand Down Expand Up @@ -101,10 +101,10 @@ const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(
)}
>
{renderIcon()}
<span className="flex-1 font-body font-normal text-base leading-[1.4] tracking-[0.02em]">
<span className="min-w-0 flex-1 font-body font-normal text-base leading-[1.4] tracking-[0.02em]">
{title}
</span>
<div className="relative ml-auto size-4 flex-shrink-0">
<div className="relative ml-auto aspect-square size-6 shrink-0 -rotate-180">
<PlusCircle
className="absolute inset-0 h-full w-full transition-opacity duration-200 group-data-[state=open]:opacity-0"
color="currentColor"
Expand Down
2 changes: 1 addition & 1 deletion app/sections/instagram/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ let InstagramContent = forwardRef<HTMLDivElement, InstagramContentProps>(
<div
ref={ref}
{...rest}
className="instagram-content flex w-full min-w-0 flex-col items-start gap-6 rounded-[var(--Radius-border-radius-md,12px)] bg-white p-6 min-[744px]:self-stretch lg:w-80 lg:flex-none desktop:w-[320px] desktop:self-start"
className="instagram-content flex w-full min-w-0 flex-col items-start gap-6 rounded-[var(--Radius-border-radius-md,12px)] bg-white p-6 md:self-stretch lg:w-80 lg:flex-none desktop:w-[320px] desktop:self-start"
>
<div className="flex w-full min-w-0 flex-col items-start gap-2.5">
{headingContent && (
Expand Down
3 changes: 2 additions & 1 deletion app/sections/instagram/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -29,7 +30,7 @@ const InstagramImage = forwardRef<HTMLDivElement, InstagramImageProps>(
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)`}
/>
<span className="pointer-events-none absolute inset-0 bg-black/30 opacity-0 transition-opacity duration-300 group-hover:opacity-100 group-focus-within:opacity-100 group-active:opacity-100" />
<InstagramLogo className="-translate-x-1/2 -translate-y-1/2 pointer-events-none absolute top-1/2 left-1/2 z-1 size-8 text-white opacity-0 transition-opacity duration-300 group-hover:opacity-100 group-focus-within:opacity-100 group-active:opacity-100" />
Expand Down
2 changes: 1 addition & 1 deletion app/sections/instagram/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Instagram = forwardRef<HTMLElement, InstagramProps>((props, ref) => {
width="full"
className="instagram-section"
>
<div className="instagram-row mx-auto flex w-full max-w-[1440px] flex-col gap-5 px-5 min-[744px]:grid min-[744px]:grid-cols-[minmax(0,1fr)_minmax(0,2fr)] min-[744px]:items-stretch min-[744px]:gap-6 min-[744px]:px-8 min-[744px]:[&>*:only-child]:col-span-full lg:flex lg:flex-row lg:px-0">
<div className="instagram-row mx-auto flex w-full max-w-[1440px] flex-col gap-5 px-5 md:grid md:grid-cols-[minmax(0,1fr)_minmax(0,2fr)] md:items-stretch md:gap-4 md:px-8 md:[&>*:only-child]:col-span-full lg:gap-6 lg:flex lg:flex-row lg:px-0">
{children}
</div>
</Section>
Expand Down
2 changes: 1 addition & 1 deletion app/sections/instagram/slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const InstagramGrid = forwardRef<HTMLDivElement, InstagramGridProps>(
{...rest}
className="instagram-grid-wrap w-full min-w-0 md:flex-1"
>
<div className="instagram-grid grid grid-cols-2 gap-2 min-[744px]:grid-cols-4 min-[744px]:gap-5">
<div className="instagram-grid grid grid-cols-2 gap-2 md:grid-cols-4 lg:gap-5">
{children}
</div>
</div>
Expand Down
72 changes: 72 additions & 0 deletions tests/accordion-style-2.browser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24"><path d="M2 12h20"/></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();
}
});
18 changes: 14 additions & 4 deletions tests/instagram-responsive-layout.browser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
Loading