feat(tracing): keyboard navigate lists (#6224)

This commit is contained in:
Pavel Feldman 2021-04-19 11:09:50 -10:00 committed by GitHub
parent 8ca58e344e
commit 27e720f23a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 17 deletions

View File

@ -22,6 +22,7 @@
user-select: none;
color: #555;
overflow: auto;
outline: none;
}
.action-entry {
@ -32,19 +33,19 @@
white-space: nowrap;
line-height: 28px;
padding-left: 3px;
border-left: 3px solid transparent;
}
.action-entry:hover, .action-entry.selected {
color: #333;
}
.action-entry.selected {
border-left: 3px solid #666;
color: white;
background-color: var(--gray);
}
.action-entry.selected:focus {
border-color: var(--orange);
.action-list:focus .action-entry.selected {
background-color: var(--blue);
}
.action-entry.selected > div {
color: white;
}
.action-title {

View File

@ -33,7 +33,27 @@ export const ActionList: React.FC<ActionListProps> = ({
onSelected = () => {},
onHighlighted = () => {},
}) => {
return <div className='action-list'>{actions.map(actionEntry => {
return <div
className='action-list'
tabIndex={0}
onKeyDown={event => {
if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp')
return;
const index = selectedAction ? actions.indexOf(selectedAction) : -1;
if (event.key === 'ArrowDown') {
if (index === -1)
onSelected(actions[0]);
else
onSelected(actions[Math.min(index + 1, actions.length - 1)]);
}
if (event.key === 'ArrowUp') {
if (index === -1)
onSelected(actions[actions.length - 1]);
else
onSelected(actions[Math.max(index - 1, 0)]);
}
}}
>{actions.map((actionEntry, index) => {
const { metadata, actionId } = actionEntry;
return <div
className={'action-entry' + (actionEntry === selectedAction ? ' selected' : '')}

View File

@ -17,23 +17,29 @@
.snapshot-tab {
display: flex;
flex: auto;
flex-direction: column;
align-items: stretch;
outline: none;
padding-right: 60px;
}
.snapshot-controls {
flex: 0 0 24px;
flex: 0 0 60px;
display: flex;
flex-direction: row;
flex-direction: column;
align-items: center;
padding: 10px 4px 0 0;
padding: 5px 0 0 5px;
}
.snapshot-toggle {
margin-top: 4px;
padding: 4px 8px;
cursor: pointer;
border-radius: 20px;
margin-left: 4px;
width: 60px;
display: flex;
align-items: center;
justify-content: center;
}
.snapshot-toggle:hover {
@ -41,7 +47,12 @@
}
.snapshot-toggle.toggled {
background: var(--inactive-focus-ring);
background: var(--gray);
color: white;
}
.snapshot-tab:focus .snapshot-toggle.toggled {
background: var(--blue);
}
.snapshot-wrapper {

View File

@ -56,8 +56,16 @@ export const SnapshotTab: React.FunctionComponent<{
width: snapshotSize.width * scale,
height: snapshotSize.height * scale,
};
return <div className='snapshot-tab'>
<div className='snapshot-controls'>
return <div
className='snapshot-tab'
tabIndex={0}
onKeyDown={event => {
if (event.key === 'ArrowDown')
setSnapshotIndex(Math.min(snapshotIndex + 1, snapshots.length - 1));
if (event.key === 'ArrowUp')
setSnapshotIndex(Math.max(snapshotIndex - 1, 0));
}}
><div className='snapshot-controls'>
{snapshots.map((snapshot, index) => {
return <div
key={snapshot.title}

View File

@ -46,10 +46,14 @@
pointer-events: none;
overflow: hidden;
flex: none;
flex-basis: 30px;
height: 30px;
position: relative;
}
.timeline-lane.timeline-labels {
height: 20px;
}
.timeline-grid {
position: absolute;
top: 0;