Skip to content

Commit

Permalink
chevrons
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed May 12, 2018
1 parent 2a2af27 commit 6745a56
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 57 deletions.
20 changes: 15 additions & 5 deletions lighthouse-core/report/html/renderer/category-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ class CategoryRenderer {
}

auditEl.classList.add(`lh-audit--${audit.result.scoreDisplayMode}`);

this.dom.find('.lh-audit__index', auditEl).textContent = `${index + 1}`;

// Add chevron SVG to the end of the summary
this.dom.find('.lh-chevron-container', auditEl).appendChild(this._createChevron());
this._setRatingClass(auditEl, audit.result.score, scoreDisplayMode);

if (audit.result.scoreDisplayMode === 'error') {
Expand All @@ -84,6 +85,15 @@ class CategoryRenderer {
return auditEl;
}

/**
* @return {!Element}
*/
_createChevron() {
const chevronTmpl = this.dom.cloneTemplate('#tmpl-lh-chevron', this.templateContext);
const chevronEl = this.dom.find('.lh-chevron', chevronTmpl);
return chevronEl;
}

/**
* @param {!Element} element DOM node to populate with values.
* @param {number|null} score
Expand Down Expand Up @@ -131,10 +141,10 @@ class CategoryRenderer {
const summmaryEl = this.dom.createChildOf(groupEl, 'summary', 'lh-audit-group__summary');
const headerEl = this.dom.createChildOf(summmaryEl, 'div', 'lh-audit-group__header');
const itemCountEl = this.dom.createChildOf(summmaryEl, 'div', 'lh-audit-group__itemcount');
this.dom.createChildOf(summmaryEl, 'div',
`lh-toggle-arrow ${expandable ? '' : ' lh-toggle-arrow-unexpandable'}`, {
title: 'Show audits',
});
if (expandable) {
const chevronEl = summmaryEl.appendChild(this._createChevron());
chevronEl.title = 'Show audits';
}

if (group.description) {
const auditGroupDescription = this.dom.createElement('div', 'lh-audit-group__description');
Expand Down
79 changes: 44 additions & 35 deletions lighthouse-core/report/html/report-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
--pass-icon-url: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><title>check</title><path fill="hsl(139, 70%, 30%)" d="M24 4C12.95 4 4 12.95 4 24c0 11.04 8.95 20 20 20 11.04 0 20-8.96 20-20 0-11.05-8.96-20-20-20zm-4 30L10 24l2.83-2.83L20 28.34l15.17-15.17L38 16 20 34z"/></svg>');
--average-icon-url: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><title>info</title><path fill="hsl(31, 100%, 45%)" d="M24 4C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4zm2 30h-4V22h4v12zm0-16h-4v-4h4v4z"/></svg>');
--fail-icon-url: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><title>warn</title><path fill="hsl(1, 73%, 45%)" d="M2 42h44L24 4 2 42zm24-6h-4v-4h4v4zm0-8h-4v-8h4v8z"/></svg>');
--chevron-icon-url: url('data:image/svg+xml;utf8,<svg fill="hsl(216, 5%, 39%)" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"/><path d="M0-.25h24v24H0z" fill="none"/></svg>');

--av-timer-icon-url: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48"><path d="M0 0h48v48H0z" fill="none"/><path d="M22 34c0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2-2 .9-2 2zm0-28v8h4v-3.84c6.78.97 12 6.79 12 13.84 0 7.73-6.27 14-14 14s-14-6.27-14-14c0-3.36 1.18-6.43 3.15-8.85L24 26l2.83-2.83-13.6-13.6-.02.04C8.84 12.89 6 18.11 6 24c0 9.94 8.04 18 17.99 18S42 33.94 42 24 33.94 6 23.99 6H22zm14 18c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2zm-24 0c0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2-2 .9-2 2z" fill="hsl(216, 5%, 39%)"/></svg>');
--photo-filter-icon-url: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48"><path fill="none" d="M0 0h48v48H0V0z"/><path d="M38.04 20v18H10V10h18V6H10.04c-2.2 0-4 1.8-4 4v28c0 2.2 1.8 4 4 4h28c2.2 0 4-1.8 4-4V20h-4zM34 20l1.88-4.12L40 14l-4.12-1.88L34 8l-1.88 4.12L28 14l4.12 1.88zm-7.5 1.5L24 16l-2.5 5.5L16 24l5.5 2.5L24 32l2.5-5.5L32 24z" fill="hsl(216, 5%, 39%)"/></svg>');
Expand Down Expand Up @@ -262,13 +261,13 @@
.lh-audit__display-text,
.lh-audit__score-icon,
.lh-load-opportunity__sparkline,
.lh-toggle-arrow {
.lh-chevron-container {
margin: 0 var(--audit-item-gap);
}
.lh-audit__index {
margin-left: 0;
}
.lh-toggle-arrow {
.lh-chevron-container {
margin-right: 0;
}

Expand All @@ -281,22 +280,6 @@
flex: 1;
}

.lh-toggle-arrow {
background: var(--chevron-icon-url) no-repeat center center / 20px 20px;
width: 12px;
height: 18px;
flex: none;
transition: transform 150ms ease-in-out;
cursor: pointer;
border: none;
transform: rotateZ(90deg);
margin-top: calc((var(--body-line-height) - 12px) / 2);
}

.lh-toggle-arrow-unexpandable {
visibility: hidden;
}

/* Expandable Details (Audit Groups, Audits) */
.lh-audit__header {
display: flex;
Expand All @@ -312,14 +295,6 @@
background-color: #F8F9FA;
}


.lh-audit-group[open] > .lh-audit-group__summary > .lh-toggle-arrow,
.lh-expandable-details[open] > .lh-expandable-details__summary > .lh-toggle-arrow,
.lh-expandable-details[open] > .lh-expandable-details__summary > div > .lh-toggle-arrow,
.lh-expandable-details[open] > .lh-expandable-details__summary > div > div > .lh-toggle-arrow {
transform: rotateZ(-90deg);
}

.lh-audit-group__summary::-webkit-details-marker,
.lh-expandable-details__summary::-webkit-details-marker {
display: none;
Expand Down Expand Up @@ -603,10 +578,6 @@
margin: 0 10px;
}

.lh-audit-group__summary .lh-toggle-arrow {

}

.lh-audit-group__description {
font-size: var(--body-font-size);
color: var(--medium-75-gray);
Expand Down Expand Up @@ -742,6 +713,7 @@

.lh-category:first-of-type {
padding-top: calc(2 * var(--section-padding));
border: none;
}

/* section hash link jump should preserve fixed header
Expand All @@ -754,10 +726,6 @@
visibility: hidden;
}

.lh-category:first-of-type {
border: none;
}

.lh-category-header {
font-size: var(--header-font-size);
min-height: var(--circle-size);
Expand Down Expand Up @@ -921,6 +889,47 @@ summary.lh-passed-audits-summary {
object-fit: contain;
}

/* Chevron
https://codepen.io/paulirish/pen/LmzEmK
*/

.lh-chevron {
width: 12px;
height: 12px;
margin-top: calc((var(--body-line-height) - 12px) / 2);
}

.lh-chevron__lines {
transition: transform 0.4s;
transform: translateY(20px);
}
.lh-chevron__line {
stroke: hsl(216, 5%, 39%);
transform-origin: 50px 50px;
stroke-width: 15px;
stroke-linecap: square;
transition: transform 300ms, stroke 300ms;
transform: rotate(42deg);
}

.lh-audit-group > .lh-audit-group__summary > .lh-chevron .lh-chevron__line-right,
.lh-audit-group[open] > .lh-audit-group__summary > .lh-chevron .lh-chevron__line-left,
.lh-audit > .lh-expandable-details .lh-chevron__line-right,
.lh-audit > .lh-expandable-details[open] .lh-chevron__line-left {
transform: rotate(-42deg);
}

.lh-audit-group[open] > .lh-audit-group__summary > .lh-chevron .lh-chevron__line-right,
.lh-audit > .lh-expandable-details[open] .lh-chevron__line-right {
transform: rotate(42deg);
}

.lh-audit-group[open] > .lh-audit-group__summary > .lh-chevron .lh-chevron__lines,
.lh-audit > .lh-expandable-details[open] .lh-chevron__lines {
transform: translateY(-13px);
}



/* Tooltip */
.tooltip-boundary {
Expand Down
29 changes: 12 additions & 17 deletions lighthouse-core/report/html/templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
</div>
</template>

<!-- Toggle arrow chevron -->
<template id="tmpl-lh-chevron">
<svg class="lh-chevron" title="See audits" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 100 100">
<g class="lh-chevron__lines">
<path class="lh-chevron__line lh-chevron__line-left" d="M10 50h40" stroke="#707173"/>
<path class="lh-chevron__line lh-chevron__line-right" d="M90 50H50" stroke="#707173"/>
</g>
</svg>
</template>

<!-- Lighthouse category header -->
<template id="tmpl-lh-category-header">
<div class="lh-category-header">
Expand All @@ -34,7 +44,7 @@
<span class="lh-audit__title"></span>
<span class="lh-audit__display-text"></span>
<div class="lh-audit__score-icon"></div>
<div class="lh-toggle-arrow" title="See audits"></div>
<div class="lh-chevron-container"></div>
</summary>
<div class="lh-audit__description"></div>
</details>
Expand Down Expand Up @@ -67,7 +77,7 @@
<div class="lh-sparkline"><div class="lh-sparkline__bar"></div></div>
</div>
<div class="lh-audit__display-text"></div>
<div class="lh-toggle-arrow" title="See resources"></div>
<div class="lh-chevron-container" title="See resources"></div>
</div>
</div>
</summary>
Expand Down Expand Up @@ -297,20 +307,6 @@
display: flex;
align-items: center;
}
.lh-config__settings-toggle .lh-toggle-arrow {
width: 16px;
height: 16px;
margin-left: 2px;
}
.lh-config__settings-toggle[open] .lh-toggle-arrow {
transform: rotateZ(90deg);
}
.lh-config__settings-toggle summary::-moz-list-bullet {
display: none;
}
.lh-config__settings-toggle summary::-webkit-details-marker {
display: none;
}
@media screen and (max-width: 964px) {
.lh-export__dropdown {
right: 0;
Expand Down Expand Up @@ -340,7 +336,6 @@
<details class="lh-config__settings-toggle">
<summary>
<span>Runtime settings</span>
<span class="lh-toggle-arrow" title="See report's runtime settings"></span>
</summary>
<div class="lh-env">
<div class="lh-env__title">Runtime environment</div>
Expand Down

0 comments on commit 6745a56

Please sign in to comment.