Skip to content

Add support for changing the ACE keybinding #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 31, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve display of editor configuration
Add some basic styling and only show the advanced editor options when
the advanced editor is selected.
  • Loading branch information
shepmaster committed Jul 31, 2016
commit ac2af34b6b68688c3b21cefe0261ff4a1ed48c22
77 changes: 52 additions & 25 deletions ui/frontend/Configuration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,29 @@ import {
const keybindingOptions = ACE_KEYBINDINGS.map(t => <option value={t} key={t}>{t}</option>);
const themeOptions = ACE_THEMES.map(t => <option value={t} key={t}>{t}</option>);

const ConfigurationSelect = ({ what, label, defaultValue, onChange, children }) => (
<div className="configuration-item">
<label htmlFor={`config-${what}`}
className="configuration-label">
{label}
</label>
<select name={`config-${what}`}
className="configuration-value"
defaultValue={defaultValue}
onChange={onChange}>
{children}
</select>
</div>
);

ConfigurationSelect.propTypes = {
what: PropTypes.string.isRequired,
label: PropTypes.string.isRequired,
defaultValue: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
children: PropTypes.node.isRequired,
};

class Configuration extends PureComponent {
onChangeEditor = e => this.props.changeEditor(e.target.value);
onChangeKeybinding = e => this.props.changeKeybinding(e.target.value);
Expand All @@ -22,35 +45,39 @@ class Configuration extends PureComponent {
render() {
const { editor, keybinding, theme, toggleConfiguration } = this.props;

const advancedEditor = editor === 'advanced';

const keybindingSelect = advancedEditor ? (
<ConfigurationSelect what="keybinding"
label="Editor Keybinding"
defaultValue={keybinding}
onChange={this.onChangeKeybinding}>
{ keybindingOptions }
</ConfigurationSelect>
) : null;

const themeSelect = advancedEditor ? (
<ConfigurationSelect what="theme"
label="Editor Theme"
defaultValue={theme}
onChange={this.onChangeTheme}>
{ themeOptions }
</ConfigurationSelect>
) : null;

return (
<div className="configuration">
<div>
<label htmlFor="config-editor">Editor Style</label>
<select name="config-editor"
defaultValue={editor}
onChange={this.onChangeEditor}>
<option value="simple">Simple</option>
<option value="advanced">Advanced</option>
</select>
</div>
<ConfigurationSelect what="editor"
label="Editor Style"
defaultValue={editor}
onChange={this.onChangeEditor}>
<option value="simple">Simple</option>
<option value="advanced">Advanced</option>
</ConfigurationSelect>

<div>
<label htmlFor="config-keybinding">Editor Keybinding</label>
<select name="config-keybinding"
defaultValue={keybinding}
onChange={this.onChangeKeybinding}>
{ keybindingOptions }
</select>
</div>
{keybindingSelect}

<div>
<label htmlFor="config-theme">Editor Theme</label>
<select name="config-theme"
defaultValue={theme}
onChange={this.onChangeTheme}>
{ themeOptions }
</select>
</div>
{themeSelect}

<div className="configuration-actions">
<button onClick={toggleConfiguration}>Done</button>
Expand Down
13 changes: 11 additions & 2 deletions ui/frontend/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,17 @@ body {
width: 100%;
height: 100%;

label {
margin-right: 1em;
&-item {
display: flex;
margin-bottom: 0.5em;
}

&-label {
flex: 1 1 100%;
}

&-value {
flex: 1 1 100%;
}

&-actions {
Expand Down