Skip to content

Commit f73cdf9

Browse files
committed
WIP: responsive header
Make the header more responsive using flexbox and use less `position: absolute`. Signed-off-by: Toon Claes <[email protected]>
1 parent e255fbb commit f73cdf9

File tree

7 files changed

+63
-47
lines changed

7 files changed

+63
-47
lines changed

assets/js/application.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ var DarkMode = {
567567
|| (!prefersDarkScheme && currentTheme === "dark")) {
568568
button.attr("src", `${baseURLPrefix}images/light-mode.svg`);
569569
}
570-
button.show();
570+
button.css("display", "block");
571571

572572
button.click(function(e) {
573573
e.preventDefault();

assets/sass/application.scss

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,12 @@ pre {
5454

5555
#dark-mode-button {
5656
display: none;
57-
z-index: 10;
58-
position: absolute;
59-
top: 6px;
60-
right: -50px;
61-
width: 35px;
57+
width: 28px;
58+
padding: calc((#{$search-container-height} - 28px) / 2);
6259
background-color: transparent;
6360
text-decoration: none;
61+
align-self: flex-start;
62+
margin-right: 5px;
6463
}
6564

6665
@media (max-width: $default + 100) {

assets/sass/forms.scss

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ input, textarea {
3232

3333
form#search {
3434
position: absolute;
35-
top: 10px;
35+
top: 7px;
3636
right: 0;
37+
left: 15px;
3738
z-index: 1000;
38-
width: 262px;
39+
width: calc(100% - 32px - 32px);
3940
padding-left: 32px;
4041
@include background-image-2x($baseurl + "images/icons/search", 17px, 17px, 10px 50%);
4142
background-color: var(--main-bg) !important;
@@ -63,17 +64,12 @@ form#search {
6364
// Breakpoint ----------------
6465
@media (max-width: $default) {
6566
form#search{
66-
@include center-transformX;
67-
margin-top: 7px;
68-
top: unset;
69-
width: 92%;
7067
}
7168
}
7269

7370
// Mobile
7471
@media (max-width: $mobile-m) {
7572
form#search{
76-
width: 84%;
7773
#search-text {
7874
padding: 0.3rem 0.1rem;
7975
}

assets/sass/layout.scss

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,25 @@ aside {
110110

111111
// Header
112112
header {
113-
position: relative;
114113
padding-bottom: 26px;
115114
margin-top: 14px;
116115

116+
display: flex;
117+
flex-direction: row;
118+
119+
div {
120+
display: flex;
121+
flex-direction: row;
122+
123+
&:first-child {
124+
flex-grow: 4;
125+
}
126+
}
127+
117128
#tagline {
118-
position: absolute;
119-
top: 11px;
120-
left: 120px;
121129
display: block;
122-
margin-top: 1px;
130+
margin-top: 6px;
131+
margin-left: 8px;
123132
font-size: 24px;
124133
line-height: 24px;
125134
color: var(--light-font-color);
@@ -439,13 +448,11 @@ table.benchmarks {
439448
.responsive-table { overflow-x: auto; }
440449
.center img { height: 100%; }
441450
header{
442-
padding-bottom: 2.5rem;
443451
a, span {
444452
padding-left: 1rem;
445453
margin-bottom: 10px ;
446454
}
447455
}
448-
#home { .inner { > header { padding-bottom: 2rem; } } }
449456
#content { width: 100%; }
450457
.inner { width: 100%; }
451458
#content-wrapper { padding: 0.8rem; }
@@ -485,6 +492,7 @@ table.benchmarks {
485492
top: 0;
486493
padding-right: 1rem;
487494
}
495+
flex-direction: column;
488496
}
489497
#home { .inner { > header { padding-bottom: 2.5rem; } } }
490498
#masthead {

assets/sass/search.scss

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
@import "variables";
22
@import "mixins";
33

4+
#search-container {
5+
position: relative;
6+
height: $search-container-height;
7+
width: 300px;
8+
}
9+
410
#search-results {
511
position: absolute;
6-
top: 2px;
12+
top: -4px;
713
right: -8px;
814
z-index: 900;
915
display: none;
@@ -132,13 +138,15 @@ ol.full-search-results {
132138
// Breakpoint ---
133139
@media (max-width: $default) {
134140
#search-results{
135-
@include center-transformX;
136-
top: unset;
137-
width: 98%;
141+
width: 100%;
138142
}
139143
}
140144
// Mobile
141145
@media (max-width: $mobile-m) {
146+
#search-container {
147+
width: inherit;
148+
margin-left: 15px;
149+
}
142150
#search-results{
143151
margin-top: 4px;
144152
}

assets/sass/variables.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ $base-font-size: 14px;
1212
$base-line-height: 22px;
1313

1414
$fixed-width-font-family: Courier, monospace;
15-
$fixed-width-line-height: 18px;
15+
$fixed-width-line-height: 18px;
16+
$search-container-height: 44px;

layouts/partials/header.html

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
<header>
2+
<div id="brand">
3+
<a href="{{ relURL "" }}"><img src="{{ relURL "images/[email protected]" }}" width="110" height="46" alt="Git" class="no-filter" /></a>
4+
<span id="tagline"></span>
5+
<script type="text/javascript">
6+
const taglines = [
7+
"fast-version-control",
8+
"everything-is-local",
9+
"distributed-even-if-your-workflow-isnt",
10+
"local-branching-on-the-cheap",
11+
"distributed-is-the-new-centralized"
12+
];
13+
var tagline = taglines[Math.floor(Math.random() * taglines.length)];
14+
document.getElementById('tagline').innerHTML = '--' + tagline;
15+
</script>
16+
</div>
217

3-
<a href="{{ relURL "" }}"><img src="{{ relURL "images/[email protected]" }}" width="110" height="46" alt="Git" class="no-filter" /></a>
4-
<span id="tagline"></span>
5-
<script type="text/javascript">
6-
const taglines = [
7-
"fast-version-control",
8-
"everything-is-local",
9-
"distributed-even-if-your-workflow-isnt",
10-
"local-branching-on-the-cheap",
11-
"distributed-is-the-new-centralized"
12-
];
13-
var tagline = taglines[Math.floor(Math.random() * taglines.length)];
14-
document.getElementById('tagline').innerHTML = '--' + tagline;
15-
</script>
16-
17-
<img src="{{ relURL "images/dark-mode.svg" }}" id="dark-mode-button" />
18-
{{ if ne (.Scratch.Get "section") "search" }}
19-
<form id="search" action="{{ relURL "search/results" }}">
20-
<input id="search-text" name="search" placeholder="Type / to search entire site…" autocomplete="off" type="text" />
21-
</form>
22-
<div id="search-results"></div>
23-
{{ end }}
24-
18+
<div>
19+
{{ if ne (.Scratch.Get "section") "search" }}
20+
<div id="search-container">
21+
<form id="search" action="{{ relURL "search/results" }}">
22+
<input id="search-text" name="search" placeholder="Type / to search entire site…" autocomplete="off" type="text" />
23+
</form>
24+
<div id="search-results"></div>
25+
</div>
26+
{{ end }}
27+
<img src="{{ relURL "images/dark-mode.svg" }}" id="dark-mode-button" />
28+
</div>
2529
</header>

0 commit comments

Comments
 (0)