Skip to content

Commit

Permalink
feat: inline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Jul 12, 2024
1 parent 5e23ffa commit 0fb1f11
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
37 changes: 26 additions & 11 deletions src/DevTools/DevTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
} from '../lib/util'

export default class DevTools extends Emitter {
constructor($container, { defaults = {} } = {}) {
constructor($container, { defaults = {}, inline = false } = {}) {
super()

this._defCfg = extend(
Expand All @@ -52,6 +52,7 @@ export default class DevTools extends Emitter {
this._resizeTimer = null
this._resizeStartY = 0
this._resizeStartSize = 0
this._inline = inline

this._initTpl()
this._initTab()
Expand Down Expand Up @@ -201,16 +202,22 @@ export default class DevTools extends Emitter {
'System preference',
...keys(evalCss.getThemes()),
])
.range(cfg, 'transparency', 'Transparency', {
min: 0.2,
max: 1,
step: 0.01,
})
.range(cfg, 'displaySize', 'Display Size', {
min: 40,
max: 100,
step: 1,
})

if (!this._inline) {
settings
.range(cfg, 'transparency', 'Transparency', {
min: 0.2,
max: 1,
step: 0.01,
})
.range(cfg, 'displaySize', 'Display Size', {
min: 40,
max: 100,
step: 1,
})
}

settings
.button('Restore defaults and reload', function () {
const store = safeStorage('local')

Expand Down Expand Up @@ -270,6 +277,10 @@ export default class DevTools extends Emitter {
if (this._isShow) this._$el.css({ opacity })
}
_setDisplaySize(height) {
if (this._inline) {
height = 100
}

if (!isNum(height)) return

this._$el.css({ height: height + '%' })
Expand Down Expand Up @@ -323,6 +334,10 @@ export default class DevTools extends Emitter {
const $navBar = this._$el.find(c('.nav-bar'))
const $document = $(document)

if (this._inline) {
$resizer.hide()
}

const startListener = (e) => {
e.preventDefault()
e.stopPropagation()
Expand Down
5 changes: 3 additions & 2 deletions src/eruda.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default {

this._initContainer(container, useShadowDom)
this._initStyle()
this._initDevTools(defaults)
this._initDevTools(defaults, inline)
this._initEntryBtn()
this._initSettings()
this._initTools(tool)
Expand Down Expand Up @@ -239,9 +239,10 @@ export default {

this._$el = $(el)
},
_initDevTools(defaults) {
_initDevTools(defaults, inline) {
this._devTools = new DevTools(this._$el, {
defaults,
inline,
})
},
_initStyle() {
Expand Down
3 changes: 0 additions & 3 deletions src/style/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
}
&.inline {
position: static;
.dev-tools {
height: 100% !important;
}
}
}

Expand Down

0 comments on commit 0fb1f11

Please sign in to comment.