From b30ed4bfcd5b9fe23f4141bd7b7b84bd53093031 Mon Sep 17 00:00:00 2001 From: Rahul Yadav Date: Tue, 19 Nov 2024 16:14:23 +0530 Subject: [PATCH] fix: ensure vertical split section resizes correctly (#157) --- .../workspace/WorkSpace/WorkSpace.module.scss | 4 ++-- .../workspace/WorkSpace/WorkSpace.tsx | 22 ++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/components/workspace/WorkSpace/WorkSpace.module.scss b/src/components/workspace/WorkSpace/WorkSpace.module.scss index 21bdfad..cf35457 100644 --- a/src/components/workspace/WorkSpace/WorkSpace.module.scss +++ b/src/components/workspace/WorkSpace/WorkSpace.module.scss @@ -6,7 +6,7 @@ flex: 0 0 70px; width: 70px; } - .splitHorizontal { + .splitVertical { display: flex; flex-direction: row; width: calc(100% - 70px); @@ -16,7 +16,7 @@ background-color: var(--splitter-bg); } } - .splitVertical { + .splitHorizontal { display: flex; flex-direction: column; height: 100%; diff --git a/src/components/workspace/WorkSpace/WorkSpace.tsx b/src/components/workspace/WorkSpace/WorkSpace.tsx index 8a0ae7c..6d63b12 100644 --- a/src/components/workspace/WorkSpace/WorkSpace.tsx +++ b/src/components/workspace/WorkSpace/WorkSpace.tsx @@ -16,7 +16,7 @@ import * as TonCrypto from '@ton/crypto'; import { Blockchain } from '@ton/sandbox'; import { Buffer } from 'buffer'; import { useRouter } from 'next/router'; -import { FC, useEffect, useMemo, useState } from 'react'; +import { FC, useEffect, useMemo, useRef, useState } from 'react'; import Split from 'react-split'; import { useEffectOnce } from 'react-use'; import BottomPanel from '../BottomPanel/BottomPanel'; @@ -32,6 +32,8 @@ import FileTree from '../tree/FileTree'; import ItemAction from '../tree/FileTree/ItemActions'; import s from './WorkSpace.module.scss'; +type SplitInstance = Split & { split: Split.Instance }; + const WorkSpace: FC = () => { const { clearLog, createLog } = useLogActivity(); @@ -40,6 +42,7 @@ const WorkSpace: FC = () => { const [isLoaded, setIsLoaded] = useState(false); // eslint-disable-next-line @typescript-eslint/no-explicit-any const [contract, setContract] = useState(''); + const splitVerticalRef = useRef(null); const { tab } = router.query; const { @@ -153,6 +156,17 @@ const WorkSpace: FC = () => { window.TonCore = TonCore; window.TonCrypto = TonCrypto; window.Buffer = Buffer; + + const handleResize = () => { + if (!splitVerticalRef.current) return; + + splitVerticalRef.current.split.setSizes([5, 95]); + }; + + window.addEventListener('resize', handleResize); + return () => { + window.removeEventListener('resize', handleResize); + }; }); return ( @@ -172,8 +186,10 @@ const WorkSpace: FC = () => { /> { @@ -230,7 +246,7 @@ const WorkSpace: FC = () => { {isLoaded && ( <>