diff --git a/packages/fether-electron/src/main/index.js b/packages/fether-electron/src/main/index.js index 732e7743e250557b309f29daf736536158ed86a2..10d54619eb2930d5de204713ff4f63d0ab6f7e4d 100644 --- a/packages/fether-electron/src/main/index.js +++ b/packages/fether-electron/src/main/index.js @@ -82,7 +82,9 @@ function createWindow () { ); // Listen to messages from renderer process - ipcMain.on('asynchronous-message', messages); + ipcMain.on('asynchronous-message', (...args) => + messages(mainWindow, ...args) + ); // Add application menu addMenu(mainWindow); diff --git a/packages/fether-electron/src/main/messages/index.js b/packages/fether-electron/src/main/messages/index.js index 3f1687e383bbdd179c91f52a526c19d4f7f74714..42e9d3d6c14848d8812867b1a795fd044d486a9c 100644 --- a/packages/fether-electron/src/main/messages/index.js +++ b/packages/fether-electron/src/main/messages/index.js @@ -5,17 +5,34 @@ import { signerNewToken } from '@parity/electron'; +import Pino from '../utils/pino'; + +const pino = Pino(); + /** * Handle all asynchronous messages from renderer to main. */ -export default async (event, arg) => { - switch (arg) { - case 'signer-new-token': { - const token = await signerNewToken(); - // Send back the token to the renderer process - event.sender.send('asynchronous-reply', token); - break; +export default async (mainWindow, event, action, ...args) => { + try { + if (!action) { + return; + } + switch (action) { + case 'app-resize': { + const [width] = mainWindow.getContentSize(); + const newHeight = args[0]; + mainWindow.setContentSize(width, Math.round(newHeight) + 2); + break; + } + case 'signer-new-token': { + const token = await signerNewToken(); + // Send back the token to the renderer process + event.sender.send('asynchronous-reply', token); + break; + } + default: } - default: + } catch (err) { + pino.error(err); } }; diff --git a/packages/fether-react/package.json b/packages/fether-react/package.json index 092a19c2709d53ef414f025099ef664afd408b5c..27d1b2ffab5511c4c2d6cfbf10eb39fe50887b77 100644 --- a/packages/fether-react/package.json +++ b/packages/fether-react/package.json @@ -52,6 +52,7 @@ "react-dom": "^16.3.2", "react-final-form": "^3.6.4", "react-markdown": "^3.3.4", + "react-resize-detector": "^3.0.1", "react-router-dom": "^4.2.2", "react-scripts": "1.1.4", "recompose": "^0.27.1", diff --git a/packages/fether-react/src/App/App.js b/packages/fether-react/src/App/App.js index fc8a44f541c2680df740e9766da6b81a92a8f059..5b34d1a9c1adcb44f33c1351bc22eca0793537b4 100644 --- a/packages/fether-react/src/App/App.js +++ b/packages/fether-react/src/App/App.js @@ -12,6 +12,8 @@ import { Switch } from 'react-router-dom'; import { inject, observer } from 'mobx-react'; +import isElectron from 'is-electron'; +import ReactResizeDetector from 'react-resize-detector'; import Accounts from '../Accounts'; import Onboarding from '../Onboarding'; @@ -25,17 +27,26 @@ import Whitelist from '../Whitelist'; // https://github.com/facebook/create-react-app/issues/3591 const Router = process.env.NODE_ENV === 'production' ? MemoryRouter : BrowserRouter; +const electron = isElectron() ? window.require('electron') : null; @inject('healthStore', 'onboardingStore') @observer class App extends Component { + handleResize = (_, height) => { + if (!electron) { + return; + } + // Send height to main process + electron.ipcRenderer.send('asynchronous-message', 'app-resize', height); + }; + render () { return ( - -
+ +
{this.renderScreen()}
-
-
+ + ); } diff --git a/packages/fether-react/src/assets/sass/layouts/_wrapper.scss b/packages/fether-react/src/assets/sass/layouts/_wrapper.scss index 5d07a1df842c2ba1d0d8e802cec48941ba0e0c54..719fd6d235505b6d18d17ecb2f486b689257bd49 100644 --- a/packages/fether-react/src/assets/sass/layouts/_wrapper.scss +++ b/packages/fether-react/src/assets/sass/layouts/_wrapper.scss @@ -1,58 +1,49 @@ -.wrapper { - position: fixed; - left: 0; - right: 0; - top: 0; - bottom: 0; - overflow: hidden; +.content { + // TODO: abstract this out + overflow: visible; + max-width: 22rem; + margin: 0 auto; - .content { - // TODO: abstract this out - overflow: visible; - max-width: 22rem; - margin: 0 auto; + .connector { + height: 0.5rem; + display: flex; + justify-content: center; - .connector { - height: 0.5rem; - display: flex; - justify-content: center; - - &.-top { - margin-bottom: -1px; - } + &.-top { + margin-bottom: -1px; + } - svg { - height: 0.5rem; - width: auto; - polygon { - fill: $chrome; - } + svg { + height: 0.5rem; + width: auto; + polygon { + fill: $chrome; } } + } - .window { - background: $chrome; - border-radius: 0.25rem; - overflow: hidden; - position: relative; - box-shadow: 0 0.125rem 0.75rem rgba($black, 0.175), - 0 0.125rem 0.125rem rgba($black, 0.1); + .window { + background: $chrome; + border-radius: 0.25rem; + overflow: hidden; + position: relative; + box-shadow: 0 0.125rem 0.75rem rgba($black, 0.175), + 0 0.125rem 0.125rem rgba($black, 0.1); - .window_content { - min-height: 7.5rem; - } + .window_content { + min-height: 7.5rem; + } - .window_overlay { - background-color: $chrome; - bottom: 0; - left: 0; - min-height: 7.5rem; - opacity: 0.98; - position: absolute; - right: 0; - top: 0; - z-index: 10; - } + .window_overlay { + background-color: $chrome; + bottom: 0; + left: 0; + min-height: 7.5rem; + opacity: 0.98; + position: absolute; + right: 0; + top: 0; + z-index: 10; } } } diff --git a/packages/fether-react/src/assets/sass/shared/_basics.scss b/packages/fether-react/src/assets/sass/shared/_basics.scss index 0a1f0695f109c6518c3396a000e5cbcdc644ba1b..e70205079e8ffc8027b590640eb4542000947e44 100644 --- a/packages/fether-react/src/assets/sass/shared/_basics.scss +++ b/packages/fether-react/src/assets/sass/shared/_basics.scss @@ -1,6 +1,5 @@ html { font-size: 16px; - height: 100%; } body { @@ -10,7 +9,6 @@ body { font-weight: 400; font-size: ms(0); line-height: ms(0) * 1.3; - min-height: 100%; } .hidden { diff --git a/yarn.lock b/yarn.lock index b61f7ff47a69fe1ff7862d315c89266c76d4cf43..20e3797cc0c252ec560d40394b4f99d7cb735177 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7561,6 +7561,14 @@ lodash.defaults@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c" +lodash.isarray@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-4.0.0.tgz#2aca496b28c4ca6d726715313590c02e6ea34403" + +lodash.isfunction@^3.0.9: + version "3.0.9" + resolved "https://registry.yarnpkg.com/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz#06de25df4db327ac931981d1bdb067e5af68d051" + lodash.memoize@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" @@ -7582,6 +7590,10 @@ lodash.templatesettings@^4.0.0: dependencies: lodash._reinterpolate "~3.0.0" +lodash.throttle@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4" + lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" @@ -9599,6 +9611,17 @@ react-redux@4.4.6: lodash "^4.2.0" loose-envify "^1.1.0" +react-resize-detector@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/react-resize-detector/-/react-resize-detector-3.0.1.tgz#73214983c0652e96fac1e2eba39b5501de3e2a12" + dependencies: + lodash.debounce "^4.0.8" + lodash.isarray "^4.0.0" + lodash.isfunction "^3.0.9" + lodash.throttle "^4.1.1" + prop-types "^15.6.1" + resize-observer-polyfill "^1.5.0" + react-router-dom@^4.2.2: version "4.3.1" resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-4.3.1.tgz#4c2619fc24c4fa87c9fd18f4fb4a43fe63fbd5c6" @@ -10143,6 +10166,10 @@ requires-port@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" +resize-observer-polyfill@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.0.tgz#660ff1d9712a2382baa2cad450a4716209f9ca69" + resolve-cwd@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a"