Skip to content

Commit

Permalink
Add basic layout
Browse files Browse the repository at this point in the history
  • Loading branch information
adonis0147 committed Mar 3, 2017
1 parent c8a5174 commit c8db564
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
tags
8 changes: 7 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css" type="text/css" media="screen" charset="utf-8">
<link rel="stylesheet" href="./static/css/view.css" type="text/css" media="screen" charset="utf-8">
<title>Profile Viewer</title>
</head>
<body>
<h1>Hello, world!</h1>
<div id="sidebar"></div>
<div id="content">
<svg id="blackboard"></svg>
</div>
</body>
<script src="./script/view.js" charset="utf-8"></script>
</html>

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "profile-viewer",
"version": "0.1.0",
"description": "Profile viewer for behavior tree",
"main": "main.js",
"main": "./script/main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand All @@ -18,6 +18,7 @@
"homepage": "https://github.com/adonis0147/profile-viewer#readme",
"dependencies": {
"bootstrap": "^3.3.7",
"d3": "^4.7.1",
"jquery": "^3.1.1"
}
}
2 changes: 1 addition & 1 deletion main.js → script/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let win

function createWindow() {
win = new BrowserWindow({width: 800, height: 600})
win.loadURL(path.join('file://', __dirname, 'index.html'))
win.loadURL(path.join('file://', __dirname, '..', 'index.html'))
}

app.on('ready', createWindow)
Expand Down
28 changes: 28 additions & 0 deletions script/view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const d3 = require('d3')

var blackboard = d3.select('#blackboard')

init()

function init() {
initBlackboard()
registerEvent()
}

function initBlackboard() {
var min_width = blackboard.style('width')
var min_height = blackboard.style('height')

blackboard.style('min-width', min_width)
blackboard.style('min-height', min_height)
}

function registerEvent() {
d3.select(window).on('resize', () => {
console.log('Windows was resized to ' +
blackboard.style('width') +
' x ' +
blackboard.style('height'))
})
}

43 changes: 43 additions & 0 deletions static/css/view.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
* {
padding: 0;
margin: 0;
}

html {
display: flex;
flex-direction: column;
flex-grow: 1;
flex-shrink: 0;
height: 100%;
width: 100%;
}

body {
display: flex;
flex-direction: row;
flex-grow: 1;
flex-shrink: 0;
}

#sidebar {
background-color: #CCF;
padding: 10px;
width: 200px;
flex: none;
}

#content {
background-color: #CFC;
padding: 10px;
display: flex;
flex-direction: column;
flex-grow: 1;
}

svg {
border: 1px solid #0E0;
flex-grow: 1;
width: 100%;
height: 100%;
}

0 comments on commit c8db564

Please sign in to comment.