tangled
alpha
login
or
join now
vielle.dev
/
site-archive
0
fork
atom
[Archived] Archived WIP of vielle.dev
0
fork
atom
overview
issues
pulls
pipelines
Add cable for balloon and add to post
vielle.dev
9 months ago
f166a675
1d963942
+122
-1
3 changed files
expand all
collapse all
unified
split
src
components
blog
Balloon.astro
Post.astro
config.ts
+102
src/components/blog/Balloon.astro
···
1
1
+
---
2
2
+
import { blog, utils } from "@/config";
3
3
+
4
4
+
interface Props {
5
5
+
id: number;
6
6
+
of: number;
7
7
+
}
8
8
+
9
9
+
const { id, of } = Astro.props;
10
10
+
11
11
+
const length = utils.getRandom(blog.balloons.size);
12
12
+
const offset = utils.getRandom(blog.balloons.offset);
13
13
+
const rotation = new Array(5)
14
14
+
.fill(0)
15
15
+
.map((_) => utils.getRandom(blog.balloons.rotation));
16
16
+
---
17
17
+
18
18
+
<div
19
19
+
style={`--length: ${length}rem;
20
20
+
--id: ${id};
21
21
+
--of: ${of};
22
22
+
--offset: ${offset}rem;
23
23
+
${rotation.map((x, i) => `--rot-${i}: ${x}deg;`).join(" ")}
24
24
+
--timing: ${utils.getRandom(blog.balloons.timing)}s;
25
25
+
`}
26
26
+
>
27
27
+
</div>
28
28
+
29
29
+
<style>
30
30
+
@property --rot-0 {
31
31
+
syntax: "<angle>";
32
32
+
inherits: false;
33
33
+
initial-value: 0px;
34
34
+
}
35
35
+
36
36
+
@property --rot-1 {
37
37
+
syntax: "<angle>";
38
38
+
inherits: false;
39
39
+
initial-value: 0px;
40
40
+
}
41
41
+
42
42
+
@property --rot-2 {
43
43
+
syntax: "<angle>";
44
44
+
inherits: false;
45
45
+
initial-value: 0px;
46
46
+
}
47
47
+
48
48
+
@property --rot-3 {
49
49
+
syntax: "<angle>";
50
50
+
inherits: false;
51
51
+
initial-value: 0px;
52
52
+
}
53
53
+
54
54
+
@property --rot-4 {
55
55
+
syntax: "<angle>";
56
56
+
inherits: false;
57
57
+
initial-value: 0px;
58
58
+
}
59
59
+
60
60
+
@keyframes tilt {
61
61
+
from,
62
62
+
to {
63
63
+
rotate: var(--rot-0);
64
64
+
}
65
65
+
66
66
+
20% {
67
67
+
rotate: var(--rot-1);
68
68
+
}
69
69
+
70
70
+
40% {
71
71
+
rotate: var(--rot-2);
72
72
+
}
73
73
+
74
74
+
60% {
75
75
+
rotate: var(--rot-3);
76
76
+
}
77
77
+
78
78
+
80% {
79
79
+
rotate: var(--rot-4);
80
80
+
}
81
81
+
}
82
82
+
83
83
+
div {
84
84
+
position: absolute;
85
85
+
86
86
+
width: 0.5rem;
87
87
+
height: var(--length);
88
88
+
background: black;
89
89
+
90
90
+
top: calc(-1 * var(--length));
91
91
+
left: calc(
92
92
+
100% / var(--of) * var(--id) + 100% / 2 / var(--of) + var(--offset)
93
93
+
);
94
94
+
95
95
+
transform-origin: bottom;
96
96
+
rotate: var(--rot-0);
97
97
+
98
98
+
@media (prefers-reduced-motion: no-preference) {
99
99
+
animation: infinite var(--timing) linear tilt;
100
100
+
}
101
101
+
}
102
102
+
</style>
+13
-1
src/components/blog/Post.astro
···
2
2
import type { InferEntrySchema } from "astro:content";
3
3
import { Image } from "astro:assets";
4
4
5
5
-
import { blog } from "@/config";
5
5
+
import { blog, utils } from "@/config";
6
6
+
import Balloon from "./Balloon.astro";
6
7
7
8
interface Props {
8
9
id: string;
···
76
77
--y-gap: ${blog.post.yGap}rem;
77
78
`}
78
79
>
80
80
+
{
81
81
+
// new Array(Math.floor(utils.getRandom(blog.balloons.numBalloons)))
82
82
+
// .fill(0)
83
83
+
// .map((_, i) => <Balloon id={i} of={this?.length} />)
84
84
+
85
85
+
(() => {
86
86
+
const len = Math.round(utils.getRandom(blog.balloons.numBalloons));
87
87
+
const arr = new Array(len).fill(0);
88
88
+
return arr.map((_, i) => <Balloon id={i} of={len} />);
89
89
+
})()
90
90
+
}
79
91
<Image src={image} alt="" />
80
92
<div>
81
93
<a href={`/blog/${id}/`}>({id}) {data.title}</a>
+7
src/config.ts
···
36
36
prongs: [10, 20],
37
37
},
38
38
},
39
39
+
balloons: {
40
40
+
numBalloons: [1, 3],
41
41
+
size: [10, 20],
42
42
+
offset: [-5, 5],
43
43
+
rotation: [-10, 10],
44
44
+
timing: [30, 45]
45
45
+
},
39
46
} as const;
40
47
41
48
export const utils = {