diff --git a/apps/sim/app/(landing)/components/shared/responsive-design-stage/responsive-design-stage.test.ts b/apps/sim/app/(landing)/components/shared/responsive-design-stage/responsive-design-stage.test.ts index a17aaf1e831..2b749f2db55 100644 --- a/apps/sim/app/(landing)/components/shared/responsive-design-stage/responsive-design-stage.test.ts +++ b/apps/sim/app/(landing)/components/shared/responsive-design-stage/responsive-design-stage.test.ts @@ -114,6 +114,43 @@ describe('calculateFitScale', () => { }) describe('ResponsiveDesignStage', () => { + it.each([ + { width: 280, height: 400, supportsZoom: true }, + { width: 280, height: 400, supportsZoom: false }, + { width: 350, height: 340, supportsZoom: true }, + { width: 350, height: 340, supportsZoom: false }, + ])( + 'fits an uncapped $width × $height stage with zoom support: $supportsZoom', + ({ width, height, supportsZoom }) => { + vi.stubGlobal('CSS', { supports: vi.fn(() => supportsZoom) }) + act(() => { + root.render( + createElement( + ResponsiveDesignStage, + { width, height, maxScale: Number.POSITIVE_INFINITY }, + createElement('span', null, 'Preview') + ) + ) + }) + + const surface = container.firstElementChild?.firstElementChild + if (!(surface instanceof HTMLElement) || !resizeObserver) { + throw new Error('responsive stage did not mount') + } + const observer = resizeObserver + + act(() => observer.deliver(width * 2, height * 1.5)) + expect(surface.style.zoom).toBe(supportsZoom ? '1.5' : '1') + expect(surface.style.transform).toBe(supportsZoom ? '' : 'scale(1.5)') + expect(surface.style.opacity).toBe('1') + + act(() => observer.deliver(width / 2, height * 2)) + expect(surface.style.zoom).toBe(supportsZoom ? '0.5' : '1') + expect(surface.style.transform).toBe(supportsZoom ? '' : 'scale(0.5)') + expect(surface.style.opacity).toBe('1') + } + ) + it('hides an already visible surface until a measurable size returns', () => { act(() => { root.render( diff --git a/apps/sim/app/(landing)/files/components/feature-graphics/file-library-graphic.module.css b/apps/sim/app/(landing)/files/components/feature-graphics/file-library-graphic.module.css index 1fe3f88e310..eb11c05760a 100644 --- a/apps/sim/app/(landing)/files/components/feature-graphics/file-library-graphic.module.css +++ b/apps/sim/app/(landing)/files/components/feature-graphics/file-library-graphic.module.css @@ -44,9 +44,9 @@ .folderButton { position: relative; - min-width: 0; - min-height: 0; - container-type: size; + display: block; + width: 100%; + height: 100%; cursor: pointer; touch-action: manipulation; border-radius: 12px; @@ -60,11 +60,10 @@ width: 321px; height: 270px; left: 50%; - bottom: 12px; + bottom: 0; margin-left: -160.5px; perspective: 800px; transform-origin: bottom center; - scale: min(tan(atan2(100cqw, 350px)), tan(atan2(100cqh, 340px))); } .folderBack { position: absolute; diff --git a/apps/sim/app/(landing)/files/components/feature-graphics/interactive-library-folder.tsx b/apps/sim/app/(landing)/files/components/feature-graphics/interactive-library-folder.tsx index 0b423b59801..ad1d78fd5b5 100644 --- a/apps/sim/app/(landing)/files/components/feature-graphics/interactive-library-folder.tsx +++ b/apps/sim/app/(landing)/files/components/feature-graphics/interactive-library-folder.tsx @@ -3,6 +3,7 @@ import { useState } from 'react' import { cn } from '@sim/emcn' import { motion, useReducedMotion } from 'framer-motion' +import { ResponsiveDesignStage } from '@/app/(landing)/components/shared/responsive-design-stage' import styles from '@/app/(landing)/files/components/feature-graphics/file-library-graphic.module.css' /** @@ -72,53 +73,68 @@ export function InteractiveLibraryFolder({ : { type: 'spring' as const, stiffness: 120, damping: 14 } return ( - + + + ) } diff --git a/apps/sim/app/(landing)/workflows/components/feature-graphics/workflow-canvas-graphic.tsx b/apps/sim/app/(landing)/workflows/components/feature-graphics/workflow-canvas-graphic.tsx index 8cb36e7b7b2..dcda47e3221 100644 --- a/apps/sim/app/(landing)/workflows/components/feature-graphics/workflow-canvas-graphic.tsx +++ b/apps/sim/app/(landing)/workflows/components/feature-graphics/workflow-canvas-graphic.tsx @@ -1,5 +1,6 @@ import { ChipTag, cn } from '@sim/emcn' import colorMixFallbacks from '@/app/(landing)/components/shared/color-mix-fallbacks/color-mix-fallbacks.module.css' +import { ResponsiveDesignStage } from '@/app/(landing)/components/shared/responsive-design-stage' import { FeatureGraphicShell } from '@/app/(landing)/enterprise/components/feature-graphics' import styles from '@/app/(landing)/workflows/components/feature-graphics/workflow-canvas-graphic.module.css' @@ -65,11 +66,14 @@ const EDGE_DRAW_CLASSES = [styles.edgeDraw0, styles.edgeDraw1, styles.edgeDraw2] export function WorkflowCanvasGraphic() { return ( - )