From 588dba7b749d028d11173742d4f3e43d0018ddae Mon Sep 17 00:00:00 2001 From: redhoodsu Date: Fri, 6 Sep 2024 19:38:32 +0800 Subject: [PATCH] chore: update luna-box-model --- package.json | 2 +- src/Elements/Detail.js | 48 +++++++++++++++++++++++++++---------- src/Snippets/defSnippets.js | 2 +- src/style/luna.scss | 9 +++++-- 4 files changed, 44 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 9fdf40efc..56b17e3a7 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/Elements/Detail.js b/src/Elements/Detail.js index 59c9f0e76..27982042b 100644 --- a/src/Elements/Detail.js +++ b/src/Elements/Detail.js @@ -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' @@ -31,10 +32,10 @@ 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 @@ -42,18 +43,7 @@ export default class Detail { 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() @@ -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 @@ -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) => { diff --git a/src/Snippets/defSnippets.js b/src/Snippets/defSnippets.js index 8e42c81fc..47aeedc3b 100644 --- a/src/Snippets/defSnippets.js +++ b/src/Snippets/defSnippets.js @@ -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', } diff --git a/src/style/luna.scss b/src/style/luna.scss index 0fd7f114a..f30a9deff 100644 --- a/src/style/luna.scss +++ b/src/style/luna.scss @@ -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); }