More website loading speed and code improvements

This commit is contained in:
Keavon Chambers
2025-01-08 20:49:42 -08:00
parent 68e6bec9b5
commit ae2637e08e
44 changed files with 833 additions and 898 deletions

View File

@@ -0,0 +1,189 @@
.carousel {
margin-top: calc(80 * var(--variable-px));
transform: translate(0);
.carousel-slide {
display: flex;
white-space: nowrap;
touch-action: pan-y pinch-zoom;
cursor: grab;
img {
position: relative;
display: inline-block;
user-select: none;
flex: 0 0 auto;
height: auto;
padding: 0 20px;
&:first-child,
&:last-child {
--fade-factor: Min(calc(var(--over-slide-factor, 0) / 1.5 + 0.5), 1);
// Fade to white (combining invert and brightness, see <https://stackoverflow.com/a/78478074/775283>) and desaturate
filter: Invert(calc(var(--fade-factor) / 2)) Brightness(calc(1 + var(--fade-factor))) Grayscale(var(--fade-factor));
}
&:first-child {
margin-left: -20px;
}
&:last-child {
margin-right: -20px;
}
}
}
&:not(.dragging, .jostling) .carousel-slide img {
transition: transform 500ms;
}
.carousel-slide:not(.torn) {
overflow: hidden;
}
.carousel-slide.torn {
position: fixed;
top: 0;
z-index: -1;
// Torn edge mask
-webkit-mask-repeat: no-repeat;
mask-repeat: no-repeat;
-webkit-mask-size: contain;
mask-size: contain;
&.left {
padding-left: 160px;
margin-left: -160px;
-webkit-mask-image: url("https://static.graphite.rs/textures/torn-edge-left__2.png");
mask-image: url("https://static.graphite.rs/textures/torn-edge-left__2.png");
-webkit-mask-position: top left;
mask-position: top left;
}
&.right {
padding-right: 160px;
margin-right: -160px;
-webkit-mask-image: url("https://static.graphite.rs/textures/torn-edge-right__2.png");
mask-image: url("https://static.graphite.rs/textures/torn-edge-right__2.png");
-webkit-mask-position: top right;
mask-position: top right;
}
}
.screenshot-details {
display: flex;
margin: 20px 0;
gap: 20px 40px;
@media screen and (max-width: 800px) {
flex-wrap: wrap;
justify-content: center;
}
.carousel-controls {
display: flex;
align-items: center;
flex: 0 0 auto;
button {
outline: none;
background: none;
border: none;
padding: 0;
color: inherit;
cursor: pointer;
svg {
display: block;
}
+ button {
margin-left: 20px;
}
}
.direction {
fill: currentColor;
}
.dot {
width: 16px;
height: 16px;
box-sizing: border-box;
border-radius: 50%;
border: 2px solid currentColor;
&.active {
border: none;
background: var(--color-crimson);
}
}
}
.screenshot-description {
display: flex;
align-items: center;
min-height: calc(2em * 1.5);
p + p {
margin: 0;
}
p:not(.active) {
display: none;
}
}
}
&.center {
.screenshot-details {
justify-content: center;
}
}
&.window-size-1 .carousel-slide img {
width: 100%;
}
&.window-size-2 .carousel-slide img {
width: calc((100% / 2) - 10px);
padding: 0 10px;
&:first-child {
margin-left: -10px;
}
&:last-child {
margin-right: -10px;
}
}
&.window-size-3 .carousel-slide img {
width: calc((100% / 3) - 10px * (4 / 3));
padding: 0 10px;
&:first-child {
margin-left: -10px;
}
&:last-child {
margin-right: -10px;
}
}
@media screen and (max-width: 1000px) {
margin-left: calc(-1 * var(--page-edge-padding));
margin-right: calc(-1 * var(--page-edge-padding));
.screenshot-details {
margin-left: var(--page-edge-padding);
margin-right: var(--page-edge-padding);
}
}
@media screen and (max-width: /* The value of --max-width-plus-padding: */ 1280px) {
.carousel-slide.torn {
display: none;
}
}
}

View File

