1 parent
6f2c0d95f2
commit
d354829e51
4 files changed
+72
-27
No files matched your search
@@ -0,0 +1,12 @@
|
||||
type Size = { width: number; height: number };
|
||||
|
||||
export const PROMPT_EDITOR_VIEWPORT_MARGIN = 24;
|
||||
|
||||
export function clampPromptEditorModalSize(size: Size, viewport: Size): Size {
|
||||
const maxWidth = Math.max(1, viewport.width - PROMPT_EDITOR_VIEWPORT_MARGIN);
|
||||
const maxHeight = Math.max(1, viewport.height - PROMPT_EDITOR_VIEWPORT_MARGIN);
|
||||
return {
|
||||
width: Math.min(maxWidth, Math.max(560, Math.round(size.width))),
|
||||
height: Math.min(maxHeight, Math.max(320, Math.round(size.height))),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user