Skip to content
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

Add a status bar to Editor component #538

Merged
merged 4 commits into from
Dec 1, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
35 changes: 20 additions & 15 deletions src/components/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,26 @@ class Editor extends Component {
const { content, type } = this.props;
const mode = /json/i.test(type) ? 'json' : 'yaml';
return (
<AceEditor
value={content}
mode={mode}
theme="monokai"
width="100%"
height="400px"
showGutter={false}
showPrintMargin={false}
highlightActiveLine={false}
className="config-editor"
fontSize={14}
scrollMargin={[15, 15, 15, 15]}
ref="ace"
onChange={this.handleChange}
/>
<div>
<AceEditor
value={content}
mode={mode}
theme="monokai"
width="100%"
height="400px"
showGutter={false}
showPrintMargin={false}
highlightActiveLine={false}
className="config-editor"
fontSize={14}
scrollMargin={[15, 15, 15, 15]}
ref="ace"
onChange={this.handleChange}
/>
<div className="statusbar">
<span>mode: {mode.toUpperCase()}</span>
ashmaroli marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>
);
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/tests/editor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function setup(props = { content, editorChanged: false }) {

return {
component,
editor: component.first(),
editor: component.find('.config-editor'),
actions: actions,
};
}
Expand All @@ -24,11 +24,13 @@ describe('Components::Editor', () => {
const { editor } = setup();
expect(editor.prop('value')).toEqual(content);
});

it('should call onEditorChange if editor is not changed', () => {
const { actions, editor } = setup();
editor.simulate('change');
expect(actions.onEditorChange).toHaveBeenCalled();
});

it('should not call onEditorChange again if editor is already changed', () => {
const { actions, editor } = setup({ content, editorChanged: true });
editor.simulate('change');
Expand Down
8 changes: 8 additions & 0 deletions src/styles/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
border-radius: $border-radius;
outline: none;
font-size: 14px;

& + .statusbar {
padding: 12px 0;
font-size: 12px;
color: #959694;
text-align: right;
border-bottom: 1px solid $border-color;
}
}

.ace_focus {
Expand Down