Skip to content

Commit 2ff6382

Browse files
authored
feat: use the search box in place of the page header (#39)
1 parent 5acc629 commit 2ff6382

File tree

4 files changed

+59
-18
lines changed

4 files changed

+59
-18
lines changed

api/detail.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,18 @@ module.exports = async (request, response) => {
117117
<link rel="stylesheet" href="/style.css" />
118118
</head>
119119
<body>
120-
<h1>octokit.rest</h1>
120+
<header>
121+
<h2>octokit.rest</h2>
122+
</header>
121123
122124
<div id="search">
123125
${search({ query: `${endpoint.method} ${endpoint.url}` })}
124126
</div>
125127
126-
<div id="details">
128+
<main id="details" class="details">
127129
128130
<section>
129-
<h2>${endpoint.name} (<code>${route}</code>)</h2>
131+
<h2>${endpoint.name}</h2>
130132
131133
${markdown.render(endpoint.description)}
132134
</section>
@@ -177,7 +179,7 @@ module.exports = async (request, response) => {
177179
endpoint.documentationUrl
178180
}">GitHub developer guides</a></p>
179181
180-
</div>
182+
</main>
181183
182184
<script type="module" src="/detail.js"></script>
183185
<script type="module" src="/search.js"></script>

api/search.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ module.exports = async (request, response) => {
5757
<link rel="stylesheet" href="/style.css" />
5858
</head>
5959
<body>
60-
<h1>octokit.rest</h1>
60+
<header>
61+
<h2>octokit.rest</h2>
62+
</header>
6163
6264
<div id="search">
6365
${search({ query, results })}

public/components/search.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ export function search({ query, results }) {
66
const resultsHTML = searchResults({ query, results });
77

88
return `
9-
<form action="/">
10-
<label>
11-
What would you like to request?<br />
12-
<input type="text" value="${query}" name="query" autocomplete="off" />
13-
</label>
9+
<form action="/" class="search">
10+
<h1>
11+
<label class="has-placeholder">
12+
<span>What would you like to request?</span><br />
13+
<input type="text" value="${query}" name="query" placeholder="Type your search here" autocomplete="off" />
14+
</label>
15+
</h1>
1416
<button type="submit">Go</button>
1517
</form>
1618
17-
<div id="results">
19+
<div id="results" class="results">
1820
${resultsHTML}
1921
</div>
2022
`;

public/style.css

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,14 @@ body {
1111
font-family: "Helvetica Neue", Helvetica, sans-serif;
1212
font-size: 100%;
1313
line-height: 1.5;
14+
padding: 3vw;
1415
}
1516

1617
/* Color */
1718
a {
1819
color: hsl(210, 53%, 51%);
1920
}
2021

21-
/* Layout */
22-
body > * {
23-
margin: 3rem auto;
24-
padding: 1.5rem;
25-
max-width: 45rem;
26-
}
27-
2822
/* Form */
2923
input {
3024
font-size: inherit;
@@ -37,13 +31,24 @@ input {
3731
input {
3832
margin-top: 0.375em;
3933
}
34+
input:focus::placeholder {
35+
color: hsl(0, 0%, 75%);
36+
}
4037
button {
4138
font-size: inherit;
4239
font-family: inherit;
4340
border: 1px solid hsl(0, 0%, 75%);
4441
padding: 0.375em 0.75em;
4542
}
4643

44+
45+
label.has-placeholder > span,
46+
label.has-placeholder > br {
47+
/* @hidden-accessible */
48+
position: absolute;
49+
left: -9999px;
50+
}
51+
4752
/* Code */
4853
pre {
4954
border: 1px solid hsl(0, 0%, 79%);
@@ -129,3 +134,33 @@ td {
129134
.note > :last-child {
130135
margin-bottom: 0;
131136
}
137+
138+
/* Header */
139+
body > header {
140+
/* @hidden-accessible */
141+
position: absolute;
142+
left: -9999px;
143+
}
144+
form h1 {
145+
font: inherit;
146+
margin: 0;
147+
display: inline;
148+
}
149+
150+
/* Search */
151+
.search {
152+
font-size: 3vw;
153+
margin-bottom: 1.5em;
154+
margin-left: calc(-0.75em - 1px);
155+
}
156+
157+
/* Details */
158+
.details {
159+
margin-left: -1.5rem;
160+
margin-right: -1.5rem;
161+
}
162+
.details > * {
163+
margin: 3rem auto;
164+
padding: 1.5rem;
165+
max-width: 45rem;
166+
}

0 commit comments

Comments
 (0)