Skip to content

Commit 788125a

Browse files
authored
docs: play a short entrance animation in the home page hero (#71)
The hero illustration now plays a short entrance once on load and then rests on the same static picture as before: | Time | What happens | |---|---| | 0.1s | the yellow ring around the illustration is drawn (1.1s) | | 0.15s | the review card rises | | 0.3s | the ring around "already checked" is drawn | | 0.35s | the "clang-format 21 · clang-tidy 21" pin slides in | | 0.45s | the three diff lines slide in one after another | | 0.85s | the github-actions clang-tidy suggestion rises | | 1.05s | the small check beside the headline is drawn | | 1.45s | "Commit suggestion" is pressed | | 1.7s | the auto-fix commit chip pops up | | 2.0s | the large check is drawn | It is CSS only: a block of keyframes in `home.css`, and `pathLength="1"` on the four hand-drawn paths in `home.html`, which the drawing needs. With "reduce motion" turned on, nothing moves. The strokes keep their width when the SVGs stretch (`vector-effect: non-scaling-stroke`), so on screen a path is 0.67 to 1.25 times its `pathLength` (measured at 375px and 1280px). The drawing uses 1.5-long dashes to cover that, and its last frame removes the dashes, so the finished picture is the unchanged static stroke. Checked with `mkdocs serve` at 1280px and 375px wide by seeking the animations to 0.1, 0.55, 0.9, 1.05, 1.65 and 2.05 seconds and to the end: no stray stroke before the drawing starts, the end state matches the current page, and there is no horizontal scroll.
1 parent 85739d3 commit 788125a

2 files changed

Lines changed: 135 additions & 3 deletions

File tree

‎docs/overrides/home.html‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
<h1 class="cl-hero__title">
7676
C/C++ pull requests<br>
7777
that arrive<br>
78-
<span class="cl-circled"><svg class="cl-circled__ring" viewBox="0 0 400 100" preserveAspectRatio="none" aria-hidden="true"><path d="M 318 10 C 236 -4, 92 0, 36 22 C -4 38, 4 84, 108 92 C 214 100, 378 90, 394 56 C 402 36, 384 20, 350 12"/></svg><span class="cl-circled__text">already checked</span><svg class="cl-circled__check" viewBox="0 0 64 52" aria-hidden="true"><path d="M 6 28 L 22 44 L 58 6"/></svg></span>.
78+
<span class="cl-circled"><svg class="cl-circled__ring" viewBox="0 0 400 100" preserveAspectRatio="none" aria-hidden="true"><path pathLength="1" d="M 318 10 C 236 -4, 92 0, 36 22 C -4 38, 4 84, 108 92 C 214 100, 378 90, 394 56 C 402 36, 384 20, 350 12"/></svg><span class="cl-circled__text">already checked</span><svg class="cl-circled__check" viewBox="0 0 64 52" aria-hidden="true"><path pathLength="1" d="M 6 28 L 22 44 L 58 6"/></svg></span>.
7979
</h1>
8080
<p class="cl-lead">
8181
cpp-linter runs clang-format and clang-tidy on the files each pull
@@ -99,7 +99,7 @@ <h1 class="cl-hero__title">
9999
</div>
100100

101101
<div class="cl-visual" role="img" aria-label="A review comment from cpp-linter-action suggests a clang-tidy fix, and auto-fix pushes the clang-format fixes as a commit.">
102-
<svg class="cl-visual__ring" viewBox="0 0 600 600" preserveAspectRatio="none" aria-hidden="true"><path d="M 512 112 C 460 56, 380 30, 300 30 C 150 30, 36 146, 36 300 C 36 452, 150 570, 302 570 C 454 570, 566 452, 566 300 C 566 250, 552 206, 532 172"/></svg>
102+
<svg class="cl-visual__ring" viewBox="0 0 600 600" preserveAspectRatio="none" aria-hidden="true"><path pathLength="1" d="M 512 112 C 460 56, 380 30, 300 30 C 150 30, 36 146, 36 300 C 36 452, 150 570, 302 570 C 454 570, 566 452, 566 300 C 566 250, 552 206, 532 172"/></svg>
103103
<span class="cl-visual__pin"><span class="cl-ico">{% include ".icons/octicons/pin-16.svg" %}</span>clang-format 21 · clang-tidy 21</span>
104104
<div class="cl-review">
105105
<div class="cl-review__file">
@@ -132,7 +132,7 @@ <h1 class="cl-hero__title">
132132
</div>
133133
</div>
134134
</div>
135-
<svg class="cl-visual__check" viewBox="0 0 140 120" aria-hidden="true"><path d="M 14 70 L 44 100 L 128 12"/></svg>
135+
<svg class="cl-visual__check" viewBox="0 0 140 120" aria-hidden="true"><path pathLength="1" d="M 14 70 L 44 100 L 128 12"/></svg>
136136
<div class="cl-fixchip">
137137
<span class="cl-fixchip__icon">{% include ".icons/material/check-bold.svg" %}</span>
138138
<span class="cl-fixchip__text">

‎docs/stylesheets/home.css‎

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,138 @@
961961
}
962962
}
963963

