diff --git a/client/app/scripts/components/app.js b/client/app/scripts/components/app.js index 39d5120f1c..99adde0a16 100644 --- a/client/app/scripts/components/app.js +++ b/client/app/scripts/components/app.js @@ -1,7 +1,9 @@ const React = require('react'); +const mui = require('material-ui'); const Logo = require('./logo'); const AppStore = require('../stores/app-store'); +const Sidebar = require('./sidebar.js'); const Status = require('./status.js'); const Topologies = require('./topologies.js'); const TopologyOptions = require('./topology-options.js'); @@ -11,6 +13,8 @@ const Details = require('./details'); const Nodes = require('./nodes'); const RouterUtils = require('../utils/router-utils'); +const ThemeManager = new mui.Styles.ThemeManager(); + const ESC_KEY_CODE = 27; function getStateFromStores() { @@ -57,6 +61,12 @@ const App = React.createClass({ } }, + getChildContext: function() { + return { + muiTheme: ThemeManager.getCurrentTheme() + }; + }, + render: function() { const showingDetails = this.state.selectedNodeId; const versionString = this.state.version ? 'Version ' + this.state.version : ''; @@ -70,23 +80,30 @@ const App = React.createClass({
- -
+ + + + +
{versionString}   Report an issue
); - } + }, + childContextTypes: { + muiTheme: React.PropTypes.object + } }); module.exports = App; diff --git a/client/app/scripts/components/details.js b/client/app/scripts/components/details.js index bccab8f1ad..811b7b6426 100644 --- a/client/app/scripts/components/details.js +++ b/client/app/scripts/components/details.js @@ -10,7 +10,7 @@ const Details = React.createClass({ render: function() { return (
- +
diff --git a/client/app/scripts/components/sidebar.js b/client/app/scripts/components/sidebar.js new file mode 100644 index 0000000000..659b7226e4 --- /dev/null +++ b/client/app/scripts/components/sidebar.js @@ -0,0 +1,15 @@ +const React = require('react'); + +const Sidebar = React.createClass({ + + render: function() { + return ( +
+ {this.props.children} +
+ ); + } + +}); + +module.exports = Sidebar; diff --git a/client/app/scripts/components/status.js b/client/app/scripts/components/status.js index d5b726f58f..cea0dc382f 100644 --- a/client/app/scripts/components/status.js +++ b/client/app/scripts/components/status.js @@ -14,10 +14,17 @@ const Status = React.createClass({ } }, + renderTopologyStats: function(stats) { + const statsText = `${stats.node_count} nodes, ${stats.edge_count} connections`; + return
{statsText}
; + }, + render: function() { + const showStats = this.props.topology && !this.props.errorUrl && !this.props.websocketClosed; return ( -
- {this.renderConnectionState(this.props.errorUrl, this.props.websocketClosed)} +
+ {showStats && this.renderTopologyStats(this.props.topology.stats)} + {!showStats && this.renderConnectionState(this.props.errorUrl, this.props.websocketClosed)}
); } diff --git a/client/app/scripts/components/topology-option-action.js b/client/app/scripts/components/topology-option-action.js new file mode 100644 index 0000000000..2101bc3078 --- /dev/null +++ b/client/app/scripts/components/topology-option-action.js @@ -0,0 +1,22 @@ +const React = require('react'); + +const AppActions = require('../actions/app-actions'); + +const TopologyOptionAction = React.createClass({ + + onClick: function(ev) { + ev.preventDefault(); + AppActions.changeTopologyOption(this.props.option, this.props.value); + }, + + render: function() { + return ( + + {this.props.value} + + ); + } + +}); + +module.exports = TopologyOptionAction; diff --git a/client/app/scripts/components/topology-options.js b/client/app/scripts/components/topology-options.js index 38855a4863..435ad62a78 100644 --- a/client/app/scripts/components/topology-options.js +++ b/client/app/scripts/components/topology-options.js @@ -1,40 +1,35 @@ const React = require('react'); const _ = require('lodash'); -const mui = require('material-ui'); -const DropDownMenu = mui.DropDownMenu; -const AppActions = require('../actions/app-actions'); +const TopologyOptionAction = require('./topology-option-action'); const TopologyOptions = React.createClass({ - componentDidMount: function() { - this.fixWidth(); - }, - - onChange: function(ev, index, item) { - ev.preventDefault(); - AppActions.changeTopologyOption(item.option, item.payload); + renderAction: function(action, option) { + return ( + + ); }, renderOption: function(items) { - let selected = 0; - let key; + let activeText; + const actions = []; const activeOptions = this.props.activeOptions; - const menuItems = items.map(function(item, index) { + items.forEach(function(item) { if (activeOptions[item.option] && activeOptions[item.option] === item.value) { - selected = index; + activeText = item.display; + } else { + actions.push(this.renderAction(item.value, item.option)); } - key = item.option; - return { - option: item.option, - payload: item.value, - text: item.display - }; - }); + }, this); return ( - +
+ {activeText} + + {actions} + +
); }, @@ -51,27 +46,14 @@ const TopologyOptions = React.createClass({ ); return ( -
+
{options.map(function(items) { return this.renderOption(items); }, this)}
); - }, - - componentDidUpdate: function() { - this.fixWidth(); - }, - - fixWidth: function() { - const containerNode = this.refs.container.getDOMNode(); - _.each(containerNode.childNodes, function(child) { - // set drop down width to length of current label - const label = child.getElementsByClassName('mui-menu-label')[0]; - const width = label.getBoundingClientRect().width + 40; - child.style.width = width + 'px'; - }); } + }); module.exports = TopologyOptions; diff --git a/client/app/styles/main.less b/client/app/styles/main.less index 1eb64c63d2..0f9627922d 100644 --- a/client/app/styles/main.less +++ b/client/app/styles/main.less @@ -1,6 +1,3 @@ -@import "~material-ui/src/less/scaffolding.less"; -@import "~material-ui/src/less/components.less"; - @font-face { font-family: "Roboto"; src: url("../../node_modules/materialize-css/font/roboto/Roboto-Regular.woff2"), @@ -8,7 +5,6 @@ url("../../node_modules/materialize-css/font/roboto/Roboto-Regular.ttf"); } - .browsehappy { margin: 0.2em 0; background: #ccc; @@ -32,12 +28,6 @@ @text-darker-color: @primary-color; @white: @background-secondary-color; -html, body { -} - -.wrap { -} - /* add this class to truncate text with ellipsis, container needs width */ .truncate { white-space: nowrap; @@ -50,6 +40,25 @@ body { background: linear-gradient(30deg, @background-color 0%, @background-secondary-color 100%); color: @text-color; line-height: 150%; + font-family: Roboto, Helvetica, Arial, sans-serif; + font-size: 13px; +} + +p { + line-height: 20px; + padding-top: 6px; + margin-bottom: 14px; + letter-spacing: 0; + font-weight: 400; + color: @text-color; +} + +h2 { + font-size: 34px; + line-height: 40px; + padding-top: 8px; + margin-bottom: 12px; + font-weight: 400; } #app { @@ -135,10 +144,6 @@ body { } .status { - float: right; - margin-top: 14px; - margin-right: 64px; - &-icon { font-size: 16px; position: relative; @@ -269,26 +274,6 @@ body { } } -.mui-paper, .mui-paper-container { - height: 100%; -} - -.mui-drop-down-menu { - .mui-menu-control { - .mui-menu-label { - font-size: 12px; - } - - .mui-menu-control-underline { - border-top: none; - } - - .mui-menu-control-bg { - background-color: transparent; - } - } -} - .node-details { height: 100%; width: 100%; @@ -300,7 +285,7 @@ body { &-label { color: white; - margin-bottom: 0; + margin: 0; width: 348px; &-minor { @@ -372,3 +357,32 @@ body { } +.sidebar { + position: fixed; + bottom: 16px; + left: 24px; + width: 16em; + font-size: 85%; + + &-item { + background-color: darken(@background-color, 8%); + border-radius: 2px; + padding: 4px 8px; + width: 100%; + margin-top: 2px; + + &.status { + background-color: darken(@background-color, 4%); + color: @text-secondary-color; + } + + &-action { + float: right; + text-transform: uppercase; + font-weight: bold; + color: darken(@weave-orange, 15%); + cursor: pointer; + } + } +} + diff --git a/client/package.json b/client/package.json index c14726dc49..383cd5b0c9 100644 --- a/client/package.json +++ b/client/package.json @@ -15,7 +15,7 @@ "immutable": "^3.7.4", "keymirror": "^0.1.1", "lodash": "~3.9.3", - "material-ui": "~0.7.5", + "material-ui": "^0.11.0", "materialize-css": "^0.96.1", "object-assign": "^2.0.0", "page": "^1.6.3",