From a7867fd78688ba1dd75fd2569d9a17633afd8eb5 Mon Sep 17 00:00:00 2001 From: surunzi Date: Sat, 30 Sep 2017 19:49:24 +0800 Subject: [PATCH] Dev: Logger item style --- .gitignore | 1 + src/Console/Logger.scss | 8 ++++++++ src/DevTools/DevTools.es6 | 5 +++-- test/boot.js | 4 +++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 8979157..9df817e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /.idea/ /node_modules/ /test/lib/ +/test/playground.html eruda* /script/icomoon/ \ No newline at end of file diff --git a/src/Console/Logger.scss b/src/Console/Logger.scss index fee1194..f16c5d2 100644 --- a/src/Console/Logger.scss +++ b/src/Console/Logger.scss @@ -6,6 +6,7 @@ @include overflow-auto(y); height: 100%; font-size: $font-size; + padding-top: 1px; .header { @include overflow-auto(x); white-space: nowrap; @@ -15,10 +16,13 @@ color: $gray; } .log-item { + position: relative; @include clear-float(); background: #fff; padding: $padding; border-bottom: 1px solid $gray-light; + border-top: 1px solid $gray-light; + margin-top: -1px; a { color: $blue !important; } @@ -86,6 +90,7 @@ } } &.error { + z-index: 50; background: $red-light; color: $red; border-top: 1px solid $red; @@ -100,14 +105,17 @@ } } &.debug { + z-index: 20; color: $blue; } &.warn { + z-index: 40; background: #fffbe6; border-top: 1px solid $yellow; border-bottom: 1px solid $yellow; } &.info { + z-index: 30; color: $blue; } &.output { diff --git a/src/DevTools/DevTools.es6 b/src/DevTools/DevTools.es6 index ffcb393..82bf1af 100644 --- a/src/DevTools/DevTools.es6 +++ b/src/DevTools/DevTools.es6 @@ -1,5 +1,6 @@ import NavBar from './NavBar.es6' import util from '../lib/util' +import logger from '../lib/logger.es6' import Tool from './Tool.es6' export default class DevTools extends util.Emitter @@ -54,9 +55,9 @@ export default class DevTools extends util.Emitter util.defaults(tool, {init, show, hide}); let name = tool.name; - if (!name) throw new Error('You must specify a name for a tool'); + if (!name) return logger.error('You must specify a name for a tool'); name = name.toLowerCase(); - if (this._tools[name]) throw new Error('Tool ' + name + ' already exists' ); + if (this._tools[name]) return logger.error('Tool ' + name + ' already exists' ); this._$tools.prepend(`
`); tool.init(this._$tools.find(`.eruda-${name}`), this); diff --git a/test/boot.js b/test/boot.js index 3caeea9..5de3aea 100644 --- a/test/boot.js +++ b/test/boot.js @@ -1,4 +1,4 @@ -function boot(name) +function boot(name, cb) { // Need a little delay to make sure width and height of webpack dev server iframe are initialized. setTimeout(function () @@ -8,6 +8,8 @@ function boot(name) }); eruda.show().get().config.set('displaySize', '50%'); + cb && cb(); + if (name == null) return; loadJs('lib/boot', function ()