1
0
mirror of synced 2025-12-17 04:43:23 +08:00

Add: Css color display

This commit is contained in:
surunzi
2016-05-21 21:36:35 +08:00
parent d2be932905
commit ff67f95739
3 changed files with 23 additions and 3 deletions

View File

@@ -208,10 +208,12 @@ export default class Elements extends Tool
var computedStyle = cssStore.getComputedStyle(); var computedStyle = cssStore.getComputedStyle();
if (this._rmDefComputedStyle) computedStyle = rmDefComputedStyle(computedStyle); if (this._rmDefComputedStyle) computedStyle = rmDefComputedStyle(computedStyle);
processStyleRules(computedStyle);
ret.computedStyle = computedStyle; ret.computedStyle = computedStyle;
var styles = cssStore.getMatchedCSSRules(); var styles = cssStore.getMatchedCSSRules();
styles.unshift(getInlineStyle(el.style)); styles.unshift(getInlineStyle(el.style));
styles.forEach(style => processStyleRules(style.style));
ret.styles = styles; ret.styles = styles;
return ret; return ret;
@@ -252,7 +254,18 @@ export default class Elements extends Tool
} }
} }
var isElExist = val => util.isEl(val) && val.parentNode; function processStyleRules(style)
{
util.each(style, (val, key) =>
{
if (util.startWith(val, 'rgb'))
{
style[key] = `<span class="eruda-style-color" style="background-color: ${val}"></span>${val}`;
}
});
}
const isElExist = val => util.isEl(val) && val.parentNode;
function formatElName(data) function formatElName(data)
{ {

View File

@@ -38,7 +38,7 @@
{{#each computedStyle}} {{#each computedStyle}}
<tr> <tr>
<td class="eruda-key">{{@key}}</td> <td class="eruda-key">{{@key}}</td>
<td>{{this}}</td> <td>{{{.}}}</td>
</tr> </tr>
{{/each}} {{/each}}
</tbody> </tbody>
@@ -55,7 +55,7 @@
<div>{{selectorText}} {</div> <div>{{selectorText}} {</div>
{{#each style}} {{#each style}}
<div class="eruda-rule"> <div class="eruda-rule">
<span>{{@key}}</span>: {{this}}; <span>{{@key}}</span>: {{{.}}};
</div> </div>
{{/each}} {{/each}}
<div>}</div> <div>}</div>

View File

@@ -58,6 +58,13 @@
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
} }
} }
.style-color {
width: 7px;
height: 7px;
margin-right: 2px;
border: 1px solid $gray-dark;
display: inline-block;
}
.computed-style { .computed-style {
background: #fff; background: #fff;
font-size: 12px; font-size: 12px;