Skip to content

Commit

Permalink
REFACTOR (2) change layout of app container
Browse files Browse the repository at this point in the history
  • Loading branch information
serapath committed Jul 18, 2017
1 parent 2f6b70a commit 0bce0b9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 30 deletions.
15 changes: 0 additions & 15 deletions assets/css/browser-solidity.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@ body {
font-weight: normal;
}

#editor {
position: absolute;
top: 0;
left: 0;
width: auto;
bottom: 0;
right: 37em;
}

.scroller {
position: absolute;
z-index: 999;
Expand Down Expand Up @@ -428,12 +419,6 @@ body {
border-right: 2px solid hsla(215, 81%, 79%, .3);
}

#editor .ace-tm .ace_gutter,
#editor .ace-tm .ace_gutter-active-line,
#editor .ace-tm .ace_marker-layer .ace_active-line {
background-color: rgba(225, 229, 251, 0.5);
}

input[readonly] {
display: block;
width: 100%;
Expand Down
22 changes: 17 additions & 5 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ var RighthandPanel = require('./app/righthand-panel')
var examples = require('./app/example-contracts')

var css = csjs`
.browsersolidity {
position : absolute;
top : 0;
left : 0;
width : auto;
bottom : 0;
right : 37em;
}
.editor-container {
display : flex;
position : absolute;
Expand Down Expand Up @@ -58,8 +66,8 @@ class App {
var self = this
if (self._view.el) return self._view.el
/***************************************************************************/
var el = yo`
<div id="editor">
self._view.el = yo`
<div class=${css.browsersolidity}>
<div id="tabs-bar">
<div class="scroller scroller-left"><i class="fa fa-chevron-left "></i></div>
<div class="scroller scroller-right"><i class="fa fa-chevron-right "></i></div>
Expand All @@ -73,7 +81,7 @@ class App {
<div id="dragbar"></div>
</div>
`
return el
return self._view.el
}
}

Expand Down Expand Up @@ -662,7 +670,11 @@ function run () {
// ---------------- Righthand-panel --------------------
var rhpAPI = {
config: config,
onResize: onResize,
setEditorSize (delta) {
$('#righthand-panel').css('width', delta)
self._view.el.style.right = delta + 'px'
onResize()
},
reAdjust: reAdjust,
warnCompilerLoading: (msg) => {
renderer.clear()
Expand Down Expand Up @@ -692,7 +704,7 @@ function run () {
window.onresize = onResize
onResize()

document.querySelector('#editor').addEventListener('change', onResize)
self._view.el.addEventListener('change', onResize)
document.querySelector('#editorWrap').addEventListener('change', onResize)

// ----------------- compiler ----------------------
Expand Down
11 changes: 10 additions & 1 deletion src/app/editor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

var EventManager = require('ethereum-remix').lib.EventManager

var yo = require('yo-yo')
var csjs = require('csjs-inject')
var ace = require('brace')
var Range = ace.acequire('ace/range').Range
Expand All @@ -14,6 +14,15 @@ var css = csjs`
width : 100%;
}
`
document.head.appendChild(yo`
<style>
.ace-tm .ace_gutter,
.ace-tm .ace_gutter-active-line,
.ace-tm .ace_marker-layer .ace_active-line {
background-color: rgba(225, 229, 251, 0.5);
}
</style>
`)

function Editor (editorElement) {
var editor = ace.edit(editorElement)
Expand Down
14 changes: 5 additions & 9 deletions src/app/righthand-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ var css = csjs`
module.exports = RighthandPanel

function RighthandPanel (container, appAPI, events, opts) {
var self = this
self._api = appAPI
var optionViews = yo`<div id="optionViews" class="settingsView"></div>`
var element = yo`
<div id="righthand-panel">
Expand Down Expand Up @@ -61,7 +63,7 @@ function RighthandPanel (container, appAPI, events, opts) {
var hidingRHP = false
$('.toggleRHP').click(function () {
hidingRHP = !hidingRHP
setEditorSize(hidingRHP ? 0 : appAPI.config.get(EDITOR_WINDOW_SIZE))
self._api.setEditorSize(hidingRHP ? 0 : appAPI.config.get(EDITOR_WINDOW_SIZE))
$('.toggleRHP i').toggleClass('fa-angle-double-right', !hidingRHP)
$('.toggleRHP i').toggleClass('fa-angle-double-left', hidingRHP)
})
Expand Down Expand Up @@ -98,12 +100,6 @@ function RighthandPanel (container, appAPI, events, opts) {

var $body = $('body')

function setEditorSize (delta) {
$('#righthand-panel').css('width', delta)
$('#editor').css('right', delta)
appAPI.onResize()
}

function getEditorSize () {
return $('#righthand-panel').width()
}
Expand All @@ -115,14 +111,14 @@ function RighthandPanel (container, appAPI, events, opts) {
$(document).unbind('mousemove')
dragging = false
delta = (delta < 50) ? 50 : delta
setEditorSize(delta)
self._api.setEditorSize(delta)
appAPI.config.set(EDITOR_WINDOW_SIZE, delta)
appAPI.reAdjust()
}
})

if (appAPI.config.exists(EDITOR_WINDOW_SIZE)) {
setEditorSize(appAPI.config.get(EDITOR_WINDOW_SIZE))
self._api.setEditorSize(appAPI.config.get(EDITOR_WINDOW_SIZE))
} else {
appAPI.config.set(EDITOR_WINDOW_SIZE, getEditorSize())
}
Expand Down

0 comments on commit 0bce0b9

Please sign in to comment.