Skip to content

Commit 575b2fb

Browse files
committed
Auto merge of #3333 - Turbo87:header-description, r=locks
Display crate description in the `CrateHeader` component <img width="1127" alt="Bildschirmfoto 2021-02-25 um 18 52 09" src="https://user-images.githubusercontent.com/141300/109195299-a4e3e600-779a-11eb-9211-724bf0b37fd7.png"> This makes it easier to figure out on first glance what a crate does, without having to wait for and read through the README text.
2 parents 4d8b9e3 + 036e953 commit 575b2fb

File tree

5 files changed

+41
-12
lines changed

5 files changed

+41
-12
lines changed

Diff for: app/components/crate-header.hbs

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
<FollowButton @crate={{@crate}}/>
1313
{{/if}}
1414
</div>
15+
{{#if @crate.description}}
16+
<div local-class="description">
17+
{{@crate.description}}
18+
</div>
19+
{{/if}}
1520
</PageHeader>
1621

1722
<NavTabs aria-label="{{@crate.name}} crate subpages" local-class="nav" as |nav|>

Diff for: app/components/crate-header.module.css

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
height: 32px;
3131
}
3232

33+
.description {
34+
margin-top: 15px;
35+
line-height: 1.35;
36+
}
37+
3338
.nav {
3439
margin-bottom: 20px;
3540
}

Diff for: app/components/loading-spinner.module.css

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
.spinner {
22
--spinner-color: black;
33
--spinner-bg-color: rgba(0, 0, 0, .2);
4+
--spinner-size: 16px;
45

56
display: inline-block;
6-
height: 16px;
7-
width: 16px;
7+
height: var(--spinner-size);
8+
width: var(--spinner-size);
89

910
&:after {
1011
content: " ";
1112
display: block;
1213
box-sizing: border-box;
13-
width: 16px;
14-
height: 16px;
14+
width: var(--spinner-size);
15+
height: var(--spinner-size);
1516
border-radius: 50%;
16-
border: 3px solid var(--spinner-color);
17+
border: calc(var(--spinner-size) / 5.5) solid var(--spinner-color);
1718
border-color: var(--spinner-bg-color) var(--spinner-bg-color) var(--spinner-color) var(--spinner-bg-color);
1819
animation: spinner 1.2s linear infinite;
1920
}

Diff for: app/styles/crate/version.module.css

+17
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,23 @@
3131
margin-bottom: 20px;
3232
}
3333

34+
.readme-spinner,
35+
.no-readme {
36+
padding: 40px 15px;
37+
text-align: center;
38+
font-size: 20px;
39+
font-weight: 300;
40+
41+
code {
42+
font-size: 18px;
43+
font-weight: 500;
44+
}
45+
}
46+
47+
.readme-spinner > div {
48+
--spinner-size: 35px;
49+
}
50+
3451
.crate-downloads {
3552
display: flex;
3653
flex-wrap: wrap;

Diff for: app/templates/crate/version.hbs

+8-7
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@
1414
one that has not been yanked.
1515
</p>
1616
{{else}}
17-
{{#if this.readme}}
17+
{{#if this.loadReadmeTask.isRunning}}
18+
<div local-class="readme-spinner">
19+
<LoadingSpinner/>
20+
</div>
21+
{{else if this.readme}}
1822
<article aria-label="Readme">
1923
<RenderedHtml @html={{this.readme}} local-class="readme" />
2024
</article>
2125
{{else}}
22-
{{#if this.crate.description}}
23-
<div local-class='about'>
24-
<h3>About This Package</h3>
25-
<p>{{ this.crate.description }}</p>
26-
</div>
27-
{{/if}}
26+
<div local-class="no-readme">
27+
{{this.crate.name}} v{{this.currentVersion.num}} appears to have no <code>README.md</code> file
28+
</div>
2829
{{/if}}
2930
{{/if}}
3031
</div>

0 commit comments

Comments
 (0)