Refactoring Debugger - applying style-guide

pull/7/head
ninabreznik 7 years ago committed by yann300
parent 8886d995ec
commit c730d865b5
  1. 13
      src/ui/BasicPanel.js
  2. 45
      src/ui/DropdownPanel.js
  3. 5
      src/ui/TxBrowser.js

@ -3,6 +3,16 @@ var style = require('./styles/basicStyles')
var yo = require('yo-yo') var yo = require('yo-yo')
var ui = require('../helpers/ui') var ui = require('../helpers/ui')
var csjs = require('csjs-inject')
var styleGuide = require('./styles/style-guide')
var styles = styleGuide()
var css = csjs`
.container {
width: 70%;
}
`
function BasicPanel (_name, _width, _height) { function BasicPanel (_name, _width, _height) {
this.data this.data
this.name = _name this.name = _name
@ -24,7 +34,8 @@ BasicPanel.prototype.show = function () {
} }
BasicPanel.prototype.render = function () { BasicPanel.prototype.render = function () {
var view = yo`<div id='container' style=${ui.formatCss({'width': this.width}, style.panel.container)}> var view = yo`
<div css=${css.container} id='container' style=${ui.formatCss({'width': this.width})}>
<div style=${ui.formatCss(style.panel.title)}> <div style=${ui.formatCss(style.panel.title)}>
${this.name} ${this.name}
</div> </div>

@ -6,6 +6,35 @@ var basicStyles = require('./styles/basicStyles')
var TreeView = require('./TreeView') var TreeView = require('./TreeView')
var EventManager = require('../lib/eventManager') var EventManager = require('../lib/eventManager')
var csjs = require('csjs-inject')
var styleGuide = require('./styles/style-guide')
var styles = styleGuide()
var css = csjs`
.title {
margin-top: 10px;
${styles.dropdown}
display: flex;
align-items: center;
}
.name {
color: ${styles.colors.black};
font-weight: bold;
}
.icon {
color: ${styles.colors.black};
margin-right: 5%;
}
.eyeButton {
${styles.button}
margin: 3px;
float: right;
}
.eyeButton:hover {
color: ${styles.colors.orange};
}
`
function DropdownPanel (_name, _opts) { function DropdownPanel (_name, _opts) {
this.event = new EventManager() this.event = new EventManager()
if (!_opts) { if (!_opts) {
@ -79,12 +108,12 @@ DropdownPanel.prototype.render = function (overridestyle) {
to {transform:rotate(359deg);} to {transform:rotate(359deg);}
} }
</style> </style>
<div class='title' style=${ui.formatCss(styleDropdown.title)} onclick=${function () { self.toggle() }}> <div class='${css.title} title' onclick=${function () { self.toggle() }}>
<div style=${ui.formatCss(styleDropdown.caret)} class='fa fa-caret-right'></div> <div class='${css.icon} fa fa-caret-right'></div>
<div style=${ui.formatCss(styleDropdown.inner, styleDropdown.titleInner)}>${this.name}</div><span></span> <div class=${css.name}>${this.name}</div><span></span>
</div> </div>
<div class='dropdownpanel' style=${ui.formatCss(styleDropdown.content)} style='display:none'> <div class='dropdownpanel' style=${ui.formatCss(styleDropdown.content)} style='display:none'>
<button onclick=${function () { self.toggleRaw() }} style=${ui.formatCss(basicStyles.button, styleDropdown.copyBtn)} title='raw' class="btn fa fa-eye" type="button"> <button onclick=${function () { self.toggleRaw() }} title='raw' class="${css.eyeButton} btn fa fa-eye" type="button">
</button> </button>
<i class="fa fa-refresh" style=${ui.formatCss(styleDropdown.inner, overridestyle, {display: 'none', 'margin-left': '4px', 'margin-top': '4px', 'animation': 'spin 2s linear infinite'})} aria-hidden="true"></i> <i class="fa fa-refresh" style=${ui.formatCss(styleDropdown.inner, overridestyle, {display: 'none', 'margin-left': '4px', 'margin-top': '4px', 'animation': 'spin 2s linear infinite'})} aria-hidden="true"></i>
<div style=${ui.formatCss(styleDropdown.inner, overridestyle)} class='dropdowncontent'>${content}</div> <div style=${ui.formatCss(styleDropdown.inner, overridestyle)} class='dropdowncontent'>${content}</div>
@ -110,11 +139,11 @@ DropdownPanel.prototype.toggle = function () {
var caret = this.view.querySelector('.title').firstElementChild var caret = this.view.querySelector('.title').firstElementChild
if (el.style.display === '') { if (el.style.display === '') {
el.style.display = 'none' el.style.display = 'none'
caret.className = 'fa fa-caret-right' caret.className = `${css.icon} fa fa-caret-right`
this.event.trigger('hide', []) this.event.trigger('hide', [])
} else { } else {
el.style.display = '' el.style.display = ''
caret.className = 'fa fa-caret-down' caret.className = `${css.icon} fa fa-caret-down`
this.event.trigger('show', []) this.event.trigger('show', [])
} }
} }
@ -124,7 +153,7 @@ DropdownPanel.prototype.hide = function () {
var caret = this.view.querySelector('.title').firstElementChild var caret = this.view.querySelector('.title').firstElementChild
var el = this.view.querySelector('.dropdownpanel') var el = this.view.querySelector('.dropdownpanel')
el.style.display = 'none' el.style.display = 'none'
caret.className = 'fa fa-caret-right' caret.className = `${css.icon} fa fa-caret-right`
this.event.trigger('hide', []) this.event.trigger('hide', [])
} }
} }
@ -134,7 +163,7 @@ DropdownPanel.prototype.show = function () {
var caret = this.view.querySelector('.title').firstElementChild var caret = this.view.querySelector('.title').firstElementChild
var el = this.view.querySelector('.dropdownpanel') var el = this.view.querySelector('.dropdownpanel')
el.style.display = '' el.style.display = ''
caret.className = 'fa fa-caret-down' caret.className = `${css.icon} fa fa-caret-down`
this.event.trigger('show', []) this.event.trigger('show', [])
} }
} }

@ -41,6 +41,9 @@ var css = csjs`
.txbutton:hover { .txbutton:hover {
color: ${styles.colors.orange}; color: ${styles.colors.orange};
} }
.txinfo {
margin-top: 5px;
}
` `
function TxBrowser (_parent) { function TxBrowser (_parent) {
this.event = new EventManager() this.event = new EventManager()
@ -193,7 +196,7 @@ TxBrowser.prototype.render = function () {
</div> </div>
</div> </div>
<span id='error'></span> <span id='error'></span>
<div style=${ui.formatCss(style.transactionInfo)} id='txinfo'> <div style=${css.txinfo} id='txinfo'>
${this.basicPanel.render()} ${this.basicPanel.render()}
</div> </div>
</div>` </div>`

Loading…
Cancel
Save