Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(docsite): fill constrained template previews (#6436)

Ernest9f0783f12726
diff --git a/apps/docsite/src/components/TemplatePreviewDialog.tsx b/apps/docsite/src/components/TemplatePreviewDialog.tsx
index f6a4e085fa..cba223c992 100644
--- a/apps/docsite/src/components/TemplatePreviewDialog.tsx
+++ b/apps/docsite/src/components/TemplatePreviewDialog.tsx
@@ -9,7 +9,7 @@
* display order. Arrow keys (←/→) also navigate; Escape closes.
*
* @input Template metadata, selected index, open state, and navigation callbacks.
- * @output A responsive dialog with a 16:10 live preview up to 1440×900 and template actions.
+ * @output A responsive dialog with a fill-mode live preview up to 1440×900 and template actions.
* @position Shared preview controller for the templates gallery.
*
* The header surfaces template metadata (name, description) with the close
@@ -76,8 +76,6 @@ const styles = stylex.create({
body: {
position: 'relative',
display: 'flex',
- alignItems: 'flex-start',
- justifyContent: 'center',
height: '100%',
minHeight: 0,
boxSizing: 'border-box',
@@ -394,14 +392,7 @@ export function TemplatePreviewDialog({
isOpen={isOpen}
onOpenChange={onOpenChange}
variant={variant}
- // Scale the desktop dialog with available block space so the preview can
- // stay full-width and 16:10. The offsets account for viewport gutters,
- // fixed header/footer chrome, and the preview's inline padding.
- width={
- isFullscreen
- ? undefined
- : 'min(1472px, calc((100dvh - 210px) * 1.6 + 32px))'
- }
+ width={isFullscreen ? undefined : 1472}
maxHeight={isFullscreen ? undefined : 'calc(100dvh - 32px)'}
xstyle={isFullscreen ? undefined : styles.dialogDesktop}
aria-label={current.name}>
diff --git a/apps/docsite/src/components/TemplatePreviewSurface.module.css b/apps/docsite/src/components/TemplatePreviewSurface.module.css
index 8128756dc4..fd80a15f17 100644
--- a/apps/docsite/src/components/TemplatePreviewSurface.module.css
+++ b/apps/docsite/src/components/TemplatePreviewSurface.module.css
@@ -1,15 +1,14 @@
/* Copyright (c) Meta Platforms, Inc. and affiliates. */
-/* The preview "window". It preserves the 1440×900 aspect ratio while fitting
- the dialog body's available width and height. Fill-mode templates scroll
- their own content region; auto-height templates can still use this frame. */
+/* The preview window fills all space between the dialog header and footer.
+ Large desktop dialogs naturally reach 1440×900; constrained desktop and
+ mobile dialogs use every available pixel without forcing an aspect ratio. */
.frame {
position: relative;
- width: min(100%, 1440px);
- max-height: 900px;
- aspect-ratio: 16 / 10;
+ width: 100%;
+ height: 100%;
margin-inline: auto;
- flex: 0 0 auto;
+ flex: 1 1 auto;
min-height: 0;
/* The frame is the single scroll container. Fill-mode templates fit the
frame exactly and scroll their own content region internally (no frame
diff --git a/apps/docsite/src/components/TemplatePreviewSurface.tsx b/apps/docsite/src/components/TemplatePreviewSurface.tsx
index c2a6e79d87..c9497b614d 100644
--- a/apps/docsite/src/components/TemplatePreviewSurface.tsx
+++ b/apps/docsite/src/components/TemplatePreviewSurface.tsx
@@ -4,8 +4,8 @@
/**
* @file TemplatePreviewSurface.tsx
- * @input Uses the shared template component registry and current theme mode.
- * @output Renders one live page template inside a preview-sized viewport.
+ * @input Uses the template slug, shared component registry, and current theme mode.
+ * @output Renders one live page template in a viewport that fills its host.
* @position Shared preview surface used by TemplatePreviewDialog.
*
* The viewport wrapper gives percentage-height templates a definite containing