@marimo-team/islands 0.23.17-dev26 → 0.23.17-dev28
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/dist/{ImageComparisonComponent-C3y7L3eJ.js → ImageComparisonComponent-fdY0LUuf.js} +38 -27
- package/dist/{common-9UepGWSR.js → common-BWX4gEr_.js} +1 -1
- package/dist/main.js +3 -3
- package/dist/{reveal-component-C9_o1FTa.js → reveal-component-DtQUExfw.js} +1 -1
- package/package.json +1 -1
- package/src/plugins/impl/image-comparison/ImageComparisonComponent.tsx +20 -1
- package/src/plugins/impl/image-comparison/__tests__/ImageComparisonComponent.test.tsx +58 -0
|
@@ -240,7 +240,7 @@ function truncateSrc(e) {
|
|
|
240
240
|
return e.length > 100 ? `${e.slice(0, 100)}\u2026` : e;
|
|
241
241
|
}
|
|
242
242
|
var ImageComparisonComponent_default = (e) => {
|
|
243
|
-
let i = (0, import_compiler_runtime.c)(
|
|
243
|
+
let i = (0, import_compiler_runtime.c)(40), { beforeSrc: a, afterSrc: o, value: s, direction: c, width: l, height: p } = e, [m, h] = import_react.useState(_temp), g;
|
|
244
244
|
i[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (g = () => {
|
|
245
245
|
h(/* @__PURE__ */ new Set());
|
|
246
246
|
}, i[0] = g) : g = i[0];
|
|
@@ -257,56 +257,67 @@ var ImageComparisonComponent_default = (e) => {
|
|
|
257
257
|
maxWidth: "100%",
|
|
258
258
|
minHeight: "2rem"
|
|
259
259
|
}, i[5] = b, i[6] = x, i[7] = S) : S = i[7];
|
|
260
|
-
let C = S;
|
|
260
|
+
let C = S, w;
|
|
261
|
+
i[8] !== p || i[9] !== l ? (w = l || p ? {
|
|
262
|
+
width: l || void 0,
|
|
263
|
+
height: p || void 0,
|
|
264
|
+
objectFit: "contain"
|
|
265
|
+
} : void 0, i[8] = p, i[9] = l, i[10] = w) : w = i[10];
|
|
266
|
+
let T = w;
|
|
261
267
|
if (m.size > 0) {
|
|
262
268
|
let e2 = m.size > 1 ? "images" : "image", a2;
|
|
263
|
-
i[
|
|
269
|
+
i[11] === m ? a2 = i[12] : (a2 = [...m].map(_temp2), i[11] = m, i[12] = a2);
|
|
264
270
|
let o2 = a2.join(", "), s2;
|
|
265
|
-
i[
|
|
271
|
+
i[13] !== o2 || i[14] !== e2 ? (s2 = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
266
272
|
"Failed to load ",
|
|
267
273
|
e2,
|
|
268
274
|
":",
|
|
269
275
|
" ",
|
|
270
276
|
o2
|
|
271
|
-
] }), i[
|
|
277
|
+
] }), i[13] = o2, i[14] = e2, i[15] = s2) : s2 = i[15];
|
|
272
278
|
let c2;
|
|
273
|
-
return i[
|
|
279
|
+
return i[16] !== C || i[17] !== s2 ? (c2 = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
274
280
|
style: C,
|
|
275
281
|
className: "flex items-center justify-center rounded border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive",
|
|
276
282
|
children: s2
|
|
277
|
-
}), i[
|
|
283
|
+
}), i[16] = C, i[17] = s2, i[18] = c2) : c2 = i[18], c2;
|
|
278
284
|
}
|
|
279
|
-
let
|
|
280
|
-
i[
|
|
281
|
-
let
|
|
282
|
-
i[
|
|
285
|
+
let E;
|
|
286
|
+
i[19] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (E = { verticalAlign: "top" }, i[19] = E) : E = i[19];
|
|
287
|
+
let D;
|
|
288
|
+
i[20] === a ? D = i[21] : (D = () => y(a), i[20] = a, i[21] = D);
|
|
289
|
+
let O;
|
|
290
|
+
i[22] !== a || i[23] !== T || i[24] !== D ? (O = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
|
|
283
291
|
slot: "first",
|
|
284
292
|
src: a,
|
|
285
293
|
alt: "Before",
|
|
286
294
|
width: "100%",
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
295
|
+
style: T,
|
|
296
|
+
onError: D
|
|
297
|
+
}), i[22] = a, i[23] = T, i[24] = D, i[25] = O) : O = i[25];
|
|
298
|
+
let k;
|
|
299
|
+
i[26] === o ? k = i[27] : (k = () => y(o), i[26] = o, i[27] = k);
|
|
300
|
+
let A;
|
|
301
|
+
i[28] !== o || i[29] !== T || i[30] !== k ? (A = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
|
|
293
302
|
slot: "second",
|
|
294
303
|
src: o,
|
|
295
304
|
alt: "After",
|
|
296
305
|
width: "100%",
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
306
|
+
style: T,
|
|
307
|
+
onError: k
|
|
308
|
+
}), i[28] = o, i[29] = T, i[30] = k, i[31] = A) : A = i[31];
|
|
309
|
+
let j;
|
|
310
|
+
i[32] !== c || i[33] !== O || i[34] !== A || i[35] !== s ? (j = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dist.ImgComparisonSlider, {
|
|
301
311
|
value: s,
|
|
302
312
|
direction: c,
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
313
|
+
style: E,
|
|
314
|
+
children: [O, A]
|
|
315
|
+
}), i[32] = c, i[33] = O, i[34] = A, i[35] = s, i[36] = j) : j = i[36];
|
|
316
|
+
let M;
|
|
317
|
+
return i[37] !== C || i[38] !== j ? (M = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
307
318
|
style: C,
|
|
308
|
-
children:
|
|
309
|
-
}), i[
|
|
319
|
+
children: j
|
|
320
|
+
}), i[37] = C, i[38] = j, i[39] = M) : M = i[39], M;
|
|
310
321
|
};
|
|
311
322
|
function _temp() {
|
|
312
323
|
return /* @__PURE__ */ new Set();
|
|
@@ -36338,7 +36338,7 @@ ${d}`,
|
|
|
36338
36338
|
return Logger.warn("Failed to get version from mount config"), null;
|
|
36339
36339
|
}
|
|
36340
36340
|
}
|
|
36341
|
-
marimoVersionAtom = atom(getVersionFromMountConfig() || "0.23.17-
|
|
36341
|
+
marimoVersionAtom = atom(getVersionFromMountConfig() || "0.23.17-dev28");
|
|
36342
36342
|
showCodeInRunModeAtom = atom(true);
|
|
36343
36343
|
atom(null);
|
|
36344
36344
|
var import_compiler_runtime = require_compiler_runtime();
|
package/dist/main.js
CHANGED
|
@@ -26,7 +26,7 @@ import { $ as notebookOutline, $t as publishedCellClasses, A as ChevronDownIcon,
|
|
|
26
26
|
import { __tla as __tla_1 } from "./chunk-5FQGJX7Z-B9WoXK1R.js";
|
|
27
27
|
import { o as useSize, s as Root$1, u as createLucideIcon } from "./dist-DgzzIPS4.js";
|
|
28
28
|
import { A as SquareFunction, C as DEFAULT_COLOR_SCHEME, D as SCALE_TYPE_DESCRIPTIONS, E as EMPTY_VALUE$1, O as TIME_UNIT_DESCRIPTIONS, S as DEFAULT_AGGREGATION, T as DEFAULT_TIME_UNIT, _ as AGGREGATION_TYPE_DESCRIPTIONS, a as AGGREGATION_FNS$1, b as COLOR_SCHEMES, c as COLOR_BY_FIELDS, d as NONE_VALUE, f as SELECTABLE_DATA_TYPES, g as TIME_UNITS, h as STRING_AGGREGATION_FNS, i as convertDataTypeToSelectable, j as ChartColumn, k as escapeFieldName, l as COMBINED_TIME_UNITS, m as SORT_TYPES, n as createSpecWithoutData, o as BIN_AGGREGATION, p as SINGLE_TIME_UNITS, r as isFieldSet, s as CHART_TYPES, t as augmentSpecWithData, u as ChartType, v as AGGREGATION_TYPE_ICON, w as DEFAULT_MAX_BINS_FACET, x as COUNT_FIELD, y as CHART_TYPE_ICON } from "./spec-C7rMyZ_8.js";
|
|
29
|
-
import { $ as CommandSeparator, $t as Kbd, A as ErrorState, At as getPageIndexForRow, B as ContextMenuTrigger, Bt as dateToLocalISODate, C as downloadHTMLAsImage, Ct as inferFieldTypes, D as ColumnName, Dt as DelayMount, E as downloadSizeLimitAtom, Et as ColumnChartSpecModel, F as getUserColumnVisibilityCounts, Ft as TOO_MANY_ROWS, G as DateRangePicker, Gt as TabsList, H as useSelectList, Ht as dateToLocalISOTime, I as ContextMenu, It as toFieldTypes, J as Command, Jt as ChartInfoState, K as Combobox, Kt as TabsTrigger, L as ContextMenuContent, Lt as getMimeValues, M as prettifyRowColumnCount, Mt as loadTableData, N as prettifyRowCount, Nt as INDEX_COLUMN_NAME, O as ColumnPreviewContainer, Ot as useIntersectionObserver, P as getColumnCountForDisplay, Pt as SELECT_COLUMN_ID, Q as CommandList, Qt as RenderTextWithLinks, R as ContextMenuItem, Rt as isNullishFilter, S as downloadExportedFile, St as generateColumns, T as Filenames, Tt as ColumnChartContext, U as CompactChipRow, Ut as Tabs, V as useInternalStateWithSync, Vt as dateToLocalISODateTime, W as DatePicker, Wt as TabsContent, X as CommandInput, Xt as LazyVegaEmbed, Y as CommandEmpty, Yt as ChartLoadingState, Z as CommandItem, Zt as useOverflowDetection, _ as DataTable, _n as ChevronLeft, _t as TableCell, an as TextWrap, at as contextAwarePanelType, b as downloadBlob, bt as TableRow, c as SLIDE_TYPE_OPTIONS_BY_VALUE, cn as EyeOff, ct as slotsController, d as Switch, dn as Download, en as HtmlOutput, et as smartMatch, f as RadioGroup, fn as Code, g as OutputRenderer, gn as ChevronsDownUp, gt as TableBody, h as OutputArea, hn as ChevronsLeft, ht as Table, i as showCodeInRunModeAtom, in as $fae977aafc393c5c$export$6b862160d295c8e, it as contextAwarePanelOwner, j as LoadingState, jt as loadTableAndRawData, k as EmptyState, kt as usePrevious$1, lt as Toggle, m as JsonOutput, mn as ChevronsRight, mt as Provider$1, n as useNotebookCodeAvailable, nn as safeLocale, nt as PANEL_TYPES, on as GripHorizontal, ot as isCellAwareAtom, p as RadioGroupItem, pn as ChevronsUpDown, pt as Fill, q as ComboboxItem, qt as ChartErrorState, r as marimoVersionAtom, rn as $fae977aafc393c5c$export$588937bcd60ade55, rt as contextAwarePanelOpen, sn as Funnel, st as SlotNames, t as cellDomProps, tn as EmotionCacheProvider, tt as ContextAwarePanelItem, u as Slide, un as Ellipsis, v as InstallPackageButton, vn as ArrowDownWideNarrow, vt as TableHead, w as Progress, wt as renderCellValue, x as downloadByURL, xt as NAMELESS_COLUMN_PREFIX, y as ADD_PRINTING_CLASS, yt as TableHeader, z as ContextMenuSeparator, zt as Maps, __tla as __tla_2 } from "./common-
|
|
29
|
+
import { $ as CommandSeparator, $t as Kbd, A as ErrorState, At as getPageIndexForRow, B as ContextMenuTrigger, Bt as dateToLocalISODate, C as downloadHTMLAsImage, Ct as inferFieldTypes, D as ColumnName, Dt as DelayMount, E as downloadSizeLimitAtom, Et as ColumnChartSpecModel, F as getUserColumnVisibilityCounts, Ft as TOO_MANY_ROWS, G as DateRangePicker, Gt as TabsList, H as useSelectList, Ht as dateToLocalISOTime, I as ContextMenu, It as toFieldTypes, J as Command, Jt as ChartInfoState, K as Combobox, Kt as TabsTrigger, L as ContextMenuContent, Lt as getMimeValues, M as prettifyRowColumnCount, Mt as loadTableData, N as prettifyRowCount, Nt as INDEX_COLUMN_NAME, O as ColumnPreviewContainer, Ot as useIntersectionObserver, P as getColumnCountForDisplay, Pt as SELECT_COLUMN_ID, Q as CommandList, Qt as RenderTextWithLinks, R as ContextMenuItem, Rt as isNullishFilter, S as downloadExportedFile, St as generateColumns, T as Filenames, Tt as ColumnChartContext, U as CompactChipRow, Ut as Tabs, V as useInternalStateWithSync, Vt as dateToLocalISODateTime, W as DatePicker, Wt as TabsContent, X as CommandInput, Xt as LazyVegaEmbed, Y as CommandEmpty, Yt as ChartLoadingState, Z as CommandItem, Zt as useOverflowDetection, _ as DataTable, _n as ChevronLeft, _t as TableCell, an as TextWrap, at as contextAwarePanelType, b as downloadBlob, bt as TableRow, c as SLIDE_TYPE_OPTIONS_BY_VALUE, cn as EyeOff, ct as slotsController, d as Switch, dn as Download, en as HtmlOutput, et as smartMatch, f as RadioGroup, fn as Code, g as OutputRenderer, gn as ChevronsDownUp, gt as TableBody, h as OutputArea, hn as ChevronsLeft, ht as Table, i as showCodeInRunModeAtom, in as $fae977aafc393c5c$export$6b862160d295c8e, it as contextAwarePanelOwner, j as LoadingState, jt as loadTableAndRawData, k as EmptyState, kt as usePrevious$1, lt as Toggle, m as JsonOutput, mn as ChevronsRight, mt as Provider$1, n as useNotebookCodeAvailable, nn as safeLocale, nt as PANEL_TYPES, on as GripHorizontal, ot as isCellAwareAtom, p as RadioGroupItem, pn as ChevronsUpDown, pt as Fill, q as ComboboxItem, qt as ChartErrorState, r as marimoVersionAtom, rn as $fae977aafc393c5c$export$588937bcd60ade55, rt as contextAwarePanelOpen, sn as Funnel, st as SlotNames, t as cellDomProps, tn as EmotionCacheProvider, tt as ContextAwarePanelItem, u as Slide, un as Ellipsis, v as InstallPackageButton, vn as ArrowDownWideNarrow, vt as TableHead, w as Progress, wt as renderCellValue, x as downloadByURL, xt as NAMELESS_COLUMN_PREFIX, y as ADD_PRINTING_CLASS, yt as TableHeader, z as ContextMenuSeparator, zt as Maps, __tla as __tla_2 } from "./common-BWX4gEr_.js";
|
|
30
30
|
import { c as Calendar, i as createReducerAndAtoms, n as useOnUnmount, o as ToggleLeft, t as useOnMount } from "./useLifecycle-CLPBATCv.js";
|
|
31
31
|
import { t as Check } from "./check-CCvJTB2E.js";
|
|
32
32
|
import { A as Icon, C as logNever, D as $18f2051aff69b9bf$export$a54013f0d02a8f82, E as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7, F as createCollection, I as X, M as clamp$2, N as usePrevious$2, P as useDirection, R as ChevronDown, S as assertNever, a as SelectGroup, c as SelectSeparator, d as NativeSelect, i as SelectContent, j as Trigger$1, l as SelectTrigger, n as capitalize, o as SelectItem, r as Select, s as SelectLabel, t as Strings, u as SelectValue, w as $a916eb452884faea$export$b7a616150fdb9f44 } from "./strings-CITcoFNY.js";
|
|
@@ -28644,7 +28644,7 @@ ${c}
|
|
|
28644
28644
|
f
|
|
28645
28645
|
]
|
|
28646
28646
|
});
|
|
28647
|
-
}, LazyImageComparisonComponent = import_react.lazy(() => import("./ImageComparisonComponent-
|
|
28647
|
+
}, LazyImageComparisonComponent = import_react.lazy(() => import("./ImageComparisonComponent-fdY0LUuf.js")), ImageComparisonPlugin = class {
|
|
28648
28648
|
constructor() {
|
|
28649
28649
|
__publicField(this, "tagName", "marimo-image-comparison");
|
|
28650
28650
|
__publicField(this, "validator", object({
|
|
@@ -38221,7 +38221,7 @@ ${c}
|
|
|
38221
38221
|
function _temp2$2(e) {
|
|
38222
38222
|
e.target === e.currentTarget && e.key === "Enter" && (e.preventDefault(), e.stopPropagation(), e.currentTarget.click());
|
|
38223
38223
|
}
|
|
38224
|
-
var LazySlidesComponent = import_react.lazy(() => import("./reveal-component-
|
|
38224
|
+
var LazySlidesComponent = import_react.lazy(() => import("./reveal-component-DtQUExfw.js"));
|
|
38225
38225
|
const SlidesLayoutRenderer = ({ layout: e, setLayout: r, cells: c, mode: l }) => {
|
|
38226
38226
|
var _a5;
|
|
38227
38227
|
let u = useAtomValue(kioskModeAtom), d = l === "read" || u, f = useAtomValue(numColumnsAtom) > 1, [p, m] = (0, import_react.useState)(null), { slideCells: h, skippedIds: g, noOutputIds: _, slideTypes: v, startCellIndex: y } = (0, import_react.useMemo)(() => computeSlideCellsInfo(c, e), [
|
|
@@ -9,7 +9,7 @@ import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
|
|
|
9
9
|
import { ut as outputIsStale } from "./html-to-image-D_6NEfLQ.js";
|
|
10
10
|
import "./chunk-5FQGJX7Z-B9WoXK1R.js";
|
|
11
11
|
import { u as createLucideIcon } from "./dist-DgzzIPS4.js";
|
|
12
|
-
import { a as DEFAULT_DECK_TRANSITION, cn as EyeOff, dt as PanelGroup, fn as Code, ft as PanelResizeHandle, l as SlideSidebar, ln as Expand, n as useNotebookCodeAvailable, o as DEFAULT_DECK_VERTICAL_ALIGN, s as DEFAULT_SLIDE_TYPE, t as cellDomProps, u as Slide, ut as Panel } from "./common-
|
|
12
|
+
import { a as DEFAULT_DECK_TRANSITION, cn as EyeOff, dt as PanelGroup, fn as Code, ft as PanelResizeHandle, l as SlideSidebar, ln as Expand, n as useNotebookCodeAvailable, o as DEFAULT_DECK_VERTICAL_ALIGN, s as DEFAULT_SLIDE_TYPE, t as cellDomProps, u as Slide, ut as Panel } from "./common-BWX4gEr_.js";
|
|
13
13
|
import { R as ChevronDown } from "./strings-CITcoFNY.js";
|
|
14
14
|
import { X as useDebouncedCallback } from "./input-DtTqU0xh.js";
|
|
15
15
|
import { v as kioskModeAtom } from "./toDate-kxcuDOWd.js";
|
package/package.json
CHANGED
|
@@ -49,6 +49,18 @@ const ImageComparisonComponent: React.FC<ImageComparisonData> = ({
|
|
|
49
49
|
minHeight: "2rem",
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
// The slider's width="100%" images resolve against its shadow-DOM wrappers (circular),
|
|
53
|
+
// so size the images explicitly and letterbox with object-fit to keep them aligned.
|
|
54
|
+
// Treat empty strings as "not provided" (normalize_dimension passes them through).
|
|
55
|
+
const imageStyle: React.CSSProperties | undefined =
|
|
56
|
+
width || height
|
|
57
|
+
? {
|
|
58
|
+
width: width || undefined,
|
|
59
|
+
height: height || undefined,
|
|
60
|
+
objectFit: "contain",
|
|
61
|
+
}
|
|
62
|
+
: undefined;
|
|
63
|
+
|
|
52
64
|
// If an image fails to load, the slider collapses to nothing; surface a
|
|
53
65
|
// visible error instead of silently rendering an empty output.
|
|
54
66
|
if (failedSrcs.size > 0) {
|
|
@@ -67,12 +79,18 @@ const ImageComparisonComponent: React.FC<ImageComparisonData> = ({
|
|
|
67
79
|
|
|
68
80
|
return (
|
|
69
81
|
<div style={containerStyle}>
|
|
70
|
-
<ImgComparisonSlider
|
|
82
|
+
<ImgComparisonSlider
|
|
83
|
+
value={value}
|
|
84
|
+
direction={direction}
|
|
85
|
+
// inline-block leaves a baseline gap below the slider; align to top.
|
|
86
|
+
style={{ verticalAlign: "top" }}
|
|
87
|
+
>
|
|
71
88
|
<img
|
|
72
89
|
slot="first"
|
|
73
90
|
src={beforeSrc}
|
|
74
91
|
alt="Before"
|
|
75
92
|
width="100%"
|
|
93
|
+
style={imageStyle}
|
|
76
94
|
onError={() => handleError(beforeSrc)}
|
|
77
95
|
/>
|
|
78
96
|
<img
|
|
@@ -80,6 +98,7 @@ const ImageComparisonComponent: React.FC<ImageComparisonData> = ({
|
|
|
80
98
|
src={afterSrc}
|
|
81
99
|
alt="After"
|
|
82
100
|
width="100%"
|
|
101
|
+
style={imageStyle}
|
|
83
102
|
onError={() => handleError(afterSrc)}
|
|
84
103
|
/>
|
|
85
104
|
</ImgComparisonSlider>
|
|
@@ -68,4 +68,62 @@ describe("ImageComparisonComponent", () => {
|
|
|
68
68
|
expect(error?.textContent).toContain("…");
|
|
69
69
|
expect(error?.textContent).not.toContain("A".repeat(200));
|
|
70
70
|
});
|
|
71
|
+
|
|
72
|
+
it("sizes both images explicitly when dimensions are given", () => {
|
|
73
|
+
const { getAllByAltText } = render(
|
|
74
|
+
<ImageComparisonComponent {...baseProps} width="300px" height="300px" />,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
for (const img of getAllByAltText(/Before|After/)) {
|
|
78
|
+
expect((img as HTMLElement).style.width).toBe("300px");
|
|
79
|
+
expect((img as HTMLElement).style.height).toBe("300px");
|
|
80
|
+
// Letterbox identically so the slider's clip stays aligned.
|
|
81
|
+
expect((img as HTMLElement).style.objectFit).toBe("contain");
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("applies a single dimension to both images when only one is given", () => {
|
|
86
|
+
const { getAllByAltText } = render(
|
|
87
|
+
<ImageComparisonComponent {...baseProps} width="300px" />,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
for (const img of getAllByAltText(/Before|After/)) {
|
|
91
|
+
expect((img as HTMLElement).style.width).toBe("300px");
|
|
92
|
+
expect((img as HTMLElement).style.objectFit).toBe("contain");
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("applies height-only sizing to both images", () => {
|
|
97
|
+
const { getAllByAltText } = render(
|
|
98
|
+
<ImageComparisonComponent {...baseProps} height="300px" />,
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
for (const img of getAllByAltText(/Before|After/)) {
|
|
102
|
+
expect((img as HTMLElement).style.height).toBe("300px");
|
|
103
|
+
expect((img as HTMLElement).style.objectFit).toBe("contain");
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("treats empty-string dimensions as not provided", () => {
|
|
108
|
+
const { getAllByAltText } = render(
|
|
109
|
+
<ImageComparisonComponent {...baseProps} width="" height="" />,
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
for (const img of getAllByAltText(/Before|After/)) {
|
|
113
|
+
expect((img as HTMLElement).style.width).toBe("");
|
|
114
|
+
expect((img as HTMLElement).style.height).toBe("");
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("leaves images unstyled when no dimensions are given", () => {
|
|
119
|
+
const { getAllByAltText } = render(
|
|
120
|
+
<ImageComparisonComponent {...baseProps} />,
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
for (const img of getAllByAltText(/Before|After/)) {
|
|
124
|
+
// No explicit sizing: the slider keeps its intrinsic-size behavior.
|
|
125
|
+
expect((img as HTMLElement).style.width).toBe("");
|
|
126
|
+
expect((img as HTMLElement).style.height).toBe("");
|
|
127
|
+
}
|
|
128
|
+
});
|
|
71
129
|
});
|