diff --git a/components/canvas/DetailSurfaceOverlayRenderer.tsx b/components/canvas/DetailSurfaceOverlayRenderer.tsx index 87b24f2ac..ccf75cda8 100644 --- a/components/canvas/DetailSurfaceOverlayRenderer.tsx +++ b/components/canvas/DetailSurfaceOverlayRenderer.tsx @@ -66,9 +66,12 @@ function resolveOverlayText( function renderOverlayComponentContent( snapshot: DetailUiScreenOverlaySnapshot, component: RenderableOverlayComponent, + scale: number, ) { const content = resolveOverlayText(snapshot, component); const lines = content.split("\n").filter(Boolean); + const iconSize = Math.max(12, Math.round(16 * scale)); + const smallIconSize = Math.max(10, Math.round(14 * scale)); if (component.type === "detail_feature_card") { const headline = lines[0] || content; @@ -77,7 +80,7 @@ function renderOverlayComponentContent(
- +
{headline}
@@ -95,7 +98,7 @@ function renderOverlayComponentContent( if (component.type === "detail_feature_tag") { return (
- + {content}
); @@ -120,7 +123,7 @@ function renderOverlayComponentContent( if (component.type === "detail_proof_bar") { return (
- +
{content}
); @@ -130,7 +133,7 @@ function renderOverlayComponentContent( return (
{content} - +
); } @@ -139,7 +142,9 @@ function renderOverlayComponentContent( return (
{content}
- {component.type === "detail_cta_banner" ? : null} + {component.type === "detail_cta_banner" ? ( + + ) : null}
); } @@ -151,6 +156,7 @@ function getOverlayComponentStyle(params: { component: RenderableOverlayComponent; snapshot: DetailUiScreenOverlaySnapshot; content: string; + scale: number; frameOverride?: { x: number; y: number; @@ -167,6 +173,7 @@ function getOverlayComponentStyle(params: { const style = (params.component.style || {}) as Record; const widthScale = 100 / Math.max(1, params.snapshot.screenSize.width); const heightScale = 100 / Math.max(1, params.snapshot.screenSize.height); + const scale = Math.max(0.55, Math.min(2.4, params.scale)); const overlayStyle: CSSProperties = { position: "absolute", @@ -175,12 +182,15 @@ function getOverlayComponentStyle(params: { width: `${Number(frame.width || 0) * widthScale}%`, height: `${Number(frame.height || 0) * heightScale}%`, zIndex: Number(params.component.layout?.zIndex || 1), - fontSize: typeof style.fontSize === "number" ? `${style.fontSize}px` : undefined, + fontSize: + typeof style.fontSize === "number" ? `${style.fontSize * scale}px` : undefined, fontFamily: typeof style.fontFamily === "string" ? style.fontFamily : undefined, fontWeight: typeof style.fontWeight === "string" ? style.fontWeight : undefined, lineHeight: typeof style.lineHeight === "number" ? style.lineHeight : undefined, letterSpacing: - typeof style.letterSpacing === "number" ? `${style.letterSpacing}px` : undefined, + typeof style.letterSpacing === "number" + ? `${style.letterSpacing * scale}px` + : undefined, color: typeof style.color === "string" ? style.color : undefined, textAlign: style.textAlign === "center" || style.textAlign === "right" @@ -195,17 +205,26 @@ function getOverlayComponentStyle(params: { background: typeof style.backgroundColor === "string" ? style.backgroundColor : undefined, borderColor: typeof style.borderColor === "string" ? style.borderColor : undefined, borderWidth: - typeof style.borderWidth === "number" ? `${style.borderWidth}px` : undefined, + typeof style.borderWidth === "number" + ? `${Math.max(1, style.borderWidth * scale)}px` + : undefined, borderStyle: typeof style.borderWidth === "number" && style.borderWidth > 0 ? "solid" : undefined, borderRadius: - typeof style.borderRadius === "number" ? `${style.borderRadius}px` : undefined, - padding: typeof style.padding === "number" ? `${style.padding}px` : undefined, + typeof style.borderRadius === "number" + ? `${style.borderRadius * scale}px` + : undefined, + padding: + typeof style.padding === "number" ? `${style.padding * scale}px` : undefined, boxShadow: typeof style.boxShadow === "string" ? style.boxShadow : undefined, backdropFilter: - typeof style.backdropBlur === "number" ? `blur(${style.backdropBlur}px)` : undefined, + typeof style.backdropBlur === "number" + ? `blur(${style.backdropBlur * scale}px)` + : undefined, WebkitBackdropFilter: - typeof style.backdropBlur === "number" ? `blur(${style.backdropBlur}px)` : undefined, + typeof style.backdropBlur === "number" + ? `blur(${style.backdropBlur * scale}px)` + : undefined, overflow: "hidden", whiteSpace: "pre-wrap", wordBreak: "break-word", @@ -467,6 +486,10 @@ export function DetailSurfaceOverlayRenderer(params: { params.imageMetrics && params.imageMetrics.renderedHeight > 0 ? params.imageMetrics.renderedHeight : params.overlay.screenSize.height; + const overlayScale = Math.min( + overlayWidth / Math.max(1, params.overlay.screenSize.width), + overlayHeight / Math.max(1, params.overlay.screenSize.height), + ); const frameOverrides = buildFrameOverrides({ overlay: params.overlay, components, @@ -508,6 +531,7 @@ export function DetailSurfaceOverlayRenderer(params: { component, snapshot: params.overlay!, content, + scale: overlayScale, frameOverride: (() => { const frame = frameOverrides.get(component.id); if (!frame) return undefined; @@ -520,7 +544,7 @@ export function DetailSurfaceOverlayRenderer(params: { })(), })} > - {renderOverlayComponentContent(params.overlay!, component)} + {renderOverlayComponentContent(params.overlay!, component, overlayScale)}
); })}