move out magic values to constants

This commit is contained in:
Nate Kelley 2025-07-16 11:24:23 -06:00
parent abcb500d5f
commit 47029669a3
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
1 changed files with 10 additions and 6 deletions

View File

@ -22,6 +22,10 @@ export interface AppVerticalCodeSplitterProps {
readOnly?: boolean;
}
const MIN_LEFT_SIZE = 120;
const MIN_RIGHT_SIZE = 80;
const AUTO_BUST_STORAGE_ON_INIT_SIZE = 800;
export const AppVerticalCodeSplitter = forwardRef<AppSplitterRef, AppVerticalCodeSplitterProps>(
(
{
@ -50,10 +54,10 @@ export const AppVerticalCodeSplitter = forwardRef<AppSplitterRef, AppVerticalCod
(preservedSideValue: number | null, refSize: number) => {
return (
!preservedSideValue ||
preservedSideValue < 120 ||
refSize < 120 + 80 ||
preservedSideValue > 800 ||
preservedSideValue > refSize - 80 ||
preservedSideValue < MIN_LEFT_SIZE ||
refSize < MIN_LEFT_SIZE + MIN_RIGHT_SIZE ||
preservedSideValue > AUTO_BUST_STORAGE_ON_INIT_SIZE ||
preservedSideValue > refSize - MIN_RIGHT_SIZE ||
!refSize
);
}
@ -88,8 +92,8 @@ export const AppVerticalCodeSplitter = forwardRef<AppSplitterRef, AppVerticalCod
defaultLayout={defaultLayout}
autoSaveId={autoSaveId}
preserveSide="left"
rightPanelMinSize={'80px'}
leftPanelMinSize={'120px'}
rightPanelMinSize={`${MIN_RIGHT_SIZE}px`}
leftPanelMinSize={`${MIN_LEFT_SIZE}px`}
leftHidden={topHidden}
className={className}
bustStorageOnInit={bustStorageOnInit}