Skip to content

Commit e4ea8ed

Browse files
authored
transitions (#152)
* init * disable autoprefixr * add focus interactions * nits * use nesting, demo enhancements * transitions always * Update index.css * better wipe swap * setup for the tutorial * reveal some images * animation adjustment * better responsive layout * moves hidden images to css * better fit for book * more halloween * adds reduced motion support * more minimal percentage
1 parent e54fbf7 commit e4ea8ed

13 files changed

+2919
-0
lines changed

.github/workflows/main.yml

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ jobs:
7979

8080
- name: Build Tooltips
8181
run: cd tooltips && npm install && npm run build
82+
83+
- name: Build Transitions
84+
run: cd transitions && npm install && npm run build
8285

8386
- name: Deploy to Firebase
8487
uses: w9jds/firebase-action@master

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,7 @@ and expand the diversity of our skills.**
9898
[`Demo`](https://gui-challenges.web.app/tooltips/dist/)
9999
[`YouTube`](https://www.youtube.com/watch?v=Y5EIC_UyPME)
100100
[`Article`](#)(coming soon)
101+
24. Transitions
102+
[`Demo`](https://gui-challenges.web.app/transitions/dist/)
103+
[`YouTube`](#)(coming soon)
104+
[`Article`](#)(coming soon)

transitions/circle.transitions.css

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
:root {
2+
--circle-in: circle(75%);
3+
--circle-out: circle(0%);
4+
}
5+
6+
.circle-in {
7+
& > .box {
8+
clip-path: var(--circle-out);
9+
10+
@media (--motionOK) {
11+
transition: clip-path 1s ease;
12+
}
13+
}
14+
15+
&:is(:hover,:focus,:active) > .box {
16+
clip-path: var(--circle-in);
17+
}
18+
}
19+
20+
.circle-out {
21+
& > .box {
22+
clip-path: var(--circle-in);
23+
24+
@media (--motionOK) {
25+
transition: clip-path 1s ease;
26+
}
27+
}
28+
29+
&:is(:hover,:focus,:active) > .box {
30+
clip-path: var(--circle-out);
31+
}
32+
}
33+
34+
.circle-suprise {
35+
display: grid;
36+
grid: auto-flow 1fr / 1fr;
37+
38+
& > .box {
39+
grid-area: 1 / 1;
40+
clip-path: var(--circle-in);
41+
42+
@media (--motionOK) {
43+
transition: clip-path 1s ease;
44+
}
45+
46+
&:nth-child(1) {
47+
transition-delay: .2s;
48+
}
49+
50+
&:nth-child(2) {
51+
clip-path: var(--circle-out);
52+
background: deeppink;
53+
}
54+
}
55+
56+
&:is(:hover,:focus,:active) {
57+
& > .box {
58+
&:nth-child(1) {
59+
transition-delay: 0s;
60+
clip-path: var(--circle-out);
61+
}
62+
&:nth-child(2) {
63+
transition-delay: .2s;
64+
clip-path: var(--circle-in);
65+
}
66+
}
67+
}
68+
}

transitions/favicon.ico

15 KB
Binary file not shown.

transitions/favicon.svg

+28
Loading

transitions/index.css

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
@layer demo.support, transitions;
2+
3+
@import "transitions.css" layer(transitions);
4+
@import "circle.transitions.css" layer(transitions);
5+
@import "wipes.transitions.css" layer(transitions);
6+
7+
@custom-media --motionOK (prefers-reduced-motion: no-preference);
8+
9+
@layer demo {
10+
.box {
11+
display: flex;
12+
align-items: center;
13+
justify-content: center;
14+
text-align: center;
15+
background: indigo;
16+
color: white;
17+
aspect-ratio: 1;
18+
font-size: 3vw;
19+
font-size: 12cqi;
20+
font-weight: lighter;
21+
letter-spacing: .2em;
22+
}
23+
24+
.emoji {
25+
font-size: 6vw;
26+
font-size: 25cqi;
27+
}
28+
}
29+
30+
@layer demo.support {
31+
* {
32+
box-sizing: border-box;
33+
margin: 0;
34+
outline-offset: 5px;
35+
}
36+
37+
html {
38+
block-size: 100%;
39+
color-scheme: dark light;
40+
}
41+
42+
body {
43+
min-block-size: 100%;
44+
font-family: system-ui, sans-serif;
45+
46+
display: grid;
47+
place-content: center;
48+
justify-items: center;
49+
gap: 7vh;
50+
padding-block: 20vh;
51+
}
52+
53+
article {
54+
display: grid;
55+
grid-template-columns: repeat(3, min(25vw, 30ch));
56+
gap: 5vmin;
57+
58+
& > div {
59+
container-type: inline-size;
60+
}
61+
}
62+
}
63+
64+
@layer demo.support {
65+
.github-corner {
66+
position: absolute;
67+
top: 0;
68+
right: 0;
69+
width: 80px;
70+
height: 80px;
71+
fill: Highlight;
72+
color: Canvas;
73+
74+
&:hover .octo-arm {
75+
animation: octocat-wave 560ms ease-in-out
76+
}
77+
78+
& > svg {
79+
fill: inherit;
80+
stroke: inherit;
81+
position: absolute;
82+
top: 0;
83+
right: 0;
84+
}
85+
}
86+
87+
@keyframes octocat-wave{
88+
0%,100% {
89+
transform: rotate(0)
90+
}
91+
20%,60% {
92+
transform: rotate(-25deg)
93+
}
94+
40%,80% {
95+
transform: rotate(10deg)
96+
}
97+
}
98+
}

transitions/index.html

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<!doctype html>
2+
<html lang="en" dir="ltr">
3+
<head>
4+
<meta charset="utf-8">
5+
6+
<title>Transitions | GUI Challenges</title>
7+
<meta name="description" content="🤓">
8+
9+
<meta name="viewport" content="width=device-width, initial-scale=1">
10+
<meta name="mobile-web-app-capable" content="yes">
11+
<meta name="theme-color" content="Canvas">
12+
<meta name="color-scheme" content="light dark">
13+
14+
<link rel="icon" href="/favicon.ico" sizes="any">
15+
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
16+
17+
<link rel="stylesheet" href="./index.css">
18+
</head>
19+
<body>
20+
21+
<article focusgroup>
22+
<div class="circle-out" tabindex="0">
23+
<div class="box">CIRCLE<br>OUT</div>
24+
</div>
25+
<div class="circle-in" tabindex="0">
26+
<div class="box">CIRCLE<br>IN</div>
27+
</div>
28+
<div class="circle-suprise" tabindex="0">
29+
<div class="box">TRICK</div>
30+
<div class="box">TREAT</div>
31+
</div>
32+
</article>
33+
34+
<article focusgroup>
35+
<div class="wipe-out" tabindex="0">
36+
<div class="box">WIPE<br>OUT</div>
37+
</div>
38+
<div class="wipe-in" tabindex="0">
39+
<div class="box">
40+
</div>
41+
</div>
42+
<div class="wipe-suprise" tabindex="0">
43+
<div class="box">TRICK</div>
44+
<div class="box">TREAT</div>
45+
</div>
46+
</article>
47+
48+
<article focusgroup>
49+
<div class="square-out" tabindex="0">
50+
<div class="box">SQUARE<br>OUT</div>
51+
</div>
52+
<div class="square-in" tabindex="0">
53+
<div class="box">SQUARE<br>IN</div>
54+
</div>
55+
<div class="square-suprise" tabindex="0">
56+
<div class="box emoji">🎃</div>
57+
<div class="box emoji">🤘💀</div>
58+
</div>
59+
</article>
60+
61+
<!-- <a href="https://github.com/argyleink/gui-challenges" class="github-corner" aria-label="View source on GitHub">
62+
<svg width="80" height="80" viewBox="0 0 250 250" style="position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true">
63+
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
64+
<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
65+
<path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path>
66+
</svg>
67+
</a> -->
68+
69+
</body>
70+
</html>

0 commit comments

Comments
 (0)