fix(ui): improve stack frame sidebar UX
1. Show stack frames if there are more than one frame 2. Position stack frames based on sourceTab docked position: Source tab docked right -> stack frames at the bottom Source tab docked bottom -> stack frames at the right
This commit is contained in:
parent
01fa035b95
commit
cb5fd0cd27
|
|
@ -26,10 +26,11 @@ import type { StackFrame } from '@protocol/channels';
|
|||
|
||||
export const SourceTab: React.FunctionComponent<{
|
||||
stack: StackFrame[] | undefined,
|
||||
stackFrameLocation: 'bottom' | 'right',
|
||||
sources: Map<string, SourceModel>,
|
||||
rootDir?: string,
|
||||
fallbackLocation?: SourceLocation,
|
||||
}> = ({ stack, sources, rootDir, fallbackLocation }) => {
|
||||
}> = ({ stack, sources, rootDir, fallbackLocation, stackFrameLocation }) => {
|
||||
const [lastStack, setLastStack] = React.useState<StackFrame[] | undefined>();
|
||||
const [selectedFrame, setSelectedFrame] = React.useState<number>(0);
|
||||
|
||||
|
|
@ -77,7 +78,9 @@ export const SourceTab: React.FunctionComponent<{
|
|||
return { source, highlight, targetLine, fileName };
|
||||
}, [stack, selectedFrame, rootDir, fallbackLocation], { source: { errors: [], content: 'Loading\u2026' }, highlight: [] });
|
||||
|
||||
return <SplitView sidebarSize={200} orientation='horizontal'>
|
||||
const showStackFrames = (stack?.length ?? 0) > 1;
|
||||
|
||||
return <SplitView sidebarSize={200} orientation={stackFrameLocation === 'bottom' ? 'vertical' : 'horizontal'} sidebarHidden={!showStackFrames}>
|
||||
<div className='vbox' data-testid='source-code'>
|
||||
{fileName && <div className='source-tab-file-name'>{fileName}</div>}
|
||||
<CodeMirrorWrapper text={source.content || ''} language='javascript' highlight={highlight} revealLine={targetLine} readOnly={true} lineNumbers={true} />
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ export const Workbench: React.FunctionComponent<{
|
|||
stack={revealedStack}
|
||||
sources={sources}
|
||||
rootDir={rootDir}
|
||||
stackFrameLocation={sidebarLocation === 'bottom' ? 'right' : 'bottom'}
|
||||
fallbackLocation={fallbackLocation} />
|
||||
};
|
||||
const consoleTab: TabbedPaneTabModel = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue