Skip to content

Commit 06aee0c

Browse files
committed
Header: Implement @hero mode for the index route
1 parent af38502 commit 06aee0c

File tree

8 files changed

+72
-8
lines changed

8 files changed

+72
-8
lines changed

app/components/header.hbs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
<header local-class="header">
1+
<header local-class="header {{if @hero "hero"}}">
22
<div local-class="header-inner">
33
<LinkTo @route="index" local-class="index-link">
44
<img src="/assets/Cargo-Logo-Small.png" role="presentation" alt="" local-class="logo">
55
<h1>crates.io</h1>
66
</LinkTo>
77

8-
<SearchForm local-class="search-form" />
8+
<div local-class="search-form">
9+
<h1 local-class="hero-title">
10+
The Rust community&rsquo;s crate registry
11+
</h1>
12+
13+
<SearchForm @size={{if @hero "big"}} />
14+
</div>
915

1016
<nav local-class='nav'>
1117
<LinkTo @route="crates" @query={{hash letter=null page=1}} data-test-all-crates-link>

app/components/header.module.css

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@
3232
"search search" auto /
3333
auto 1fr;
3434
}
35+
36+
.hero & {
37+
grid-template:
38+
"logo nav" auto
39+
"search search" auto /
40+
auto 1fr;
41+
42+
@media only screen and (max-width: 900px) {
43+
grid-template:
44+
"logo menu" auto
45+
"search search" auto /
46+
auto 1fr;
47+
}
48+
}
3549
}
3650

3751
.index-link {
@@ -59,6 +73,35 @@
5973
@media only screen and (max-width: 820px) {
6074
padding: 10px 0;
6175
}
76+
77+
.hero & {
78+
justify-self: center;
79+
padding: 40px 0 60px;
80+
81+
@media only screen and (max-width: 450px) {
82+
padding: 40px 0 30px;
83+
}
84+
}
85+
}
86+
87+
.hero-title {
88+
display: none;
89+
margin: 0 0 20px;
90+
font-size: 45px;
91+
color: #dfffdb;
92+
text-align: center;
93+
94+
.hero & {
95+
display: block;
96+
}
97+
98+
@media only screen and (max-width: 820px) {
99+
font-size: 30px;
100+
}
101+
102+
@media only screen and (max-width: 550px) {
103+
font-size: 24px;
104+
}
62105
}
63106

64107
.sep {
@@ -75,7 +118,7 @@
75118
grid-area: nav;
76119
display: flex;
77120
align-items: center;
78-
text-align: right;
121+
justify-self: end;
79122

80123
@media only screen and (max-width: 900px) {
81124
display: none;
@@ -84,7 +127,7 @@
84127

85128
.menu {
86129
grid-area: menu;
87-
text-align: right;
130+
justify-self: end;
88131
display: none;
89132

90133
@media only screen and (max-width: 900px) {

app/components/search-form.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<form
2-
local-class="form"
2+
local-class="form {{if (eq @size "big") "size-big"}}"
33
action="/search"
44
role="search"
55
data-test-search-form

app/components/search-form.module.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
box-shadow: none;
1818
transition: box-shadow 150ms;
1919

20+
.size-big & {
21+
font-size: 125%;
22+
padding: 5px 5px 5px 35px;
23+
background-position: 10px 7px;
24+
background-size: 20px 21px;
25+
}
26+
2027
&:focus {
2128
outline: none;
2229
box-shadow: 0 0 0 4px var(--yellow500);

app/controllers/application.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@ import { inject as service } from '@ember/service';
44
export default class ApplicationController extends Controller {
55
@service design;
66
@service progress;
7+
@service router;
8+
9+
get isIndex() {
10+
return this.router.currentRouteName === 'index';
11+
}
712
}

app/styles/index.module.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
.title-header {
22
text-align: center;
33
border-bottom: 5px solid var(--gray-border);
4+
margin-top: 25px;
45
padding-bottom: 40px;
56

7+
@media only screen and (max-width: 570px) {
8+
margin-top: 0;
9+
}
10+
611
h1 {
712
font-size: 50px;
813
@media only screen and (max-width: 370px) {

app/templates/application.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ProgressBar/>
66
<NotificationContainer @position="top-right"/>
77

8-
<Header/>
8+
<Header @hero={{this.isIndex}} />
99

1010
<main local-class="main">
1111
<div local-class="inner-main">

app/templates/index.hbs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<div local-class='title-header'>
2-
<h1>The Rust community&rsquo;s crate registry</h1>
3-
42
<div local-class='links'>
53
<a href="https://doc.rust-lang.org/cargo/getting-started/installation.html" local-class="hero-button" data-test-install-cargo-link>
64
{{svg-jar "download-arrow" local-class="icon"}}

0 commit comments

Comments
 (0)