forked from LemmyNet/lemmy-ui
/
loading-skeleton.tsx
127 lines (117 loc) · 3.35 KB
/
loading-skeleton.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import { Component } from "inferno";
interface LoadingSkeletonProps {
itemCount?: number;
}
interface LoadingSkeletonLineProps {
size: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
}
class LoadingSkeletonLine extends Component<LoadingSkeletonLineProps, any> {
render() {
const className = "placeholder placeholder-lg col-" + this.props.size;
return (
<p className="placeholder-glow m-0">
<span className={className} style={{ height: "1.3em" }} />
</p>
);
}
}
export class PostsLoadingSkeleton extends Component<LoadingSkeletonProps, any> {
render() {
return Array.from({ length: this.props.itemCount ?? 10 }, (_, index) => (
<PostsLoadingSkeletonItem key={index} />
));
}
}
class PostThumbnailLoadingSkeleton extends Component<any, any> {
render() {
return (
<div className="thumbnail rounded d-flex justify-content-center placeholder-glow">
<span className="placeholder placeholder-lg h-100 w-100 rounded" />
</div>
);
}
}
class PostsLoadingSkeletonItem extends Component<any, any> {
render() {
return (
<div className="my-3">
<div className="col flex-grow-1">
<div className="row">
<div className="col flex-grow-0 order-last order-sm-first">
<PostThumbnailLoadingSkeleton />
</div>
<div className="col flex-grow-1">
<LoadingSkeletonLine size={12} />
<LoadingSkeletonLine size={8} />
<LoadingSkeletonLine size={4} />
</div>
</div>
</div>
</div>
);
}
}
export class TrendingCommunitiesLoadingSkeleton extends Component<
LoadingSkeletonProps,
any
> {
render() {
return (
<div className="mb-2">
{Array.from({ length: this.props.itemCount ?? 10 }, (_, index) => (
<TrendingCommunitiesLoadingSkeletonItem key={index} />
))}
</div>
);
}
}
class TrendingCommunitiesLoadingSkeletonItem extends Component<any, any> {
render() {
return (
<div
className="col flex-grow-1 mt-2"
style={{
"padding-left": "calc(var(--bs-gutter-x) *0.5)",
"padding-right": "calc(var(--bs-gutter-x) * 1)",
}}
>
<div className="row">
<div className="col flex-grow-0 pe-0">
<div
className="d-flex placeholder-glow"
style={{ width: "1.5rem", height: "1.5rem" }}
>
<span className="placeholder placeholder-lg w-100 h-100 rounded-circle" />
</div>
</div>
<div className="col flex-grow-1 pe-0">
<LoadingSkeletonLine size={12} />
</div>
</div>
</div>
);
}
}
export class CommentsLoadingSkeleton extends Component<any, any> {
render() {
return Array.from({ length: this.props.itemCount ?? 10 }, (_, index) => (
<CommentsLoadingSkeletonItem key={index} />
));
}
}
class CommentsLoadingSkeletonItem extends Component<any, any> {
render() {
return (
<div className="col flex-grow-1 my-2 p-2">
<div className="row">
<div className="col flex-grow-1">
<LoadingSkeletonLine size={6} />
<LoadingSkeletonLine size={12} />
<LoadingSkeletonLine size={7} />
<LoadingSkeletonLine size={4} />
</div>
</div>
</div>
);
}
}