Skip to content

Commit c1f5fbb

Browse files
authored
Simplify color HTML and CSS on SQL panel (django-commons#1333)
By using the CSS property "content", can remove the repetitive &django-commons#160; in the HTML. The single non-breaking space determines the size of the color bar. The total HTML and CSS is less for the same result.
1 parent 0101fbf commit c1f5fbb

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

debug_toolbar/static/debug_toolbar/css/toolbar.css

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -450,14 +450,8 @@
450450
min-width: 70px;
451451
white-space: nowrap;
452452
}
453-
#djDebug .djdt-panelContent table .djdt-color {
454-
width: 3px;
455-
}
456-
#djDebug .djdt-panelContent table .djdt-color span {
457-
width: 3px;
458-
height: 12px;
459-
overflow: hidden;
460-
padding: 0;
453+
#djDebug .djdt-color:after {
454+
content: "\00a0";
461455
}
462456
#djDebug .djToggleSwitch {
463457
text-decoration: none;

debug_toolbar/templates/debug_toolbar/panels/sql.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<ul>
44
{% for alias, info in databases %}
55
<li>
6-
<strong><span style="background-color:rgb({{ info.rgb_color|join:', ' }})" class="djdt-color">&#160;</span> {{ alias }}</strong>
6+
<strong><span class="djdt-color" style="background-color:rgb({{ info.rgb_color|join:', ' }})"></span> {{ alias }}</strong>
77
{{ info.time_spent|floatformat:"2" }} ms ({% blocktrans count info.num_queries as num %}{{ num }} query{% plural %}{{ num }} queries{% endblocktrans %}
88
{% if info.similar_count %}
99
{% blocktrans with count=info.similar_count trimmed %}
@@ -24,7 +24,7 @@
2424
<table>
2525
<thead>
2626
<tr>
27-
<th class="djdt-color">&#160;</th>
27+
<th></th>
2828
<th class="djdt-query" colspan="2">{% trans "Query" %}</th>
2929
<th class="djdt-timeline">{% trans "Timeline" %}</th>
3030
<th class="djdt-time">{% trans "Time (ms)" %}</th>
@@ -34,7 +34,7 @@
3434
<tbody>
3535
{% for query in queries %}
3636
<tr class="{% if query.is_slow %} djDebugRowWarning{% endif %}" id="sqlMain_{{ forloop.counter }}">
37-
<td class="djdt-color"><span style="background-color:rgb({{ query.rgb_color|join:', '}})">&#160;</span></td>
37+
<td><span class="djdt-color" style="background-color:rgb({{ query.rgb_color|join:', '}})"></span></td>
3838
<td class="djdt-toggle">
3939
<a class="djToggleSwitch" data-toggle-name="sqlMain" data-toggle-id="{{ forloop.counter }}" data-toggle-open="+" data-toggle-close="-" href="">+</a>
4040
</td>
@@ -44,13 +44,13 @@
4444
</div>
4545
{% if query.similar_count %}
4646
<strong>
47-
<span style="background-color:{{ query.similar_color }}">&#160;</span>
47+
<span class="djdt-color" style="background-color:{{ query.similar_color }}"></span>
4848
{% blocktrans with count=query.similar_count %}{{ count }} similar queries.{% endblocktrans %}
4949
</strong>
5050
{% endif %}
5151
{% if query.duplicate_count %}
5252
<strong>
53-
<span style="background-color:{{ query.duplicate_color }}">&#160;</span>
53+
<span class="djdt-color" style="background-color:{{ query.duplicate_color }}"></span>
5454
{% blocktrans with dupes=query.duplicate_count %}Duplicated {{ dupes }} times.{% endblocktrans %}
5555
</strong>
5656
{% endif %}

0 commit comments

Comments
 (0)