964+
/*
965+
* Hero entrance, played once on load: the review card rises, the diff and the
966+
* clang-tidy suggestion come in, "Commit suggestion" is pressed, the auto-fix
967+
* commit pops up, and the rings and checks are drawn. It ends on the static
968+
* picture; with reduced motion the picture is shown as is.
969+
*/
970+
@media (prefers-reduced-motion: no-preference) {
971+
.cl-hero .cl-circled__ring path,
972+
.cl-hero .cl-circled__check path,
973+
.cl-visual__ring path,
974+
.cl-visual__check path {
975+
animation: cl-draw 1s cubic-bezier(0.6, 0, 0.3, 1) both;
976+
}
977+
978+
.cl-hero .cl-circled__ring path {
979+
animation-duration: 0.8s;
980+
animation-delay: 0.3s;
981+
}
982+
983+
.cl-hero .cl-circled__check path {
984+
animation-duration: 0.35s;
985+
animation-delay: 1.05s;
986+
}
987+
988+
.cl-visual__ring path {
989+
animation-duration: 1.1s;
990+
animation-delay: 0.1s;
991+
}
992+
993+
.cl-visual__check path {
994+
animation-duration: 0.4s;
995+
animation-delay: 2s;
996+
}
997+
998+
.cl-visual__pin {
999+
animation: cl-slide-in 0.4s 0.35s ease-out both;
1000+
}
1001+
1002+
.cl-review {
1003+
animation: cl-rise 0.55s 0.15s cubic-bezier(0.2, 0.7, 0.2, 1) both;
1004+
}
1005+
1006+
.cl-review__diff .cl-diff__line {
1007+
animation: cl-slide-in 0.35s ease-out both;
1008+
}
1009+
1010+
.cl-review__diff .cl-diff__line:nth-child(1) {
1011+
animation-delay: 0.45s;
1012+
}
1013+
1014+
.cl-review__diff .cl-diff__line:nth-child(2) {
1015+
animation-delay: 0.55s;
1016+
}
1017+
1018+
.cl-review__diff .cl-diff__line:nth-child(3) {
1019+
animation-delay: 0.65s;
1020+
}
1021+
1022+
.cl-comment {
1023+
animation: cl-rise 0.5s 0.85s cubic-bezier(0.2, 0.7, 0.2, 1) both;
1024+
}
1025+
1026+
.cl-comment .cl-fake-btn--primary {
1027+
animation: cl-press 0.7s 1.45s ease-out both;
1028+
}
1029+
1030+
.cl-fixchip {
1031+
animation: cl-pop 0.5s 1.7s cubic-bezier(0.2, 0.8, 0.3, 1.25) both;
1032+
}
1033+
}
1034+
1035+
/*
1036+
* The paths have pathLength="1", but their strokes do not scale with the SVG,
1037+
* so on screen a path is 0.7 to 1.3 times that length. A dash of 1.5 covers
1038+
* it, and the last frame drops the dashes to end on the static stroke.
1039+
*/
1040+
@keyframes cl-draw {
1041+
0% {
1042+
stroke-dasharray: 1.5 1.5;
1043+
stroke-dashoffset: 1.55;
1044+
}
1045+
1046+
99% {
1047+
stroke-dasharray: 1.5 1.5;
1048+
stroke-dashoffset: 0;
1049+
}
1050+
1051+
100% {
1052+
stroke-dasharray: none;
1053+
stroke-dashoffset: 0;
1054+
}
1055+
}
1056+
1057+
@keyframes cl-rise {
1058+
from {
1059+
opacity: 0;
1060+
transform: translateY(18px);
1061+
}
1062+
}
1063+
1064+
@keyframes cl-slide-in {
1065+
from {
1066+
opacity: 0;
1067+
transform: translateX(-10px);
1068+
}
1069+
}
1070+
1071+
@keyframes cl-pop {
1072+
from {
1073+
opacity: 0;
1074+
transform: translateY(12px) scale(0.92);
1075+
}
1076+
}
1077+
1078+
@keyframes cl-press {
1079+
0% {
1080+
box-shadow: 0 0 0 0 rgba(64, 81, 181, 0.45);
1081+
}
1082+
1083+
30% {
1084+
transform: scale(0.95);
1085+
}
1086+
1087+
60% {
1088+
transform: scale(1);
1089+
}
1090+
1091+
100% {
1092+
box-shadow: 0 0 0 10px rgba(64, 81, 181, 0);
1093+
}
1094+
}
1095+
9641096
/* Tools */
9651097

9661098
.cl-tools {

0 commit comments

Comments
 (0)