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
6 changes: 6 additions & 0 deletions src/ui/kit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ describe("UI kit components (PIN-97)", () => {
expect(held).toContain("pn-sticker-held");
expect(held).toContain("Under review");
expect(held).not.toContain("<img");
// The foil perk never paints a held pin's shape either.
const foiled = html(h(Sticker, { src: "/a.webp", seed: "x", held: true, foil: true }));
expect(foiled).not.toContain("pn-foil");
expect(foiled).not.toContain("data-foil");
expect(foiled).not.toContain("--src");
expect(foiled).not.toContain("/a.webp");
const pin = html(h(Pin, { src: "/a.webp", label: "Duck", owner: { id: "p1", name: "Robin" }, held: true, onToggle: () => {} }));
expect(pin).not.toContain("<button");
expect(pin).toContain("Under review");
Expand Down
8 changes: 5 additions & 3 deletions src/ui/stickers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ export function Sticker({
const locale = useLocale();
const vars: Record<string, string | number> = { "--t": tilt ?? stickerTilt(seed) };
if (size !== undefined) vars["--pn-size"] = typeof size === "number" ? `${size}px` : size;
if (state === "cutting" || foil) vars["--src"] = `url("${src}")`;
// PIN-279: a held pin has no picture anywhere, foil mask included.
const foiled = Boolean(foil) && !held;
if (!held && (state === "cutting" || foiled)) vars["--src"] = `url("${src}")`;
return (
<span
className={cx("pn-sticker", className)}
data-state={state}
data-foil={foil ? "" : undefined}
data-foil={foiled ? "" : undefined}
data-held={held ? "" : undefined}
style={{ ...(vars as CSSProperties), ...style }}
>
Expand All @@ -61,7 +63,7 @@ export function Sticker({
) : (
<img src={src} alt={alt} draggable={false} loading={loading} decoding="async" />
)}
{foil ? <span className="pn-foil" aria-hidden="true" /> : null}
{foiled ? <span className="pn-foil" aria-hidden="true" /> : null}
{state === "picked" && pickIndex ? (
<span className="pn-sticker-badge" aria-hidden="true">
{pickIndex}
Expand Down
Loading