Skip to content

Commit

Permalink
Auto merge of #3333 - Turbo87:header-description, r=locks
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Feb 26, 2021
2 parents 4d8b9e3 + 036e953 commit 575b2fb
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 12 deletions.
5 changes: 5 additions & 0 deletions app/components/crate-header.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<FollowButton @crate={{@crate}}/>
{{/if}}
</div>
{{#if @crate.description}}
<div local-class="description">
{{@crate.description}}
</div>
{{/if}}
</PageHeader>

<NavTabs aria-label="{{@crate.name}} crate subpages" local-class="nav" as |nav|>
Expand Down
5 changes: 5 additions & 0 deletions app/components/crate-header.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
height: 32px;
}

.description {
margin-top: 15px;
line-height: 1.35;
}

.nav {
margin-bottom: 20px;
}
11 changes: 6 additions & 5 deletions app/components/loading-spinner.module.css
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
.spinner {
--spinner-color: black;
--spinner-bg-color: rgba(0, 0, 0, .2);
--spinner-size: 16px;

display: inline-block;
height: 16px;
width: 16px;
height: var(--spinner-size);
width: var(--spinner-size);

&:after {
content: " ";
display: block;
box-sizing: border-box;
width: 16px;
height: 16px;
width: var(--spinner-size);
height: var(--spinner-size);
border-radius: 50%;
border: 3px solid var(--spinner-color);
border: calc(var(--spinner-size) / 5.5) solid var(--spinner-color);
border-color: var(--spinner-bg-color) var(--spinner-bg-color) var(--spinner-color) var(--spinner-bg-color);
animation: spinner 1.2s linear infinite;
}
Expand Down
17 changes: 17 additions & 0 deletions app/styles/crate/version.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@
margin-bottom: 20px;
}

.readme-spinner,
.no-readme {
padding: 40px 15px;
text-align: center;
font-size: 20px;
font-weight: 300;

code {
font-size: 18px;
font-weight: 500;
}
}

.readme-spinner > div {
--spinner-size: 35px;
}

.crate-downloads {
display: flex;
flex-wrap: wrap;
Expand Down
15 changes: 8 additions & 7 deletions app/templates/crate/version.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@
one that has not been yanked.
</p>
{{else}}
{{#if this.readme}}
{{#if this.loadReadmeTask.isRunning}}
<div local-class="readme-spinner">
<LoadingSpinner/>
</div>
{{else if this.readme}}
<article aria-label="Readme">
<RenderedHtml @html={{this.readme}} local-class="readme" />
</article>
{{else}}
{{#if this.crate.description}}
<div local-class='about'>
<h3>About This Package</h3>
<p>{{ this.crate.description }}</p>
</div>
{{/if}}
<div local-class="no-readme">
{{this.crate.name}} v{{this.currentVersion.num}} appears to have no <code>README.md</code> file
</div>
{{/if}}
{{/if}}
</div>
Expand Down

0 comments on commit 575b2fb

Please sign in to comment.