Skip to content

Commit 173be24

Browse files
committed
deprecate $masthead-height variable, use automatic padding instead in case of height overflows
1 parent 176e565 commit 173be24

File tree

4 files changed

+32
-17
lines changed

4 files changed

+32
-17
lines changed

_sass/layout/_masthead.scss

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
.masthead {
66
position: fixed;
77
background: var(--global-bg-color);
8-
border-bottom: 1px solid var(--global-border-color);
9-
height: $masthead-height;
8+
height: fit-content;
109
top: 0;
1110
width: 100%;
1211

@@ -16,10 +15,19 @@
1615
animation-delay: 0.15s;
1716
z-index: 20;
1817

18+
&::after {
19+
content: "";
20+
position: absolute;
21+
bottom: 0;
22+
height: 1px;
23+
background: var(--global-border-color);
24+
width: 100%;
25+
}
26+
1927
&__inner-wrap {
2028
@include container;
2129
@include clearfix;
22-
padding: 1em 1em 1em;
30+
padding: 0.5em 1em;
2331
font-family: $sans-serif-narrow;
2432

2533
@include breakpoint($x-large) {

_sass/layout/_sidebar.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
@include clearfix();
1414
margin-bottom: 1em;
15-
15+
1616
@media (orientation: portrait) {
17-
margin-top: 5em;
17+
margin-top: 1em;
1818
}
1919

2020
@media screen and (min-width: $sidebar-screen-min-width) {

assets/js/main.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/plugins/jquery.greedy-navigation.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function updateNav() {
1717
var availableSpace = $btn.hasClass('hidden') ? $nav.width() : $nav.width() - $btn.width() - 30;
1818

1919
// The visible list is overflowing the nav
20-
if($vlinks.width() > availableSpace) {
20+
if ($vlinks.width() > availableSpace) {
2121

2222
while ($vlinks.width() > availableSpace && $vlinks.children('*:not(.masthead__menu-item--lg)').length > 0) {
2323

@@ -27,26 +27,24 @@ function updateNav() {
2727
// Move item to the hidden list
2828
$vlinks.children('*:not(.masthead__menu-item--lg)').last().prependTo($hlinks);
2929

30-
availableSpace = $btn.hasClass('hidden') ? $nav.width() : $nav.width() - $btn.width() - 30;
31-
30+
availableSpace = $btn.hasClass("hidden") ? $nav.width() : $nav.width() - $btn.width() - 30;
31+
3232
// Show the dropdown btn
33-
if($btn.hasClass('hidden')) {
34-
$btn.removeClass('hidden');
35-
}
33+
$btn.removeClass("hidden");
3634
}
3735

3836
// The visible list is not overflowing
3937
} else {
4038

4139
// There is space for another item in the nav
42-
while(breaks.length > 0 && availableSpace > breaks[breaks.length-1]) {
40+
while (breaks.length > 0 && availableSpace > breaks[breaks.length - 1]) {
4341
// Move the item to the visible list
4442
$hlinks.children().first().appendTo($vlinks);
4543
breaks.pop();
4644
}
4745

4846
// Hide the dropdown btn if hidden list is empty
49-
if(breaks.length < 1) {
47+
if (breaks.length < 1) {
5048
$btn.addClass('hidden');
5149
$btn.removeClass('close');
5250
$hlinks.addClass('hidden');
@@ -56,18 +54,27 @@ function updateNav() {
5654
// Keep counter updated
5755
$btn.attr("count", breaks.length);
5856

57+
// update masthead height and the body/sidebar top padding
58+
var mastheadHeight = $('.masthead').height();
59+
$('body').css('padding-top', mastheadHeight + 'px');
60+
if ($(".author__urls-wrapper button").is(":visible")) {
61+
$(".sidebar").css("padding-top", "");
62+
} else {
63+
$(".sidebar").css("padding-top", mastheadHeight + "px");
64+
}
65+
5966
}
6067

6168
// Window listeners
6269

63-
$(window).on('resize', function() {
70+
$(window).on('resize', function () {
6471
updateNav();
6572
});
66-
screen.orientation.addEventListener("change", function(){
73+
screen.orientation.addEventListener("change", function () {
6774
updateNav();
6875
});
6976

70-
$btn.on('click', function() {
77+
$btn.on('click', function () {
7178
$hlinks.toggleClass('hidden');
7279
$(this).toggleClass('close');
7380
});

0 commit comments

Comments
 (0)