Skip to content

Commit 826dfda

Browse files
authored
Add help page (#120)
* Add help page Signed-off-by: Joe Farro <joef@uber.com> * Revert adding help as a separate page Signed-off-by: Joe Farro <joef@uber.com> * Trace detail keyboard shortcuts help as a modal Signed-off-by: Joe Farro <joef@uber.com> * Misc typo Signed-off-by: Joe Farro <joef@uber.com> * Misc cleanup Signed-off-by: Joe Farro <joef@uber.com>
1 parent 3522365 commit 826dfda

File tree

4 files changed

+127
-1
lines changed

4 files changed

+127
-1
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Copyright (c) 2017 Uber Technologies, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
.KeyboardShortcutsHelp kbd {
18+
background: #f5f5f5;
19+
border: 1px solid #e8e8e8;
20+
border-bottom: 1px solid #ddd;
21+
color: #000;
22+
margin-right: 0.4em;
23+
padding: 0.25em 0.3em;
24+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// @flow
2+
3+
// Copyright (c) 2017 Uber Technologies, Inc.
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
17+
import React from 'react';
18+
import { Button, Modal } from 'semantic-ui-react';
19+
20+
import { kbdMappings } from './keyboard-shortcuts';
21+
22+
import './KeyboardShortcutsHelp.css';
23+
24+
const symbolConv = {
25+
up: '↑',
26+
right: '→',
27+
down: '↓',
28+
left: '←',
29+
shift: '⇧',
30+
};
31+
32+
const descriptions = {
33+
scrollPageDown: 'Scroll down',
34+
scrollPageUp: 'Scroll up',
35+
scrollToNextVisibleSpan: 'Scroll to the next visible span',
36+
scrollToPrevVisibleSpan: 'Scroll to the previous visible span',
37+
panLeft: 'Pan left',
38+
panLeftFast: 'Pan left — Large',
39+
panRight: 'Pan right',
40+
panRightFast: 'Pan right — Large',
41+
zoomIn: 'Zoom in',
42+
zoomInFast: 'Zoom in — Large',
43+
zoomOut: 'Zoom out',
44+
zoomOutFast: 'Zoom out — Large',
45+
};
46+
47+
function convertKeys(keyConfig: string | string[]): string[][] {
48+
const config = Array.isArray(keyConfig) ? keyConfig : [keyConfig];
49+
return config.map(str => str.split('+').map(part => symbolConv[part] || part.toUpperCase()));
50+
}
51+
52+
export default function KeyboardShortcutsHelp() {
53+
const rows = [];
54+
Object.keys(kbdMappings).forEach(title => {
55+
const keyConfigs = convertKeys(kbdMappings[title]);
56+
const configs = keyConfigs.map(config =>
57+
<tr key={String(config)}>
58+
<td>
59+
{config.map(s =>
60+
<kbd key={s}>
61+
{s}
62+
</kbd>
63+
)}
64+
</td>
65+
<td>
66+
{descriptions[title]}
67+
</td>
68+
</tr>
69+
);
70+
rows.push(...configs);
71+
});
72+
return (
73+
<Modal
74+
trigger={
75+
<Button basic compact size="tiny">
76+
<h3></h3>
77+
</Button>
78+
}
79+
>
80+
<Modal.Header>Keyboard Shortcuts</Modal.Header>
81+
<Modal.Content>
82+
<Modal.Description>
83+
<table className="KeyboardShortcutsHelp ui celled table">
84+
<thead>
85+
<tr>
86+
<th>Key(s)</th>
87+
<th>Description</th>
88+
</tr>
89+
</thead>
90+
<tbody>
91+
{rows}
92+
</tbody>
93+
</table>
94+
</Modal.Description>
95+
</Modal.Content>
96+
</Modal>
97+
);
98+
}

src/components/TracePage/TracePageHeader.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import PropTypes from 'prop-types';
1616
import React from 'react';
1717
import { Dropdown, Menu } from 'semantic-ui-react';
1818

19+
import KeyboardShortcutsHelp from './KeyboardShortcutsHelp';
1920
import { formatDatetime, formatDuration } from '../../utils/date';
2021

2122
export const HEADER_ITEMS = [
@@ -68,6 +69,9 @@ export default function TracePageHeader(props) {
6869
</h2>
6970
</div>
7071
<div className="inline-block mr1">
72+
<KeyboardShortcutsHelp />
73+
</div>
74+
<div className="mr1">
7175
<Menu>
7276
<Dropdown text="View Options" className="item">
7377
<Dropdown.Menu>

src/components/TracePage/keyboard-shortcuts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export type ShortcutCallbacks = {
4242
zoomOutFast: CombokeysHandler,
4343
};
4444

45-
const kbdMappings = {
45+
export const kbdMappings = {
4646
scrollPageDown: 's',
4747
scrollPageUp: 'w',
4848
scrollToNextVisibleSpan: 'f',

0 commit comments

Comments
 (0)