-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend): Resizable Panels for the Test run (#3694)
* feat(frontend): Resizable Panels for the Test run * feat(frontend): Resizable Panels for the Test run * feat(frontend): Final touches * feat(frontend): fixing onboarding * feat(frontend): fixing onboarding
- Loading branch information
Showing
28 changed files
with
526 additions
and
543 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import * as Spaces from 'react-spaces'; | ||
import { Panel } from 'react-resizable-panels'; | ||
|
||
const FillPanel: React.FC = ({children}) => <Spaces.Fill style={{overflow: 'scroll'}}>{children}</Spaces.Fill>; | ||
const FillPanel: React.FC = ({children}) => <Panel>{children}</Panel>; | ||
|
||
export default FillPanel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {PanelResizeHandle} from 'react-resizable-panels'; | ||
import {DoubleLeftOutlined, DoubleRightOutlined} from '@ant-design/icons'; | ||
|
||
import * as S from './ResizablePanels.styled'; | ||
|
||
interface IProps { | ||
isOpen: boolean; | ||
onToggle(): void; | ||
placement?: 'left' | 'right'; | ||
} | ||
|
||
const Handle = ({onToggle, isOpen, placement = 'left'}: IProps) => { | ||
return ( | ||
<PanelResizeHandle className="panel-handle"> | ||
<S.ButtonContainer $placement={placement}> | ||
<S.ToggleButton | ||
onClick={e => { | ||
e.stopPropagation(); | ||
onToggle(); | ||
}} | ||
icon={isOpen ? <DoubleLeftOutlined /> : <DoubleRightOutlined />} | ||
/> | ||
</S.ButtonContainer> | ||
</PanelResizeHandle> | ||
); | ||
}; | ||
|
||
export default Handle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,14 @@ | ||
import * as Spaces from 'react-spaces'; | ||
import {useLayoutEffect} from 'react'; | ||
import {noop} from 'lodash'; | ||
import useResizablePanel, {TPanel, TSize} from '../ResizablePanels/hooks/useResizablePanel'; | ||
import Splitter from '../ResizablePanels/Splitter'; | ||
import {TPanel} from '../ResizablePanels/hooks/useResizablePanel'; | ||
import Panel from './Panel'; | ||
|
||
interface IProps { | ||
panel: TPanel; | ||
order?: number; | ||
children(size: TSize): React.ReactNode; | ||
tooltip?: string; | ||
isToolTipVisible?: boolean; | ||
children: React.ReactNode; | ||
onOpen?(): void; | ||
dataTour?: string; | ||
} | ||
|
||
const LeftPanel = ({ | ||
panel, | ||
order = 1, | ||
tooltip, | ||
isToolTipVisible = false, | ||
children, | ||
onOpen = noop, | ||
dataTour, | ||
}: IProps) => { | ||
const {size, toggle, onStopResize} = useResizablePanel({panel}); | ||
|
||
useLayoutEffect(() => { | ||
if (size.isOpen) onOpen(); | ||
}, [onOpen, size.isOpen]); | ||
|
||
return ( | ||
<Spaces.LeftResizable | ||
onResizeEnd={newSize => onStopResize(newSize)} | ||
minimumSize={size.minSize} | ||
maximumSize={size.maxSize} | ||
size={size.size} | ||
key={size.name} | ||
order={order} | ||
handleRender={props => ( | ||
<Splitter | ||
{...props} | ||
name={size.name} | ||
isOpen={size.isOpen} | ||
onClick={toggle} | ||
tooltip={tooltip} | ||
isToolTipVisible={isToolTipVisible} | ||
tooltipPlacement="right" | ||
dataTour={dataTour} | ||
/> | ||
)} | ||
> | ||
{children(size)} | ||
</Spaces.LeftResizable> | ||
); | ||
const LeftPanel = (props: IProps) => { | ||
return <Panel {...props} />; | ||
}; | ||
|
||
export default LeftPanel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import {Panel as ResizablePanel} from 'react-resizable-panels'; | ||
import {useCallback, useLayoutEffect} from 'react'; | ||
import {noop} from 'lodash'; | ||
import useResizablePanel, {TPanel} from './hooks/useResizablePanel'; | ||
import * as S from './ResizablePanels.styled'; | ||
import Handle from './Handle'; | ||
|
||
interface IProps { | ||
panel: TPanel; | ||
children: React.ReactNode; | ||
onOpen?(): void; | ||
handlePlacement?: 'left' | 'right'; | ||
} | ||
|
||
const Panel = ({onOpen = noop, panel, children, handlePlacement = 'right'}: IProps) => { | ||
const {size, onStopResize, onChange, ref} = useResizablePanel({panel}); | ||
|
||
useLayoutEffect(() => { | ||
if (size.isOpen) onOpen(); | ||
}, [onOpen, size.isOpen]); | ||
|
||
const toggle = useCallback(() => { | ||
onChange(size.isOpen ? size.closeSize() : size.openSize()); | ||
}, [onChange, size]); | ||
|
||
return ( | ||
<> | ||
{handlePlacement === 'left' && <Handle placement={handlePlacement} isOpen={!size.isOpen} onToggle={toggle} />} | ||
<ResizablePanel ref={ref} maxSize={size.maxSize()} defaultSize={size.openSize()} onResize={onStopResize}> | ||
<S.PanelContainer $isOpen={size.isOpen} onClick={() => !size.isOpen && onChange(size.openSize())}> | ||
{children} | ||
</S.PanelContainer> | ||
</ResizablePanel> | ||
{handlePlacement === 'right' && <Handle placement={handlePlacement} isOpen={size.isOpen} onToggle={toggle} />} | ||
</> | ||
); | ||
}; | ||
|
||
export default Panel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,14 @@ | ||
import * as Spaces from 'react-spaces'; | ||
import Splitter from '../ResizablePanels/Splitter'; | ||
import useResizablePanel, {TPanel, TSize} from '../ResizablePanels/hooks/useResizablePanel'; | ||
import {TPanel} from '../ResizablePanels/hooks/useResizablePanel'; | ||
import Panel from './Panel'; | ||
|
||
interface IProps { | ||
panel: TPanel; | ||
order?: number; | ||
children(size: TSize): React.ReactNode; | ||
tooltip?: string; | ||
children: React.ReactNode; | ||
onOpen?(): void; | ||
} | ||
|
||
const RightPanel = ({panel, order = 1, children, tooltip}: IProps) => { | ||
const {size, toggle, onStopResize} = useResizablePanel({panel}); | ||
|
||
return ( | ||
<Spaces.RightResizable | ||
onResizeEnd={newSize => onStopResize(newSize)} | ||
minimumSize={size.minSize} | ||
maximumSize={size.maxSize} | ||
size={size.size} | ||
key={size.name} | ||
order={order} | ||
handleRender={props => ( | ||
<Splitter | ||
{...props} | ||
name={size.name} | ||
isOpen={!size.isOpen} | ||
onClick={() => toggle()} | ||
tooltip={!size.isOpen ? tooltip : ''} | ||
tooltipPlacement="left" | ||
/> | ||
)} | ||
> | ||
{children(size)} | ||
</Spaces.RightResizable> | ||
); | ||
const RightPanel = (props: IProps) => { | ||
return <Panel handlePlacement="left" {...props} />; | ||
}; | ||
|
||
export default RightPanel; |
Oops, something went wrong.