@@ -0,0 +1,106 @@
pre {
display: flex;
max-width: 100%;
color: var(--color-fog);
// This zero transform sets this element as the root for `position: fixed`
transform: translate(0);
// Color overrides
&,
&.z-code {
background: var(--color-navy);
.z-path {
color: #679f70;
span {
color: #e6e1dc;
}
}
}
// Container for the element (span or table) containing the lines of code
code {
background: initial;
color: inherit;
display: block;
overflow-x: auto;
padding: 20px;
width: 0;
flex: 1 1 auto;
}
// Language name in top right corner
&[data-lang] {
padding-top: 28px;
&::before {
content: attr(data-lang);
color: rgba(var(--color-seaside-rgb), 0.5);
text-transform: lowercase;
font-family: "Inter", sans-serif;
font-size: 0.75em;
font-weight: 700;
font-style: italic;
-webkit-user-select: none;
user-select: none;
pointer-events: none;
position: fixed;
top: 0;
line-height: 28px;
display: block;
width: 100%;
text-indent: 20px;
background: rgba(0, 0, 0, 0.25);
&[data-lang="sh"] {
content: "Shell";
}
&[data-lang="rs"] {
content: "Rust";
}
&[data-lang="js"] {
content: "JavaScript";
}
&[data-lang="ts"] {
content: "TypeScript";
}
}
}
// Code blocks with line numbers
&[data-linenos] table {
border-spacing: 0;
margin: -20px;
tr {
&:first-child td {
padding-top: 20px;
}
&:last-child td {
padding-bottom: 20px;
}
td {
&:first-child {
padding-left: 20px;
padding-right: 10px;
-webkit-user-select: none;
user-select: none;
vertical-align: top;
text-align: right;
background: rgba(0, 0, 0, 0.25);
}
&:last-child {
padding-left: 10px;
padding-right: 20px;
}
}
}
}
}

View File

@@ -0,0 +1,25 @@
.demo-artwork {
display: flex;
align-items: center;
justify-content: center;
margin-top: 20px;
> a {
flex: 0 0 auto;
img {
height: 128px;
border: 12px solid var(--color-walnut);
vertical-align: top;
flex: 0 0 auto;
}
}
p {
display: flex;
flex-direction: column;
max-width: 300px;
margin-left: 40px;
text-align: left;
}
}

View File

@@ -0,0 +1,109 @@
:not(.diptych, .triptych) > :is(.block, .diptych, .triptych) + :is(.block, .diptych, .triptych) {
margin-top: calc(120 * var(--variable-px));
}
.feature-box-narrow,
.feature-box-outer {
padding: calc(80 * var(--variable-px));
background-image: url("https://static.graphite.rs/textures/noise.png");
background-blend-mode: overlay;
background-position: center;
}
:where(h1, h2, h3, h4, p) + .feature-box-narrow {
margin-top: calc(40 * var(--variable-px));
}
.feature-box-full-image {
width: calc(100% + 2 * 80 * var(--variable-px));
height: auto;
margin-left: calc(-80 * var(--variable-px));
margin-top: calc(-80 * var(--variable-px));
margin-bottom: calc(40 * var(--variable-px));
display: block;
}
.feature-box-outer {
@media screen and (max-width: 1000px) {
&.feature-box-outer {
margin-left: calc(-1 * var(--page-edge-padding));
margin-right: calc(-1 * var(--page-edge-padding));
padding-left: var(--page-edge-padding);
padding-right: var(--page-edge-padding);
}
}
&.feature-box-outer {
max-width: unset;
}
.feature-box-inner {
max-width: var(--max-width);
margin: 0 auto;
}
}
h1.feature-box-header.feature-box-header {
&,
& a {
font-family: "Inter", sans-serif;
line-height: 1.5;
font-weight: 800;
text-transform: uppercase;
font-size: calc(1rem * 14 / 9);
}
span {
white-space: pre;
}
~ hr {
margin-top: 20px;
margin-bottom: 40px;
+ p {
margin-top: 0;
}
}
}
.diptych,
.triptych {
display: flex;
flex-wrap: wrap;
gap: calc(80 * var(--variable-px));
.block {
flex: 1 1 0;
}
img[alt=""] {
display: block;
&::after {
content: "";
display: block;
width: 100%;
height: 240px;
background: var(--color-crimson);
}
}
}
.diptych .block {
min-width: 320px;
}
.triptych .block {
min-width: 280px;
}
@media screen and (max-width: 520px) {
.diptych .block {
min-width: 200px;
}
.triptych .block {
min-width: 280px;
}
}

View File

