From 9e74d6200fee77fee1dc6fd80d4866db5948c8da Mon Sep 17 00:00:00 2001 From: Sean Li Date: Mon, 8 Jun 2015 15:11:07 -0700 Subject: [PATCH] Refactored widget display logic. --- src/components/ContainerHome.react.js | 59 +++++++++++--------- src/components/ContainerHomeFolders.react.js | 26 ++++----- src/components/ContainerHomePreview.react.js | 13 ++++- styles/container-home.less | 25 ++++----- styles/mixins.less | 29 ++++++++-- 5 files changed, 91 insertions(+), 61 deletions(-) diff --git a/src/components/ContainerHome.react.js b/src/components/ContainerHome.react.js index 35656de7dc..86f1f05712 100644 --- a/src/components/ContainerHome.react.js +++ b/src/components/ContainerHome.react.js @@ -35,6 +35,18 @@ var ContainerHome = React.createClass({ shell.openExternal('https://github.com/kitematic/kitematic/issues/new'); }, + showWeb: function () { + console.log(_.keys(this.props.ports)); + return _.keys(this.props.ports).length > 0; + }, + + showFolders: function () { + console.log('SUPETEST'); + console.log(this.props.container.Volumes); + console.log(_.keys(this.props.container.Volumes).length); + return this.props.container.Volumes && _.keys(this.props.container.Volumes).length > 0 && this.props.container.State.Running; + }, + render: function () { if (!this.props.container) { return; @@ -88,43 +100,40 @@ var ContainerHome = React.createClass({ ); } } else { - if (this.props.defaultPort) { + var logWidget = ( + + ); + var webWidget; + if (this.showWeb()) { + webWidget = ( + + ); + } + var folderWidget; + if (this.showFolders()) { + folderWidget = ( + + ); + } + if (logWidget && !webWidget && !folderWidget) { body = (
-
- -
-
- - -
+ {logWidget}
); } else { - var right; - if (_.keys(this.props.ports) > 0) { - right = ( -
- - -
- ); - } else { - right = ( -
- -
- ); - } body = (
- + {logWidget} +
+
+ {webWidget} + {folderWidget}
- {right}
); diff --git a/src/components/ContainerHomeFolders.react.js b/src/components/ContainerHomeFolders.react.js index 0d7206f214..acd051daae 100644 --- a/src/components/ContainerHomeFolders.react.js +++ b/src/components/ContainerHomeFolders.react.js @@ -73,23 +73,21 @@ var ContainerHomeFolder = React.createClass({ ); }); - if (this.props.container.Volumes && _.keys(this.props.container.Volumes).length > 0 && this.props.container.State.Running) { - return ( -
-
-
-
Edit Files
-
-
- {folders} + return ( +
+
+
+
Edit Files
+
+
-
Change Folders
+
+ {folders} +
- ); - } else { - return false; - } +
+ ); } }); diff --git a/src/components/ContainerHomePreview.react.js b/src/components/ContainerHomePreview.react.js index e5c9e6425b..2295c30f8e 100644 --- a/src/components/ContainerHomePreview.react.js +++ b/src/components/ContainerHomePreview.react.js @@ -47,18 +47,22 @@ var ContainerHomePreview = React.createClass({ render: function () { var preview; + var tempDisp = ( +
Open in Browser
+ ); if (this.props.defaultPort) { var frame = React.createElement('webview', {className: 'frame', id: 'webview', src: this.props.ports[this.props.defaultPort].url, autosize: 'on'}); preview = (
-
WEB PREVIEW
+
Web Preview
+
+ +
{frame} -
Open in Browser
-
Not showing correctly?
); } else { @@ -78,6 +82,9 @@ var ContainerHomePreview = React.createClass({
IP & PORTS
+
+ +

You can access this container using the following IP address and port:

diff --git a/styles/container-home.less b/styles/container-home.less index 227cc5c096..1fbbdaf2d9 100644 --- a/styles/container-home.less +++ b/styles/container-home.less @@ -15,21 +15,14 @@ width: 40%; flex-direction: column; } - .subtext { - text-align: right; - color: @gray-lighter; - margin-top: 2px; - transition: all 0.25s; - &:hover { - color: darken(@gray-lightest, 10%); - } - } .web-preview { - margin-bottom: 50px; + margin-bottom: 1rem; .widget { .widget-style(); + .top-bar { + .widget-bar-style(); + } background-color: white; - padding: 0.5rem; width: 100%; height: 100%; p { @@ -90,6 +83,7 @@ } } .frame { + padding-top: 8rem; border: 0; position: absolute; left: -100%; @@ -132,14 +126,16 @@ .widget-bar-style(); background-color: darken(@gray-darkest, 3%); border-bottom: 1px solid rgba(255,255,255,0.1); - color: white; + .text { + color: white; + } } height: 100%; .logs { background-color: @gray-darkest; color: @gray-lightest; font-family: @font-code; - font-size: 9px; + font-size: 10px; white-space: pre-wrap; -webkit-user-select: text; padding: 1.2rem; @@ -189,6 +185,9 @@ display: flex; padding: 1rem; border-bottom: 1px solid @color-divider; + &:last-child { + border-bottom: none; + } &:hover { background-color: @color-box-button; } diff --git a/styles/mixins.less b/styles/mixins.less index c076054771..0044bc200b 100644 --- a/styles/mixins.less +++ b/styles/mixins.less @@ -31,13 +31,30 @@ .widget-bar-style() { height: 40px; - text-transform: uppercase; - font-size: 12px; - font-weight: 500; - padding: 1.1rem; background-color: white; - color: @gray-light; border-bottom: 1px solid @color-divider; + display: flex; + align-items: flex-start; + position: relative; + z-index: 99999; + .text { + flex: 1 auto; + padding: 1.1rem; + text-transform: uppercase; + font-size: 12px; + font-weight: 500; + color: @gray-light; + } + .settings { + flex: 0 auto; + height: 40px; + width: 40px; + align-self: flex-end; + border-left: 1px solid @color-divider; + padding-top: 0.3rem; + padding-left: 0.9rem; + .box-button(); + } } .fade-in() { @@ -48,7 +65,7 @@ } .box-button { - transition: all 140ms; + transition: all 100ms; color: @gray-light; font-size: 10px; font-weight: 500;