diff --git a/packages/grafnode-components/src/components/RequestTabPanel/StyledWrapper.js b/packages/grafnode-components/src/components/RequestTabPanel/StyledWrapper.js index 195b0632f..f4007609f 100644 --- a/packages/grafnode-components/src/components/RequestTabPanel/StyledWrapper.js +++ b/packages/grafnode-components/src/components/RequestTabPanel/StyledWrapper.js @@ -1,6 +1,18 @@ import styled from 'styled-components'; const StyledWrapper = styled.div` + div.drag-request { + display: flex; + width: 0.5rem; + padding: 0; + cursor: col-resize; + background: transparent; + border-left: solid 1px var(--color-request-dragbar-background); + + &:hover { + border-left: solid 1px var(--color-request-dragbar-background-active); + } + } `; export default StyledWrapper; \ No newline at end of file diff --git a/packages/grafnode-components/src/components/RequestTabPanel/index.js b/packages/grafnode-components/src/components/RequestTabPanel/index.js index 839da3ca0..962ff7bec 100644 --- a/packages/grafnode-components/src/components/RequestTabPanel/index.js +++ b/packages/grafnode-components/src/components/RequestTabPanel/index.js @@ -18,37 +18,41 @@ const RequestTabPanel = ({dispatch, actions, collections, activeRequestTabId, re return
; } - let asideWidth = 200; + let asideWidth = 230; let { schema } = useGraphqlSchema('https://api.spacex.land/graphql'); - const [leftPaneWidth, setLeftPaneWidth] = useState(500); - const [rightPaneWidth, setRightPaneWidth] = useState(window.innerWidth - 700 - asideWidth); + const [leftPaneWidth, setLeftPaneWidth] = useState((window.innerWidth - asideWidth)/2 - 10); // 10 is for dragbar + const [rightPaneWidth, setRightPaneWidth] = useState((window.innerWidth - asideWidth)/2); + console.log((window.innerWidth - asideWidth)/2); const [dragging, setDragging] = useState(false); const handleMouseMove = (e) => { - e.preventDefault(); if(dragging) { - setLeftPaneWidth(e.clientX - asideWidth ); + e.preventDefault(); + setLeftPaneWidth(e.clientX - asideWidth); setRightPaneWidth(window.innerWidth - (e.clientX)); } }; const handleMouseUp = (e) => { - e.preventDefault(); - setDragging(false); + if(dragging) { + e.preventDefault(); + setDragging(false); + } }; - const handleMouseDown = (e) => { + const handleDragbarMouseDown = (e) => { e.preventDefault(); setDragging(true); }; - // useEffect(() => { - // document.addEventListener('mouseup', handleMouseUp); - // document.addEventListener('mousemove', handleMouseMove); - // return () => { - // document.removeEventListener('mouseup', handleMouseUp); - // document.removeEventListener('mousemove', handleMouseMove); - // }; - // }, [dragging, leftPaneWidth]); + useEffect(() => { + document.addEventListener('mouseup', handleMouseUp); + document.addEventListener('mousemove', handleMouseMove); + + return () => { + document.removeEventListener('mouseup', handleMouseUp); + document.removeEventListener('mousemove', handleMouseMove); + }; + }, [dragging, leftPaneWidth]); const onUrlChange = (value) => { dispatch({ @@ -119,8 +123,11 @@ const RequestTabPanel = ({dispatch, actions, collections, activeRequestTabId, re />