← Back
Editing: page-perf.scss
@use "sass:map"; .page-perf { background-color: #fff; border: 1px solid $gray-300; border-radius: 5px; bottom: 0; box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.15); font-family: $page-perf-font-family; left: 2em; min-height: 70px; opacity: 0; padding: 1em; position: fixed; transition: opacity 0.5s linear, transform 0.75s ease-out; width: 250px; z-index: 9999; &--visible { opacity: 1; transform: translateY(-2em); } &--with-hovered-score { .page-perf__result { opacity: 0.3; } } // Generate styles for hover effect @each $hovered-position in $page-perf-labels-position { $i: index($page-perf-labels-position, $hovered-position); &.hovered-score-#{$i} { // .page-perf.hovered-score-1 .page-perf__result:nth-child( #{$i} ) { // .page-perf.hovered-score-1 .page-perf__result:nth-child(1) opacity: 1; } .page-perf__results-labels__cell:nth-child( #{$hovered-position} ) { // .page-perf.hovered-score-1 .page-perf__results-labels__cell:nth-child(2) color: $gray-900; } } } &__title { background: none; border: 0; display: block; padding: 0 0 0.5em; position: relative; text-align: left; width: 100%; & > h2 { color: $gray-900; font-family: $page-perf-font-family; font-size: 1.1em; font-weight: 400; margin: 0; } &::after { border-bottom: 2px solid $gray-900; border-left: 2px solid $gray-900; content: ""; display: block; height: 6px; opacity: 0.8; position: absolute; right: 0; top: 0; transform: rotate(-45deg) scale(1) translate(-3px, 1px); transition: transform 0.25s; width: 6px; .page-perf--closed & { transform: rotate(-45deg) scale(-1) translate(5px, -3px); } } &:hover, &:focus { background: none; cursor: pointer; outline: none; & > h2 { color: #000; } } } &__content { padding-top: 0.75em; position: relative; &::before { background-color: $gray-100; content: ""; display: block; height: 1px; left: 0; position: absolute; top: 0; width: 100%; } } &__section { border-bottom: 1px solid $gray-100; font-size: 0.8em; &:first-child { .page-perf__section__heading { padding-top: 0.25em; &::before { top: 6px; } } } &:last-child { border-bottom: 0; .page-perf__section__heading { padding-bottom: 0.5em; } } @each $state in $page-perf-states { &.is-#{$state} .page-perf__section__heading::before { background-color: map.get($page-perf-colors, $state); } } &__heading { box-sizing: border-box; display: flex; justify-content: space-between; line-height: 1; padding: 0.75em 0 0.8em 1.25em; position: relative; &::before { background-color: $gray-300; border-radius: 7px; content: ""; display: block; height: 7px; left: 3px; position: absolute; top: 14px; width: 7px; } &.with-link:hover { cursor: pointer; } } &__title { font-family: $page-perf-font-family; font-size: 1em; font-weight: 400; margin: 0; } &__result { @each $state in $page-perf-states { .is-#{$state} & { // .is-good .page-perf__section__result color: map.get($page-perf-colors, $state); } } } } &__more { height: 200px; overflow: hidden; transition: height 0.2s; .page-perf--closed & { height: 0; margin-bottom: 0; } } &__results-labels { align-items: stretch; display: grid; gap: 0; grid-template-columns: repeat(4, 1fr) 2fr; grid-template-rows: repeat(4, 1fr); height: 100px; justify-items: stretch; width: 100%; &__cell { &.is-corner { position: relative; &::after, &::before { background-color: $gray-300; content: ""; position: absolute; } &::before { bottom: 0; left: calc(50% - 2px); top: 50%; width: 1px; } &::after { bottom: 50%; height: 1px; left: calc(50% - 2px); right: 0; } } &.is-line { position: relative; &::before { background-color: $gray-300; bottom: 0; content: ""; left: calc(50% - 2px); position: absolute; top: 0; width: 1px; } } &.is-label { align-self: center; background: none; border: 0; color: $gray-600; font-family: $page-perf-font-family; font-size: 1em; padding: 0 0 0 8px; text-align: left; transition: padding-left 0.4s ease-out; &:focus, &:hover { outline: none; } &:hover { color: $gray-900; cursor: pointer; } // Generate incremental transition delay @each $hovered-position in $page-perf-labels-position { $i: index($page-perf-labels-position, $hovered-position); &:nth-child( #{$hovered-position} ) { // .page-perf__results-labels__cell.is-label:nth-child(2) transition-delay: calc(150ms * #{$i - 1}); } } .page-perf__content--collapsed & { padding-left: 2px; } } &.is-span-2 { grid-column-end: span 2; } &.is-span-3 { grid-column-end: span 3; } &.is-span-4 { grid-column-end: span 4; } } } &__results { align-items: center; display: flex; flex-direction: row; justify-content: flex-start; list-style-type: none; margin: 0; padding: 0; width: 100%; } &__result { align-items: center; display: flex; height: 30px; justify-content: center; margin-bottom: 0; padding-right: 4px; transition: opacity 0.5s; width: 36px; will-change: opacity; &.with-link:hover { cursor: pointer; } } &__result-label { background-color: $gray-100; border: 1px solid $gray-300; border-radius: 4px; flex: 1; font-size: 0.75em; font-weight: 600; margin: 0 0 0 2px; padding: 5px 2px; text-align: center; &:hover { cursor: pointer; } @each $state in $page-perf-states { &.is-#{$state} { // .page-perf__result-label.is-good background-color: map.get($page-perf-colors-bg, $state); color: map.get($page-perf-colors, $state); } } } &__time { align-items: center; color: $gray-600; display: flex; font-size: 0.7em; font-style: italic; justify-content: space-between; margin: 0.6em 0 -0.8em; padding: 0; text-align: right; &__button { background: none; border: 0; line-height: 1; margin-right: -3px; padding-left: 0.25em; padding-right: 0; &:hover { cursor: pointer; & > svg { transform: rotate(135deg); } } & > svg { fill: $gray-600; transition: transform 0.2s; } } } &__loading { background-color: rgba(255, 255, 255, 0.75); bottom: 0; left: 0; position: absolute; right: 0; top: 0; > svg { animation-duration: 2.5s; animation-fill-mode: forwards; animation-iteration-count: infinite; animation-name: SitePerfLoading; animation-timing-function: ease-out; left: 50%; margin: 0; position: absolute; top: 52%; transform: translate(-50%, -50%) scale(0.3); } } &__cta { align-items: center; display: flex; font-size: 1em; justify-content: center; padding: 0.75em 0 0; & > button { background: none; border: 1px solid $gray-900; padding: 0.5em 1.25em; text-transform: uppercase; transition: all 0.2s; &:focus, &:hover { background-color: $gray-900; color: #fff; cursor: pointer; } } } } @keyframes SitePerfLoading { 0% { transform: translate(-50%, -50%) scale(0.3); } 50% { transform: translate(-50%, -50%) scale(0.4); } 100% { transform: translate(-50%, -50%) scale(0.3); } }
Save File
Cancel