From 5e23ffaec75ff922dfed6ecfc3fdb09313cb3345 Mon Sep 17 00:00:00 2001 From: redhoodsu Date: Fri, 12 Jul 2024 16:32:26 +0800 Subject: [PATCH] feat: inline mode --- eruda.d.ts | 4 ++++ src/eruda.js | 14 ++++++++++++-- src/style/style.scss | 6 ++++++ test/index.html | 3 +++ test/inline.html | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 test/inline.html diff --git a/eruda.d.ts b/eruda.d.ts index f32ec7dae..b63517521 100644 --- a/eruda.d.ts +++ b/eruda.d.ts @@ -35,6 +35,10 @@ declare module 'eruda' { * Use shadow dom for css encapsulation */ useShadowDom?: boolean + /** + * Enable inline mode + */ + inline?: boolean /** * Default settings */ diff --git a/src/eruda.js b/src/eruda.js index a2dadf119..a02a974c6 100644 --- a/src/eruda.js +++ b/src/eruda.js @@ -36,9 +36,12 @@ export default { tool, autoScale = true, useShadowDom = true, + inline = false, defaults = {}, } = {}) { - if (this._isInit) return + if (this._isInit) { + return + } this._isInit = true this._scale = 1 @@ -51,7 +54,14 @@ export default { this._initTools(tool) this._registerListener() - if (autoScale) this._autoScale() + if (autoScale) { + this._autoScale() + } + if (inline) { + this._entryBtn.hide() + this._$el.addClass('eruda-inline') + this.show() + } }, _isInit: false, version: VERSION, diff --git a/src/style/style.scss b/src/style/style.scss index f37d3ebbb..6dc292781 100644 --- a/src/style/style.scss +++ b/src/style/style.scss @@ -43,6 +43,12 @@ font-weight: normal; } } + &.inline { + position: static; + .dev-tools { + height: 100% !important; + } + } } .hidden { diff --git a/test/index.html b/test/index.html index d68357b18..a65625b92 100644 --- a/test/index.html +++ b/test/index.html @@ -44,6 +44,9 @@
  • manual
  • +
  • + inline +
  • + + + + + +