Skip to content

Commit

Permalink
chore: update luna-box-model
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Sep 6, 2024
1 parent 8c05dba commit 588dba7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^5.0.0",
"licia": "^1.41.0",
"luna-box-model": "^0.1.0",
"luna-box-model": "^1.0.0",
"luna-console": "^1.3.4",
"luna-data-grid": "^0.6.0",
"luna-dom-viewer": "^1.3.0",
Expand Down
48 changes: 35 additions & 13 deletions src/Elements/Detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import isBool from 'licia/isBool'
import safeGet from 'licia/safeGet'
import $ from 'licia/$'
import h from 'licia/h'
import extend from 'licia/extend'
import MutationObserver from 'licia/MutationObserver'
import CssStore from './CssStore'
import Settings from '../Settings/Settings'
Expand All @@ -31,29 +32,18 @@ export default class Detail {
this._$container = $container
this._devtools = devtools
this._curEl = document.documentElement
this._bindEvent()
this._initObserver()
this._initCfg()
this._initTpl()
this._bindEvent()
}
show(el) {
this._curEl = el
this._rmDefComputedStyle = true
this._computedStyleSearchKeyword = ''
this._enableObserver()
this._render()

const { nodeId } = chobitsu.domain('DOM').getNodeId({ node: el })
chobitsu.domain('Overlay').highlightNode({
nodeId,
highlightConfig: {
showInfo: true,
contentColor: 'rgba(111, 168, 220, .66)',
paddingColor: 'rgba(147, 196, 125, .55)',
borderColor: 'rgba(255, 229, 153, .66)',
marginColor: 'rgba(246, 178, 107, .66)',
},
})
this._highlight()
}
hide = () => {
this._$container.hide()
Expand Down Expand Up @@ -87,6 +77,36 @@ export default class Detail {
if (this._origAddEvent) winEventProto.addEventListener = this._origAddEvent
if (this._origRmEvent) winEventProto.removeEventListener = this._origRmEvent
}
_highlight = (type) => {
const el = this._curEl

const highlightConfig = {
showInfo: false,
}
if (!type || type === 'all') {
extend(highlightConfig, {
showInfo: true,
contentColor: 'rgba(111, 168, 220, .66)',
paddingColor: 'rgba(147, 196, 125, .55)',
borderColor: 'rgba(255, 229, 153, .66)',
marginColor: 'rgba(246, 178, 107, .66)',
})
} else if (type === 'margin') {
highlightConfig.marginColor = 'rgba(246, 178, 107, .66)'
} else if (type === 'border') {
highlightConfig.borderColor = 'rgba(255, 229, 153, .66)'
} else if (type === 'padding') {
highlightConfig.paddingColor = 'rgba(147, 196, 125, .55)'
} else if (type === 'content') {
highlightConfig.contentColor = 'rgba(111, 168, 220, .66)'
}

const { nodeId } = chobitsu.domain('DOM').getNodeId({ node: el })
chobitsu.domain('Overlay').highlightNode({
nodeId,
highlightConfig,
})
}
_initTpl() {
const $container = this._$container

Expand Down Expand Up @@ -321,6 +341,8 @@ export default class Detail {
this._render()
devtools.notify('Refreshed', { icon: 'success' })
})

this._boxModel.on('highlight', this._highlight)
}
_initObserver() {
this._observer = new MutationObserver((mutations) => {
Expand Down
2 changes: 1 addition & 1 deletion src/Snippets/defSnippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,5 +232,5 @@ const pluginVersion = {
geolocation: '2.1.0',
orientation: '2.1.1',
touches: '2.1.0',
vue: '1.1.0',
vue: '1.1.1',
}
9 changes: 7 additions & 2 deletions src/style/luna.scss
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,14 @@
}

.luna-box-model {
background: transparent;
background: var(--background);
}

.luna-box-model-position {
.luna-box-model-position,
.luna-box-model-margin,
.luna-box-model-border,
.luna-box-model-padding,
.luna-box-model-content {
color: var(--foreground);
background: var(--background);
}

0 comments on commit 588dba7

Please sign in to comment.