Skip to content

Commit 17cab8f

Browse files
committed
Auto merge of #3398 - Turbo87:readme-placeholder, r=pichfl
Show placeholders instead of loading spinner for the README This PR also extracts a `Placeholder` component, to make this kind of thing more reuseable :) ### Example https://user-images.githubusercontent.com/141300/110982133-6fc5bf00-8368-11eb-9d31-acc653870fb2.mov
2 parents 69d0c3f + 2ee70c9 commit 17cab8f

File tree

7 files changed

+64
-8
lines changed

7 files changed

+64
-8
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div local-class="link" ...attributes>
22
<div local-class="left">
3-
<div local-class="title"></div>
4-
{{#if @withSubtitle}}<div local-class="subtitle"></div>{{/if}}
3+
<Placeholder local-class="title" />
4+
{{#if @withSubtitle}}<Placeholder local-class="subtitle" />{{/if}}
55
</div>
66
{{svg-jar "chevron-right" local-class="right"}}
77
</div>

app/components/front-page-list/item/placeholder.module.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.link {
22
--shadow: 0 2px 3px hsla(51, 50%, 44%, .35);
3+
--placeholder-bg: hsla(59, 19%, 50%, 1.0);
4+
--placeholder-bg2: hsla(59, 19%, 50%, 0.7);
35

46
display: flex;
57
align-items: center;
@@ -23,15 +25,15 @@
2325
height: 16px;
2426
width: 150px;
2527
border-radius: 8px;
26-
background: hsla(59deg, 19%, 50%, 0.25);
28+
opacity: 0.25;
2729
}
2830

2931
.subtitle {
3032
height: 13px;
3133
width: 90px;
3234
margin-top: 4px;
3335
border-radius: 6.5px;
34-
background: hsla(59deg, 19%, 50%, 0.2);
36+
opacity: 0.2;
3537
}
3638

3739
.right {

app/components/placeholder.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div local-class="placeholder" ...attributes></div>

app/components/placeholder.module.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.placeholder {
2+
position: relative;
3+
display: block;
4+
overflow: hidden;
5+
background: linear-gradient(to right, var(--placeholder-bg) 8%, var(--placeholder-bg2) 16%, var(--placeholder-bg) 29%);
6+
background-size: 1200px 100%;
7+
animation-name: backgroundAnimation;
8+
animation-duration: 1.5s;
9+
animation-timing-function: linear;
10+
animation-iteration-count: infinite;
11+
animation-fill-mode: forwards;
12+
}
13+
14+
@keyframes backgroundAnimation {
15+
0% {
16+
background-position: -500px;
17+
}
18+
19+
100% {
20+
background-position: 500px;
21+
}
22+
}

app/styles/application.module.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
--link-color: rgb(0, 172, 91);
2222
--link-hover-color: #007940;
2323
--separator-color: #284725;
24+
25+
--placeholder-bg: hsl(212, 7%, 57%);
26+
--placeholder-bg2: hsl(213, 16%, 75%);
2427
}
2528

2629
:global(.new-design) {

app/styles/crate/version.module.css

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
}
3535
}
3636

37-
.readme-spinner,
3837
.no-readme {
3938
padding: 40px 15px;
4039
text-align: center;
@@ -47,8 +46,28 @@
4746
}
4847
}
4948

50-
.readme-spinner > div {
51-
--spinner-size: 35px;
49+
.placeholder-title {
50+
width: 30%;
51+
height: 25px;
52+
margin: 15px 0 25px;
53+
border-radius: 5px;
54+
opacity: 0.6;
55+
}
56+
57+
.placeholder-subtitle {
58+
width: 50%;
59+
height: 20px;
60+
margin: 35px 0 25px;
61+
border-radius: 5px;
62+
opacity: 0.6;
63+
}
64+
65+
.placeholder-text {
66+
width: 100%;
67+
height: 16px;
68+
margin-top: 15px;
69+
border-radius: 5px;
70+
opacity: 0.3;
5271
}
5372

5473
.sidebar {

app/templates/crate/version.hbs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@
2222
<div local-class="docs">
2323
{{#if this.loadReadmeTask.isRunning}}
2424
<div local-class="readme-spinner">
25-
<LoadingSpinner/>
25+
<Placeholder local-class="placeholder-title" />
26+
<Placeholder local-class="placeholder-text" />
27+
<Placeholder local-class="placeholder-text" />
28+
<Placeholder local-class="placeholder-text" />
29+
<Placeholder local-class="placeholder-text" />
30+
<Placeholder local-class="placeholder-text" />
31+
<Placeholder local-class="placeholder-subtitle" />
32+
<Placeholder local-class="placeholder-text" />
33+
<Placeholder local-class="placeholder-text" />
34+
<Placeholder local-class="placeholder-text" />
2635
</div>
2736
{{else if this.readme}}
2837
<article aria-label="Readme">

0 commit comments

Comments
 (0)