This repository has been archived by the owner on Jul 9, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a help modal that explains all the shortcuts
- Loading branch information
1 parent
3955f1b
commit c23fb6a
Showing
9 changed files
with
210 additions
and
33 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react' | ||
import Table from '@material-ui/core/Table' | ||
import TableBody from '@material-ui/core/TableBody' | ||
import TableCell from '@material-ui/core/TableCell' | ||
import TableRow from '@material-ui/core/TableRow' | ||
import Typography from '@material-ui/core/Typography' | ||
import Chip from '@material-ui/core/Chip' | ||
|
||
const ShortcutTable = ({ title, keys }) => ( | ||
<div> | ||
<Typography | ||
variant="subtitle1" | ||
style={{ borderBottom: '1px solid', paddingLeft: 24 }} | ||
> | ||
{title} | ||
</Typography> | ||
<Table style={{ marginBottom: 40 }}> | ||
<TableBody> | ||
{keys.map(key => ( | ||
<TableRow key={`key-row-${title}-${key.name}`}> | ||
<TableCell style={{ width: '15em' }}>{key.name}</TableCell> | ||
<TableCell> | ||
{key.shortcuts.map(key => ( | ||
<Chip | ||
key={`key-row-${title}-${key.name}-key-${key}`} | ||
label={key} | ||
style={{ marginRight: 10 }} | ||
/> | ||
))} | ||
</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</div> | ||
) | ||
|
||
export default ShortcutTable |
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,121 @@ | ||
import React from 'react' | ||
import { bindActionCreators } from 'redux' | ||
import { connect } from 'react-redux' | ||
import SettingsModal from '../SettingsModal' | ||
import { toggleShortcutHelp } from '../../actions' | ||
import keymap from '../../modules/keymap' | ||
import ShortcutTable from './ShortcutTable' | ||
|
||
const globalKeys = [ | ||
{ | ||
name: 'Focus Channels List', | ||
shortcuts: keymap.GLOBAL.FOCUS_CHANNEL_LIST, | ||
}, | ||
{ | ||
name: 'Show Keyboard Shorcuts', | ||
shortcuts: keymap.GLOBAL.HELP, | ||
}, | ||
{ | ||
name: 'Open New Post Editor', | ||
shortcuts: keymap.GLOBAL.NEW_POST, | ||
}, | ||
{ | ||
name: 'Load Channel', | ||
shortcuts: ['ctrl+1-9', 'meta+1-9', 'alt+1-9'], | ||
}, | ||
] | ||
|
||
const channelListKeys = [ | ||
{ | ||
name: 'Next Channel', | ||
shortcuts: keymap.CHANNEL_LIST.NEXT, | ||
}, | ||
{ | ||
name: 'Previous Channel', | ||
shortcuts: keymap.CHANNEL_LIST.PREVIOUS, | ||
}, | ||
{ | ||
name: 'Load Channel', | ||
shortcuts: keymap.CHANNEL_LIST.SELECT_CHANNEL, | ||
}, | ||
] | ||
|
||
const channelKeys = [ | ||
{ | ||
name: 'Next Post', | ||
shortcuts: keymap.TIMELINE.NEXT, | ||
}, | ||
{ | ||
name: 'Previous Post', | ||
shortcuts: keymap.TIMELINE.PREVIOUS, | ||
}, | ||
{ | ||
name: 'Select Post', | ||
shortcuts: keymap.TIMELINE.SELECT_POST, | ||
}, | ||
{ | ||
name: 'Focus Channel List', | ||
shortcuts: keymap.TIMELINE.FOCUS_CHANNEL_LIST, | ||
}, | ||
{ | ||
name: 'Toggle Selected Post Read', | ||
shortcuts: keymap.TIMELINE.MARK_READ, | ||
}, | ||
] | ||
|
||
const singlePostKeys = [ | ||
{ | ||
name: 'Next Post', | ||
shortcuts: keymap.POST.NEXT, | ||
}, | ||
{ | ||
name: 'Open Post Url', | ||
shortcuts: keymap.POST.OPEN, | ||
}, | ||
{ | ||
name: 'Toggle Post Read', | ||
shortcuts: keymap.POST.TOGGLE_READ, | ||
}, | ||
{ | ||
name: 'Back to Post List', | ||
shortcuts: keymap.POST.TO_TIMELINE, | ||
}, | ||
{ | ||
name: 'Scroll Up', | ||
shortcuts: keymap.POST.SCROLL_UP, | ||
}, | ||
{ | ||
name: 'Scroll Down', | ||
shortcuts: keymap.POST.SCROLL_DOWN, | ||
}, | ||
] | ||
|
||
const ShortcutHelp = ({ open, toggleShortcutHelp }) => { | ||
return ( | ||
<SettingsModal | ||
title="Keyboard Controls" | ||
maxWidth="lg" | ||
open={open} | ||
onClose={() => (open ? toggleShortcutHelp() : null)} | ||
singleColumn | ||
disableAutoFocus | ||
> | ||
<ShortcutTable title="Global Controls" keys={globalKeys} /> | ||
<ShortcutTable title="Channel List Controls" keys={channelListKeys} /> | ||
<ShortcutTable title="Channel Controls" keys={channelKeys} /> | ||
<ShortcutTable title="Post Controls" keys={singlePostKeys} /> | ||
</SettingsModal> | ||
) | ||
} | ||
|
||
const mapStateToProps = state => ({ | ||
open: state.app.get('shortcutHelpOpen'), | ||
}) | ||
|
||
const mapDispatchToProps = dispatch => | ||
bindActionCreators({ toggleShortcutHelp }, dispatch) | ||
|
||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(ShortcutHelp) |
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