Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: anchor links top scroll #903

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sphinx_scylladb_theme/static/css/main.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sphinx_scylladb_theme/static/js/main.bundle.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/css/base/_reset.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
html {
box-sizing: border-box;
scroll-padding-top: 100px;
}

body {
Expand Down
30 changes: 0 additions & 30 deletions src/css/components/_content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
padding: 20px;
margin-top: $header-height;
max-width: $max-content-width;
scroll-margin-top: $header-height;
width: 100%;

p,
Expand Down Expand Up @@ -54,11 +53,6 @@
margin-bottom: $gap;
}

section {
margin-top: -$header-height;
padding-top: $header-height;
}

.inline-icon.fa-check {
color: $color-typography-icon-checkmark;
}
Expand Down Expand Up @@ -86,15 +80,6 @@
margin-left: 0;
}

.layout--has-banner .content {
scroll-margin-top: $promo-banner-header-height;

section {
margin-top: -$promo-banner-header-height;
padding-top: $promo-banner-header-height;
}
}

.landing__content {
padding: 0 16px;
}
Expand All @@ -105,13 +90,7 @@
padding-bottom: 100px;
margin-left: $secondary-side-nav-width;
margin-top: $header-height-large;
scroll-margin-top: $header-height-large;
width: calc(100% - #{$secondary-side-nav-width});

section {
margin-top: -$header-height-large;
padding-top: $header-height-large;
}
}
}

Expand All @@ -134,15 +113,6 @@
margin-bottom: 10px;
}

.layout--has-banner .content {
scroll-margin-top: $promo-banner-header-height-large;

section {
margin-top: -$promo-banner-header-height-large;
padding-top: $promo-banner-header-height-large;
}
}

.landing {
&__content {
padding: 0 60px;
Expand Down
8 changes: 8 additions & 0 deletions src/js/body.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
export const adjustScrollPaddingTop= () => {
var promoBannerDisplay = $('.promo-banner').css('display');
var promoBannerHeight = promoBannerDisplay !== 'none' ? $('.promo-banner').outerHeight(true) : 0;
var headerHeight = $('.header').outerHeight(true);
var totalHeight = promoBannerHeight + headerHeight + 10;
$('html').css('scroll-padding-top', totalHeight + 'px');
}

export const openExternalLinksNewBrowserTab = () => {
const isExternal = new RegExp("^(?:[a-z]+:)?//", "i");
$("a.reference").each(function () {
Expand Down
2 changes: 2 additions & 0 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require("../css/main.scss");
require("foundation-sites/dist/js/foundation");

import {
adjustScrollPaddingTop,
createEnlargeImagesButtons,
createResponsiveTables,
openExternalLinksNewBrowserTab,
Expand All @@ -26,6 +27,7 @@ import {

$(document).ready(function () {
/* Body */
adjustScrollPaddingTop();
createEnlargeImagesButtons();
$(document).foundation();
createResponsiveTables();
Expand Down