| ... | ... | @@ -10,12 +10,14 @@ export type PreviewPanelMode = "inline" | "sheet" | "sidebar" | "embedded"; |
| 10 | 10 | |
| 11 | 11 | const PREVIEW_PANEL_WIDTH_STORAGE_KEY = "t3code:preview-panel-width"; |
| 12 | 12 | const PREVIEW_PANEL_MIN_WIDTH = 360; |
| 13 | | /** Hard ceiling so a wide monitor can't yield a panel that swallows the chat. */ |
| 14 | | const PREVIEW_PANEL_MAX_WIDTH_PX = 1400; |
| 15 | | /** Fraction of the viewport allowed; the panel is min(this · vw, MAX_PX). */ |
| 13 | /** Fraction of the viewport allowed, preserving the remaining space for chat. */ |
| 16 | 14 | const PREVIEW_PANEL_MAX_WIDTH_FRACTION = 0.7; |
| 17 | 15 | const PREVIEW_PANEL_DEFAULT_WIDTH = 540; |
| 18 | 16 | |
| 17 | export function getPreviewPanelMaxWidth(viewportWidth: number): number { |
| 18 | return Math.floor(viewportWidth * PREVIEW_PANEL_MAX_WIDTH_FRACTION); |
| 19 | } |
| 20 | |
| 19 | 21 | /** |
| 20 | 22 | * Shell for the preview panel. In inline mode the panel is user-resizable |
| 21 | 23 | * via a drag handle on the left edge; width persists per browser. In |
| ... | ... | @@ -82,5 +84,5 @@ function useViewportClampedMaxWidth(): number { |
| 82 | 84 | if (frame !== 0) window.cancelAnimationFrame(frame); |
| 83 | 85 | }; |
| 84 | 86 | }, []); |
| 85 | | return Math.min(PREVIEW_PANEL_MAX_WIDTH_PX, Math.floor(vw * PREVIEW_PANEL_MAX_WIDTH_FRACTION)); |
| 87 | return getPreviewPanelMaxWidth(vw); |
| 86 | 88 | } |