Skip to content

Commit

Permalink
Style Description Page and Finish Shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
wgranger committed Nov 28, 2017
1 parent fdb6547 commit baf8581
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/components/KeyboardShortcuts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,25 @@ import React from 'react';

const KeyboardShortcuts = () => {
return (
<div className="login-button">
<div className="keyboard-shortcuts">
<h2>Keyboard Shortcuts</h2>
<table>
<tr>
<th>When Annotating</th>
</tr>
<tr>
<th>Command</th>
<th>Description</th>
</tr>
<tr>
<td>M</td>
<td>Ctrl + M</td>
<td>Toggle Previous Marks</td>
</tr>
<tr>
<td>Space</td>
<td>Ctrl + N</td>
<td>Toggle Navigate and Annotate</td>
</tr>
<tr>
<th>When Transcribing</th>
</tr>
<tr>
<td>Shift + Enter</td>
<td>Ctrl + Enter</td>
<td>Submit Classifications</td>
</tr>
<tr>
Expand Down
17 changes: 17 additions & 0 deletions src/containers/ClassifierContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { toggleFavorite } from '../ducks/subject';
import { toggleDialog } from '../ducks/dialog';
import { VARIANT_TYPES, toggleOverride } from '../ducks/splits';
import { saveClassificationInProgress } from '../ducks/classifications';
import { Utility, KEY_CODES } from '../lib/Utility';

import SubjectViewer from './SubjectViewer';

Expand Down Expand Up @@ -54,6 +55,7 @@ class ClassifierContainer extends React.Component {
this.toggleAdminOverride = this.toggleAdminOverride.bind(this);
this.toggleFieldGuide = this.toggleFieldGuide.bind(this);
this.saveCurrentClassification = this.saveCurrentClassification.bind(this);
this.handleKeyUp = this.handleKeyUp.bind(this);

this.state = {
popup: null,
Expand All @@ -64,6 +66,7 @@ class ClassifierContainer extends React.Component {
//----------------------------------------------------------------
componentDidMount() {
this.props.dispatch(fetchGuide());
document.addEventListener('keyup', this.handleKeyUp);
}

componentWillReceiveProps(nextProps) {
Expand All @@ -86,6 +89,7 @@ class ClassifierContainer extends React.Component {

componentWillUnmount() {
Split.clear();
document.removeEventListener('keyup', this.handleKeyUp);
this.context.googleLogger && this.context.googleLogger.forget(['subjectID']);
}

Expand Down Expand Up @@ -283,6 +287,19 @@ class ClassifierContainer extends React.Component {
this.setState({ popup: null });
}

handleKeyUp(e) {
if (Utility.getKeyCode(e) === KEY_CODES.N && e.ctrlKey) {
if (this.props.viewerState === SUBJECTVIEWER_STATE.NAVIGATING && !this.props.selectedAnnotation) {
this.props.dispatch(setViewerState(SUBJECTVIEWER_STATE.ANNOTATING));
} else {
this.props.dispatch(setViewerState(SUBJECTVIEWER_STATE.NAVIGATING));
}
}
if (Utility.getKeyCode(e) === KEY_CODES.M && e.ctrlKey) {
this.togglePreviousMarks();
}
}

//----------------------------------------------------------------

useAnnotationTool() {
Expand Down
19 changes: 19 additions & 0 deletions src/styles/components/keyboard-shortcuts.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@import "font-groups.styl"

.keyboard-shortcuts
font-family: $playfair-display
font-size: 0.8em

h2
margin: 0

table
border-collapse: collapse
width: 100%

td
padding: 0.25em 0

th
display: inline-block
margin: 1em 0 0.5em 0

0 comments on commit baf8581

Please sign in to comment.