diff --git a/package.json b/package.json
index e3db1336c..bc8e1089c 100644
--- a/package.json
+++ b/package.json
@@ -57,7 +57,7 @@
"react-redux": "^4.4.0",
"react-router": "^2.0.0",
"redux": "^3.3.1",
- "redux-storage": "^3.0.0",
+ "redux-storage": "^4.0.0",
"redux-storage-engine-localstorage": "^1.0.0",
"sass-loader": "^3.1.2",
"style-loader": "^0.13.0",
diff --git a/src/Components/Header/Header.js b/src/Components/Header/Header.js
index f2b450d56..627135328 100644
--- a/src/Components/Header/Header.js
+++ b/src/Components/Header/Header.js
@@ -1,5 +1,7 @@
import React from 'react';
+import MarkdownIcon from '../../Components/Icons/Markdown';
+
import styles from './Header.scss';
import classNames from 'classnames/bind';
const cx = classNames.bind(styles);
@@ -7,23 +9,26 @@ const cx = classNames.bind(styles);
const Header = ({
activeEditors,
toggleEditors,
- addRevision,
}) => {
return (
Beautiful Atlas
-
-
+ Markdown
-
+
+
+ Text
-
-
- Save
+ >
+ Aa
+
);
@@ -32,7 +37,6 @@ const Header = ({
Header.propTypes = {
activeEditors: React.PropTypes.array.isRequired,
toggleEditors: React.PropTypes.func.isRequired,
- addRevision: React.PropTypes.func.isRequired,
};
export default Header;
diff --git a/src/Components/Header/Header.scss b/src/Components/Header/Header.scss
index 9b9616ea6..435a588c2 100644
--- a/src/Components/Header/Header.scss
+++ b/src/Components/Header/Header.scss
@@ -2,6 +2,9 @@
display: flex;
width: 100%;
height: 42px;
+ position: fixed;
+ z-index: 9999;
+
justify-content: space-between;
background-color: #111;
@@ -29,26 +32,29 @@
}
}
- .editorToggle {
- span {
- margin-right: 12px;
- cursor: pointer;
+ .editorToggle div {
+ margin-right: 12px;
+ cursor: pointer;
+ opacity: 0.4;
+ color: #fff;
- &:last-child {
- margin-right: 0;
- }
+ &.active {
+ opacity: 1;
+ }
+
+ &:first-child {
+ margin-top: 2px;
+ margin-right: 15px;
+ }
+
+ &:last-child {
+ margin-top: -2px;
}
}
- .sidebar {
- span {
- margin-right: 12px;
- cursor: pointer;
- }
- }
+ .textIcon {
+ font-family: Times, serif;
+ font-size: 20px;
- .active {
- text-decoration: underline;
- text-decoration-color: #fff;
}
}
\ No newline at end of file
diff --git a/src/Components/Icons/Markdown.js b/src/Components/Icons/Markdown.js
new file mode 100644
index 000000000..2d3caabbf
--- /dev/null
+++ b/src/Components/Icons/Markdown.js
@@ -0,0 +1,31 @@
+import React from 'react';
+
+export default ({ style = {}, className }) => {
+ return (
+
+
+
+ );
+};
diff --git a/src/Components/MarkdownEditor/MarkdownEditor.js b/src/Components/MarkdownEditor/MarkdownEditor.js
index 2e69a74ad..cdac8d1a7 100644
--- a/src/Components/MarkdownEditor/MarkdownEditor.js
+++ b/src/Components/MarkdownEditor/MarkdownEditor.js
@@ -1,6 +1,7 @@
import React from 'react';
import Codemirror from 'react-codemirror';
import 'codemirror/mode/gfm/gfm';
+import 'codemirror/mode/javascript/javascript';
import 'codemirror/addon/edit/continuelist';
import styles from './MarkdownEditor.scss';
diff --git a/src/Components/MarkdownEditor/MarkdownEditor.scss b/src/Components/MarkdownEditor/MarkdownEditor.scss
index ded1dd455..a51254f66 100644
--- a/src/Components/MarkdownEditor/MarkdownEditor.scss
+++ b/src/Components/MarkdownEditor/MarkdownEditor.scss
@@ -1,4 +1,13 @@
.container {
- width: 70%;
- margin: 48px auto;
+ font-weight: 400;
+ font-size: 1em;
+ line-height: 1.5em;
+
+ margin: 0 auto;
+ padding: 2em 3em;
+ max-width: 50em;
+}
+
+@media all and (max-width: 2000px) and (min-width: 960px) {
+ .container {font-size: 1.1em}
}
\ No newline at end of file
diff --git a/src/Components/MarkdownEditor/codemirror.css b/src/Components/MarkdownEditor/codemirror.css
index 339ff1ffb..d3fa3908f 100644
--- a/src/Components/MarkdownEditor/codemirror.css
+++ b/src/Components/MarkdownEditor/codemirror.css
@@ -11,10 +11,11 @@
@import url(https://fonts.googleapis.com/css?family=Cousine:400,700,700italic,400italic);
.cm-s-atlas.CodeMirror {
- background: #fcfcfc;
+ background: #ffffff;
color: #202020;
font-family: 'Cousine', 'Monaco', monospace;
font-weight: 300;
+ height: auto;
}
.cm-s-atlas div.CodeMirror-selected {
background: #90CAF9;
diff --git a/src/Components/TextEditor/TextEditor.scss b/src/Components/TextEditor/TextEditor.scss
index 845d035e6..d088f27d7 100644
--- a/src/Components/TextEditor/TextEditor.scss
+++ b/src/Components/TextEditor/TextEditor.scss
@@ -1,5 +1,17 @@
+.container {
+ font-weight: 400;
+ font-size: 1em;
+ line-height: 1.5em;
+
+ margin: 0 auto;
+ padding: 2em 3em;
+ max-width: 50em;
+}
+
.editor {
outline: none;
- margin: 0 0 20px 0;
- padding: 0 0 20px 0;
+}
+
+@media all and (max-width: 2000px) and (min-width: 960px) {
+ .container {font-size: 1.1em}
}
\ No newline at end of file
diff --git a/src/Reducers/index.js b/src/Reducers/index.js
index 000494ca9..adca3d4fd 100644
--- a/src/Reducers/index.js
+++ b/src/Reducers/index.js
@@ -12,11 +12,12 @@ import {
const activeEditors = (state = [ActiveEditors.MARKDOWN, ActiveEditors.TEXT], action) => {
switch (action.type) {
case TOGGLE_EDITORS: {
+ // TODO: A rewrite would be nice
const newState = _.xor(state, [action.toggledEditor]);
if (newState.length > 0) {
return newState;
} else {
- return [action.toggledEditor];
+ return _.xor([ActiveEditors.MARKDOWN, ActiveEditors.TEXT], [action.toggledEditor]);
}
}
default:
@@ -37,15 +38,28 @@ const historySidebar = (state = { visible: false }, action) => {
}
};
-const text = (state = { text: '', revisions: [] }, action) => {
+const textDefaultState = {
+ text: '',
+ revisions: [],
+ unsavedChanges: false,
+};
+
+const text = (state = textDefaultState, action) => {
+ const lastRevision = _.last(state.revisions);
+
switch (action.type) {
- case UPDATE_TEXT:
+ case UPDATE_TEXT: {
+ let unsavedChanges = false;
+ if (lastRevision && lastRevision.text !== state.text) {
+ unsavedChanges = true;
+ }
return {
...state,
+ unsavedChanges,
text: action.text,
};
+ }
case ADD_REVISION: {
- const lastRevision = _.last(state.revisions);
// Create new revision if it differs from the previous one
if (!lastRevision || lastRevision.text !== state.text) {
const lastId = lastRevision ? lastRevision.id : 0;
@@ -59,6 +73,7 @@ const text = (state = { text: '', revisions: [] }, action) => {
created_at: action.createdAt,
},
],
+ unsavedChanges: false,
};
} else {
return state;
diff --git a/src/Views/App/App.js b/src/Views/App/App.js
index 633875222..38994733a 100644
--- a/src/Views/App/App.js
+++ b/src/Views/App/App.js
@@ -19,6 +19,7 @@ class App extends Component {
activeEditors: React.PropTypes.array.isRequired,
toggleEditors: React.PropTypes.func.isRequired,
addRevision: React.PropTypes.func.isRequired,
+ unsavedChanges: React.PropTypes.bool.isRequired,
}
state = {
@@ -47,6 +48,7 @@ class App extends Component {
activeEditors={this.props.activeEditors}
toggleEditors={this.props.toggleEditors}
addRevision={this.props.addRevision}
+ unsavedChanges={this.props.unsavedChanges}
/>
{ this.props.children }
@@ -59,7 +61,7 @@ class App extends Component {
const mapStateToProps = (state) => {
return {
activeEditors: state.activeEditors,
- showHistorySidebar: state.historySidebar.visible,
+ unsavedChanges: state.text.unsavedChanges,
};
};
diff --git a/src/Views/Dashboard/Dashboard.scss b/src/Views/Dashboard/Dashboard.scss
index 80d56502a..6d832691c 100644
--- a/src/Views/Dashboard/Dashboard.scss
+++ b/src/Views/Dashboard/Dashboard.scss
@@ -1,5 +1,6 @@
.container {
display: flex;
+ padding-top: 48px;
}
.panel {
@@ -11,5 +12,5 @@
}
.markdown {
- background-color: #fbfbfb;
-}
\ No newline at end of file
+ background-color: #ffffff;
+}