@@ -0,0 +1,89 @@
.feature-icons {
display: flex;
flex-wrap: wrap;
margin-bottom: 20px;
width: 100%;
gap: 16px;
.atlas {
object-fit: cover;
object-position: calc(-48px * var(--atlas-index)) 0;
width: 48px;
height: 48px;
}
.feature-icon {
display: flex;
align-items: center;
img {
flex: 0 0 auto;
}
p + &.feature-icon {
margin-top: calc(40 * var(--variable-px));
}
}
&:not(.stacked) .feature-icon {
padding: 16px;
gap: 16px;
// Half width, minus own padding on both sides, minus half a gap
flex: 1 0 calc(50% - (16px * 2) - (16px / 2));
@media screen and (max-width: 1100px) {
// Quarter width, minus own padding on both sides
flex: 1 0 calc(100% - (16px * 2));
}
}
&:not(.no-background) .feature-icon {
background: rgba(0, 0, 0, 0.0625);
}
&.four-wide .feature-icon {
flex: 1 0 calc(25% - (16px * 4) - (16px / 4));
@media screen and (max-width: 1200px) {
// Half width, minus own padding on both sides, minus half a gap
flex: 1 0 calc(50% - (16px * 2) - (16px / 2));
}
@media screen and (max-width: 840px) {
// Quarter width, minus own padding on both sides
flex: 1 0 calc(100% - (16px * 2));
}
}
&.stacked {
justify-content: space-between;
margin: 0 -10px;
width: calc(100% + 20px);
gap: 0;
.feature-icon {
flex-direction: column;
flex: 0 1 auto;
margin: 0 10px;
@media screen and (max-width: 1100px) {
width: calc(100% / 3 - 40px);
}
@media screen and (max-width: 400px) {
width: calc(100% / 2 - 20px);
}
img {
width: 72px;
height: 72px;
object-position: calc(-72px * var(--atlas-index)) 0;
margin-bottom: 8px;
}
span {
text-align: center;
}
}
}
}

View File

@@ -0,0 +1,116 @@
.image-comparison {
position: relative;
touch-action: pan-y pinch-zoom;
max-width: Min(100%, 512px);
.crop-container {
height: 100%;
&:nth-child(2) {
overflow: hidden;
width: calc(100% - var(--comparison-percent));
&,
img {
position: absolute;
top: 0;
right: 0;
}
}
&.crop-container.crop-container {
img {
display: block;
width: auto;
height: 100%;
}
&:first-child img {
width: 100%;
}
}
}
.slide-bar {
position: absolute;
background: var(--color-navy);
margin-left: -2px;
width: 4px;
height: 100%;
top: 0;
left: var(--comparison-percent);
box-shadow: 0 0 2px rgba(255, 255, 255, 0.5);
.arrows {
position: absolute;
top: calc(50% - (40px / 2));
left: calc(4px / 2);
width: 0;
height: 0;
opacity: 1;
transition: opacity 0.25s;
svg {
position: absolute;
width: 6.5px;
height: 11px;
top: calc(-11px / 2);
fill: white;
@keyframes pulse-left {
from { transform: translateX(3px); }
to { transform: translateX(-3px); }
}
@keyframes pulse-right {
from { transform: scaleX(-1) translateX(3px); }
to { transform: scaleX(-1) translateX(-3px); }
}
@keyframes pulse-opacity {
0% { opacity: 0; }
40% { opacity: 1; }
90% { opacity: 1; }
100% { opacity: 0; }
}
&:nth-of-type(1) {
right: 6px;
animation: 3s infinite ease-out pulse-left, 3s infinite ease-out pulse-opacity;
}
&:nth-of-type(2) {
left: 6px;
animation: 3s infinite ease-out pulse-right, 3s infinite ease-out pulse-opacity;
}
}
div {
content: "";
position: absolute;
background: var(--color-navy);
top: 0;
left: 0;
width: 32px;
height: 32px;
transform: translate(-50%, -50%) rotate(45deg);
box-shadow: 0 0 2px rgba(255, 255, 255, 0.5);
}
// Cover up the box-shadow at the top and bottom of the circle so it connects to the vertical line
&::after {
content: "";
position: absolute;
background: var(--color-navy);
left: -2px;
top: -24px;
width: 4px;
height: 48px;
}
}
}
&:hover .slide-bar .arrows {
opacity: 0;
}
}

View File

@@ -0,0 +1,21 @@
.youtube-embed {
position: relative;
width: 100%;
&.aspect-16x9 {
padding-top: calc(100% / (16 / 9));
}
img,
iframe {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
img {
cursor: pointer;
}
}