Skip to content
This repository was archived by the owner on Oct 10, 2023. It is now read-only.

Commit d469147

Browse files
committed
Changed layout to fit screen, introduced scss styles.
1 parent 750fc90 commit d469147

8 files changed

+95
-38
lines changed

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
"babel-preset-react": "^6.16.0",
1818
"babel-preset-stage-0": "^6.16.0",
1919
"css-loader": "0.23.1",
20+
"sass-loader": "4.0.2",
21+
"style-loader": "0.13.1",
22+
"node-sass": "3.10.1",
2023
"exports-loader": "0.6.3",
2124
"expose-loader": "0.7.1",
2225
"file-loader": "0.8.5",
2326
"html-webpack-plugin": "2.22.0",
2427
"imports-loader": "0.6.5",
2528
"json-loader": "0.5.4",
26-
"style-loader": "0.13.1",
2729
"url-loader": "0.5.7",
2830
"webpack": "1.13.2",
2931
"webpack-dev-server": "1.14.1"

src/GraphViz.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ export default class GraphViz extends React.PureComponent {
286286

287287
render() {
288288
return (
289-
<div>
290-
<div id="graph" style={{width: '100%', height: '700px'}} ref={(element) => this.registerSigmaElement(element)}/>
289+
<div className="graph-view">
290+
<div id="graph" className='graph-container' ref={(element) => this.registerSigmaElement(element)}/>
291291
{this.renderSizeMenu()}
292292
{this.renderFilterPanel()}
293293
{/* <div id="nodeSizePanel" style={{position: 'absolute', right: '10px', bottom: 0, width: '260px', height: '170px'}} className="card">

src/GraphWorkspace.jsx

+8-12
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,12 @@ export default class GraphWorkspace extends React.PureComponent {
2020
render() {
2121
return (
2222
(this.props.graph && this.props.graph.nodes.length) > 0 ?
23-
<div className="row">
24-
<div className="col-md-3 col-space">
25-
{this.selectedBlock()}
26-
</div>
27-
<div className="col-md-9 col-space">
28-
{this.graphBlock()}
29-
</div>
23+
<div className="row graph-workspace">
24+
{this.selectedBlock()}
25+
{this.graphBlock()}
3026
</div>
3127
:
32-
<div className="row" >
28+
<div className="row graph-workspace" >
3329
<div className="col-md-12">No data to visualize</div>
3430
</div>
3531
);
@@ -38,17 +34,17 @@ export default class GraphWorkspace extends React.PureComponent {
3834

3935

4036
selectedBlock = () => {
41-
return <div className="card">
42-
<div className="card-block">
37+
return <div className="card selected-nodes-panel">
38+
<div className="card-block selected-nodes-block">
4339
<h4 className="card-title">Selected Nodes</h4>
4440
<SelectedTable selectedNodes={this.state.selectedNodes} onRemoved={this.onTableRemoved}/>
4541
</div>
4642
</div>;
4743
};
4844

4945
graphBlock = () => {
50-
return <div className="card">
51-
<div className="card-block">
46+
return <div className="card graph-panel">
47+
<div className="card-block graph-block">
5248
<h4 className="card-title">Graph visualization</h4>
5349
<GraphViz graph={this.props.graph} selectedNodes={this.state.selectedNodes}
5450
onSelectionAdd={this.onSelectionAdd} onSelectionRemove={this.onSelectionRemove}/>

src/ScenarioSelector.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react'
22
import GraphWorkspace from './GraphWorkspace'
3+
require('./styles.scss')
34

45
export default class ScenarioSelector extends React.Component {
56

@@ -13,8 +14,8 @@ export default class ScenarioSelector extends React.Component {
1314

1415
render() {
1516
return (
16-
<div className="container-fluid">
17-
<div className="row">
17+
<div className="container-fluid demo-root">
18+
<div className="row scenario-selection">
1819
<div className="card col-md-12">
1920
<div className="card-block">
2021
<h4 className="card-title">Scenario Selection</h4>

src/SelectedTable.jsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React from 'react'
22
import * as fileSaver from 'file-saver'
3-
3+
require('./styles.scss')
44
export default class SelectedTable extends React.Component {
55
propTypes: {
66
selectedNodes: React.PropTypes.array.isRequired
77
};
88
render() {
99
return (
10-
<div>
10+
<div className="flex-column">
1111
<div className="text-muted">Count: {this.props.selectedNodes.length} nodes</div>
12-
<div style={{height: 635, overflowY: 'auto'}}>
12+
<div style={{overflowY: 'auto'}}>
1313
<table className="table table-sm small">
1414
<tbody>
1515
<tr><th>id</th><th>value</th><th>parent</th><th>link</th><th>&nbsp;</th>{/*<th>frq</th><th>sc</th><th>sprd</th>*/}</tr>
@@ -28,7 +28,7 @@ export default class SelectedTable extends React.Component {
2828
</tbody>
2929
</table>
3030
</div>
31-
<button type="button" className="btn btn-primary" onClick={() => console.log(this.exportCsv())}>Export CSV</button>
31+
<button type="button" className="btn btn-primary export-css" onClick={() => console.log(this.exportCsv())} disabled={this.props.selectedNodes.length == 0}>Export CSV</button>
3232
</div>
3333
);
3434
}

src/examples/template.ejs

+2-16
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,13 @@
55
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
66
<title><%= htmlWebpackPlugin.options.title %></title>
77
</head>
8-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css"
9-
integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi" crossorigin="anonymous">
8+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.5/css/bootstrap-flex.css"
9+
crossorigin="anonymous">
1010
<style>
1111
html, body, #root {
1212
height: 100%;
1313
overflow: hidden;
1414
}
15-
16-
.form-inline .form-group {
17-
margin-right: 10px;
18-
}
19-
20-
.table-sm td, .table-sm th {
21-
padding: .2rem;
22-
}
23-
24-
.form-inline label,
25-
.form-inline .form-control {
26-
margin-right: 5px;
27-
}
28-
2915
</style>
3016
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
3117
<body>

src/styles.scss

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
.form-inline .form-group {
2+
margin-right: 10px;
3+
}
4+
5+
.table-sm td, .table-sm th {
6+
padding: .2rem;
7+
}
8+
9+
.form-inline label,
10+
.form-inline .form-control {
11+
margin-right: 5px;
12+
}
13+
14+
.demo-root {
15+
display: flex;
16+
flex-direction: column;
17+
height: 100%;
18+
}
19+
20+
.scenario-selection {
21+
flex: 0 0 auto;
22+
}
23+
24+
.graph-workspace {
25+
flex: 1 1 100%;
26+
display: flex;
27+
flex-wrap: nowrap;
28+
}
29+
30+
.selected-nodes-panel {
31+
flex: 0 0 400px;
32+
margin-right: 20px;
33+
width: 400px;
34+
display: flex;
35+
flex-direction: column;
36+
}
37+
38+
.selected-nodes-block {
39+
flex: 1 1 100%;
40+
display: flex;
41+
flex-direction: column;
42+
}
43+
44+
.flex-column {
45+
display: flex;
46+
flex-direction: column;
47+
}
48+
49+
.export-css {
50+
flex: 0 0 auto;
51+
margin: 20px 0 0;
52+
}
53+
54+
.graph-panel {
55+
flex: 1 1 100%;
56+
display: flex;
57+
}
58+
59+
.graph-block {
60+
flex: 1 1 100%;
61+
display: flex;
62+
flex-direction: column;
63+
}
64+
65+
.graph-view {
66+
display: flex;
67+
flex: 1 1 100%;
68+
}
69+
70+
.graph-container {
71+
width: 100%;
72+
}

webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = {
2323
{test: /\.gif$/, loader: 'url-loader?mimetype=image/gif'},
2424
{test: /\.png$/, loader: 'url-loader?mimetype=image/png'},
2525
{
26-
test: /\.js$/,
26+
test: /\.js.?$/,
2727
exclude: /(node_modules)/,
2828
loader: 'babel-loader',
2929
query: {

0 commit comments

Comments
 (0)