diff --git a/src/sidebar/app/components/CloseIcon.js b/src/sidebar/app/components/CloseIcon.js new file mode 100644 index 000000000..0a32b07cc --- /dev/null +++ b/src/sidebar/app/components/CloseIcon.js @@ -0,0 +1,15 @@ +import React from 'react'; + +function CloseIcon(props) { + return ( + + + + + ); +} + +export default CloseIcon; diff --git a/src/sidebar/app/components/Editor.js b/src/sidebar/app/components/Editor.js index a5a135d2b..f55cb51c8 100644 --- a/src/sidebar/app/components/Editor.js +++ b/src/sidebar/app/components/Editor.js @@ -1,5 +1,7 @@ import React from 'react'; +import CloseIcon from './CloseIcon'; + import { getPadStats, customizeEditor, insertSelectedText } from '../utils/editor'; import INITIAL_CONFIG from '../data/editorConfig'; @@ -11,6 +13,7 @@ class Editor extends React.Component { this.state = { ignoreNextLoadEvent: false, ignoreTextSynced: false, + wasLimitReached: false, isKintoLoaded: false, content: null }; @@ -93,6 +96,12 @@ class Editor extends React.Component { }); }; + this.closeNotification = () => { + this.setState({ + wasLimitReached: false + }); + }; + this.init = (content) => { this.setState({ content @@ -128,11 +137,18 @@ class Editor extends React.Component { }); if (content.length > 15000) { console.error('Maximum notepad size reached:', content.length); // eslint-disable-line no-console - migrationBody.textContent = browser.i18n.getMessage('maximumPadSizeExceeded'); + // TODO: display 'maximumPadSizeExceeded' notification + this.setState({ + wasLimitReached: true, + }); browser.runtime.sendMessage({ action: 'metrics-limit-reached', context: getPadStats(editor) }); + } else { + this.setState({ + wasLimitReached: false, + }); } chrome.runtime.sendMessage({ @@ -165,7 +181,6 @@ class Editor extends React.Component { this.loadContent(); } - componentWillUnmount() { chrome.runtime.onMessage.removeListener(this.events); } @@ -173,13 +188,20 @@ class Editor extends React.Component { render() { return ( -
{ - this.node = node; - }} - dangerouslySetInnerHTML={{ __html: this.state.content }} - > +
+
{ + this.node = node; + }} + dangerouslySetInnerHTML={{ __html: this.state.content }} + > +
+ { this.state.wasLimitReached ? +
+ +

{ browser.i18n.getMessage('maximumPadSizeExceeded') }

+
: null }
); } diff --git a/src/sidebar/static/scss/ckeditor.scss b/src/sidebar/static/scss/ckeditor.scss index abea74ec2..a10357829 100644 --- a/src/sidebar/static/scss/ckeditor.scss +++ b/src/sidebar/static/scss/ckeditor.scss @@ -2,6 +2,27 @@ CKEditor overrides */ +.editorWrapper { + display: flex; + flex: calc(100% - 40px); + flex-direction: column; + flex-grow: 1; + margin: 0; + padding: 0; + overflow: hidden; + position: relative; + +} + +.ck-editor { + display: flex; + flex-direction: column; + height: 100%; + margin: 0; + overflow: hidden; + padding: 0; +} + #notes { .ck-toolbar { border: 0; @@ -98,3 +119,38 @@ box-shadow: none; } } + +// CSS related to Notifications +#sync-note { + background: #00FFFE; // green background is: #B6FEB4; + width: 100%; + position: relative; + margin: 0 auto; + border: 0; + border-top: 1px solid #ccc; + color: #424242; + font-size: 12px; + padding: 0px 15% 0px 10px; + + button { + width: 16px; + position: absolute; + top: 6px; + right: 6px; + padding: 0 0; + opacity: 0.4; + + &:hover { + cursor: pointer; + opacity: 0.6 + } + &:active { + cursor: pointer; + opacity: 0.8 + } + } +} + + + + diff --git a/src/sidebar/static/scss/styles.scss b/src/sidebar/static/scss/styles.scss index 8a3ced2dd..0c13014ec 100644 --- a/src/sidebar/static/scss/styles.scss +++ b/src/sidebar/static/scss/styles.scss @@ -12,8 +12,7 @@ html { } body, -body > div, -body .ck-editor { +body > div { display: flex; flex-direction: column; height: 100%;