From aace545ba61e4b0890481d144441fa376940eb6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=BCchele?= Date: Fri, 10 Aug 2018 08:52:02 -0700 Subject: [PATCH] move WelcomeScreen Summary: The sidebar is now shown, even if no device is connected. This prevents the jumping layout when Flipper launches, but still has not connected to devices. Reviewed By: passy Differential Revision: D9263892 fbshipit-source-id: d5b96a8619393ee4002863a83d9024f00c6cb396 --- src/App.js | 16 +++++------- src/chrome/MainSidebar.js | 50 ++++++++++++++++++++++-------------- src/chrome/WelcomeScreen.js | 6 +++-- src/ui/components/Sidebar.js | 10 ++++++-- static/index.dev.html | 41 ++++++++++------------------- static/index.js | 1 + 6 files changed, 64 insertions(+), 60 deletions(-) diff --git a/src/App.js b/src/App.js index ac60810f3..24ea397d3 100644 --- a/src/App.js +++ b/src/App.js @@ -52,16 +52,14 @@ export class App extends React.Component { close={() => this.props.toggleBugDialogVisible(false)} /> )} - {this.props.selectedDevice ? ( - - {this.props.leftSidebarVisible && } + + {this.props.leftSidebarVisible && } + {this.props.selectedDevice ? ( - - ) : this.props.pluginManagerVisible ? ( - - ) : ( - - )} + ) : ( + + )} + ); diff --git a/src/chrome/MainSidebar.js b/src/chrome/MainSidebar.js index dc524a7cd..6715b58e9 100644 --- a/src/chrome/MainSidebar.js +++ b/src/chrome/MainSidebar.js @@ -135,7 +135,8 @@ class PluginSidebarListItem extends Component<{ type MainSidebarProps = {| selectedPlugin: ?string, selectedApp: ?string, - selectedDevice: BaseDevice, + selectedDevice: ?BaseDevice, + windowIsFocused: boolean, selectPlugin: (payload: { selectedPlugin: ?string, selectedApp: ?string, @@ -150,12 +151,13 @@ class MainSidebar extends Component { selectedPlugin, selectedApp, selectPlugin, + windowIsFocused, } = this.props; let {clients} = this.props; let enabledPlugins = []; for (const devicePlugin of devicePlugins) { - if (selectedDevice.supportsPlugin(devicePlugin)) { + if (selectedDevice && selectedDevice.supportsPlugin(devicePlugin)) { enabledPlugins.push(devicePlugin); } } @@ -179,22 +181,28 @@ class MainSidebar extends Component { .sort((a, b) => (a.query.app || '').localeCompare(b.query.app)); return ( - - {devicePlugins - .filter(selectedDevice.supportsPlugin) - .map((plugin: Class>) => ( - - selectPlugin({ - selectedPlugin: plugin.id, - selectedApp: null, - }) - } - plugin={plugin} - /> - ))} + + {selectedDevice && + devicePlugins + .filter(selectedDevice.supportsPlugin) + .map((plugin: Class>) => ( + + selectPlugin({ + selectedPlugin: plugin.id, + selectedApp: null, + }) + } + plugin={plugin} + /> + ))} {clients.map((client: Client) => ( {client.query.app} @@ -226,7 +234,11 @@ class MainSidebar extends Component { } export default connect( - ({connections: {selectedDevice, selectedPlugin, selectedApp, clients}}) => ({ + ({ + application: {windowIsFocused}, + connections: {selectedDevice, selectedPlugin, selectedApp, clients}, + }) => ({ + windowIsFocused, selectedDevice, selectedPlugin, selectedApp, diff --git a/src/chrome/WelcomeScreen.js b/src/chrome/WelcomeScreen.js index 12d4205c4..ff8393e14 100644 --- a/src/chrome/WelcomeScreen.js +++ b/src/chrome/WelcomeScreen.js @@ -23,7 +23,7 @@ const Container = FlexColumn.extends({ width: '100%', justifyContent: 'center', alignItems: 'center', - backgroundImage: 'url(./pattern.gif)', + backgroundColor: colors.light02, }); const Welcome = FlexColumn.extends( @@ -104,12 +104,14 @@ export default class WelcomeScreen extends PureComponent { }; componentDidMount() { + // waiting sometime before showing the welcome screen to allow Flipper to + // connect to devices, if there are any setTimeout( () => this.setState({ isMounted: true, }), - 100, + 2000, ); } diff --git a/src/ui/components/Sidebar.js b/src/ui/components/Sidebar.js index 96d98e17a..df5854dba 100644 --- a/src/ui/components/Sidebar.js +++ b/src/ui/components/Sidebar.js @@ -8,6 +8,7 @@ import type {StyledComponent} from '../styled/index.js'; import Interactive from './Interactive.js'; import FlexColumn from './FlexColumn.js'; +import {colors} from './colors'; import {Component} from 'react'; const SidebarInteractiveContainer = Interactive.extends({ @@ -21,7 +22,8 @@ const SidebarContainer: StyledComponent<{ overflow?: boolean, }> = FlexColumn.extends( { - backgroundColor: props => props.backgroundColor || '#f7f7f7', + backgroundColor: props => + props.backgroundColor || colors.macOSTitleBarBackgroundBlur, borderLeft: props => props.position === 'right' ? '1px solid #b3b3b3' : 'none', borderTop: props => @@ -103,7 +105,11 @@ type SidebarState = {| export default class Sidebar extends Component { constructor(props: SidebarProps, context: Object) { super(props, context); - this.state = {userChange: false, width: props.width, height: props.height}; + this.state = { + userChange: false, + width: props.width, + height: props.height, + }; } static defaultProps = { diff --git a/static/index.dev.html b/static/index.dev.html index 10221aaf9..c50347685 100644 --- a/static/index.dev.html +++ b/static/index.dev.html @@ -9,7 +9,8 @@ Sonar -
- -
-
Loading...
+
+
+ Loading... +
+ @@ -83,11 +75,6 @@ const box = document.querySelector('.__infinity-dev-box-error'); box.removeAttribute('hidden'); box.textContent = text; - onLoad(); - } - - function onLoad() { - document.querySelector('.__infinity-dev-box-loading').setAttribute('hidden', true); } function init() { @@ -98,8 +85,6 @@ openError('Script failure. Check Chrome console for more info.'); }; - script.onload = onLoad; - document.body.appendChild(script); } diff --git a/static/index.js b/static/index.js index 2ba20048a..fa3a6f304 100644 --- a/static/index.js +++ b/static/index.js @@ -141,6 +141,7 @@ function tryCreateWindow() { fullscreenable: false, backgroundThrottling: false, titleBarStyle: 'hiddenInset', + vibrancy: 'sidebar', webPreferences: { webSecurity: false, scrollBounce: true,