@snowcone-app/ui 0.10.13 → 0.10.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.cjs +12 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/composed/carousels/MobileProductCarousel.tsx +3 -4
- package/src/composed/carousels/__tests__/fit.test.ts +16 -0
- package/src/composed/carousels/fit.ts +18 -0
package/package.json
CHANGED
|
@@ -49,6 +49,7 @@ import React, {
|
|
|
49
49
|
memo,
|
|
50
50
|
} from "react";
|
|
51
51
|
import type { CarouselImage } from "./types";
|
|
52
|
+
import { slideFit, zoomFit } from "./fit";
|
|
52
53
|
import { EnhancedImageViewer } from "../zoom/EnhancedImageViewer";
|
|
53
54
|
import { HeroProductImage } from "../HeroProductImage";
|
|
54
55
|
import { LoadingOverlayPrismCandyInline } from "../../components/LoadingOverlayPrismCandy";
|
|
@@ -922,9 +923,7 @@ export const MobileProductCarousel = memo(function MobileProductCarousel({
|
|
|
922
923
|
// Edits render only the slides a shopper can see, at the
|
|
923
924
|
// width the screen shows them (sessionShape.ts).
|
|
924
925
|
viewportPolicy
|
|
925
|
-
|
|
926
|
-
// the whole 16:9 frame, never cropped to the slide's centre.
|
|
927
|
-
fit={image.galleryRole === "size-picture" ? "whole" : "cover"}
|
|
926
|
+
fit={slideFit(image.galleryRole)}
|
|
928
927
|
/>
|
|
929
928
|
) : image.isRealMockup && !currentArtwork ? (
|
|
930
929
|
<LoadingOverlayPrismCandyInline visible variant="light" />
|
|
@@ -1028,7 +1027,7 @@ export const MobileProductCarousel = memo(function MobileProductCarousel({
|
|
|
1028
1027
|
alt: img.label,
|
|
1029
1028
|
naturalWidth: img.naturalWidth,
|
|
1030
1029
|
naturalHeight: img.naturalHeight,
|
|
1031
|
-
...(img.galleryRole === "
|
|
1030
|
+
...(zoomFit(img.galleryRole) === "whole" ? { fit: "whole" as const } : {}),
|
|
1032
1031
|
} : null;
|
|
1033
1032
|
})
|
|
1034
1033
|
.filter((img): img is NonNullable<typeof img> => img !== null);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { slideFit, zoomFit } from "../fit";
|
|
3
|
+
|
|
4
|
+
// Known case (prod XTNA6J, iPhone 14 at 390 px, 2026-11-13): drawn whole in the phone hero, the size picture's
|
|
5
|
+
// garment was 92-120 px wide and its caption capitals 5 px; cropped it is 214-280 px and 11 px. Lead ruling A: the
|
|
6
|
+
// hero crops it (data-fit "cover"); the zoom viewer still opens it whole.
|
|
7
|
+
describe("size picture fit on a phone", () => {
|
|
8
|
+
it("the phone hero draws the size slide cropped, like every slide", () => {
|
|
9
|
+
expect(slideFit("size-picture")).toBe("cover");
|
|
10
|
+
expect(slideFit(undefined)).toBe("cover");
|
|
11
|
+
});
|
|
12
|
+
it("the zoom viewer opens the size picture whole; other pictures unchanged", () => {
|
|
13
|
+
expect(zoomFit("size-picture")).toBe("whole");
|
|
14
|
+
expect(zoomFit(undefined)).toBe("cover");
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CarouselImage } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* How the phone carousel draws a picture, and how the zoom viewer opens it.
|
|
5
|
+
*
|
|
6
|
+
* A size picture (galleryRole "size-picture") is a 16:9 diagram with a caption. On a phone the hero is ~342x448, so
|
|
7
|
+
* drawn WHOLE it shrinks to a letterbox: garment 92-120 px wide and caption capitals 5 px (measured on prod XTNA6J,
|
|
8
|
+
* 2026-11-13), against 214-280 px and 11 px cropped. The lead's ruling (A, 2026-11-13): the phone HERO draws it
|
|
9
|
+
* cropped (cover) like every slide; tapping it opens the zoom viewer, which shows it whole.
|
|
10
|
+
*/
|
|
11
|
+
export function slideFit(_galleryRole: CarouselImage["galleryRole"]): "cover" | "whole" {
|
|
12
|
+
return "cover";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** The zoom viewer opens a size picture whole (the full 16:9, caption readable); every other picture as before. */
|
|
16
|
+
export function zoomFit(galleryRole: CarouselImage["galleryRole"]): "cover" | "whole" {
|
|
17
|
+
return galleryRole === "size-picture" ? "whole" : "cover";
|
|
18
|
+
}
|