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 649bbb4 commit 5e23ffa
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 2 deletions.
4 changes: 4 additions & 0 deletions eruda.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ declare module 'eruda' {
* Use shadow dom for css encapsulation
*/
useShadowDom?: boolean
/**
* Enable inline mode
*/
inline?: boolean
/**
* Default settings
*/
Expand Down
14 changes: 12 additions & 2 deletions src/eruda.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/style/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
font-weight: normal;
}
}
&.inline {
position: static;
.dev-tools {
height: 100% !important;
}
}
}

.hidden {
Expand Down
3 changes: 3 additions & 0 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
<li>
<a href="manual.html">manual</a>
</li>
<li>
<a href="inline.html">inline</a>
</li>
</ul>
</nav>
<script>
Expand Down
37 changes: 37 additions & 0 deletions test/inline.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Inline</title>
<link rel="stylesheet" href="style.css" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/luna-window/luna-window.css"
/>
<script src="assets/eruda.js"></script>
<script src="https://cdn.jsdelivr.net/npm/luna-window/luna-window.js"></script>
</head>
<body>
<script>
const content = document.createElement('div')
const win = new LunaWindow({
title: 'Window Title',
x: 50,
y: 50,
width: window.innerWidth - 100,
height: window.innerHeight - 100,
content,
})
win.show()
win.$container
.parent()
.addClass('__chobitsu-hide__')
.css('z-index', '200000')
eruda.init({
container: content,
inline: true,
})
</script>
</body>
</html>

0 comments on commit 5e23ffa

Please sign in to comment.