Skip to content
Open
42 changes: 42 additions & 0 deletions landing-pages/site/assets/scss/_scroll-to-top.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/* Scroll to Top Button Styles */

#scrollToTopBtn {
position: fixed;
bottom: 120px;
right: 40px;
background-color: #017cee;
color: white;
border: none;
border-radius: 50%;
width: 50px;
height: 50px;
padding: 0;
font-size: 24px;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
transition: opacity 0.3s ease-in-out, background-color 0.3s ease, transform 0.2s ease;
z-index: 1000;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}
3 changes: 2 additions & 1 deletion landing-pages/site/assets/scss/main-custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
@import "survey";
@import "testimonial";
@import "suggest-change";
@import "scroll-to-top";

/* Blog Snippet Section */
.blog-snippet-list {
Expand Down Expand Up @@ -101,4 +102,4 @@
.blog-snippet-item time {
font-size: 0.8rem;
opacity: 0.7;
}
}
30 changes: 17 additions & 13 deletions landing-pages/site/layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,30 @@

<!doctype html>
<html lang="{{ .Site.Language.Lang }}" class="no-js">

<head>
{{ partial "head.html" . }}
</head>

<body class="td-{{ .Kind }}">
<header>
{{ partial "navbar.html" . }}
</header>
<div class="container-fluid td-default">
{{ block "animation-header" . }}{{ end }}
<div class="home-page-layout base-layout">
<main role="main" class="td-main container">
{{ block "main" . }}{{ end }}
</main>
{{ partial "suggest-change" . }}
<header>
{{ partial "navbar.html" . }}
</header>
<div class="container-fluid td-default">
{{ block "animation-header" . }}{{ end }}
<div class="home-page-layout base-layout">
<main role="main" class="td-main container">
{{ block "main" . }}{{ end }}
</main>
{{ partial "suggest-change" . }}
{{ partial "page-scroll-button.html" . }}
</div>
</div>
</div>
{{ partialCached "footer.html" . }}
{{ partial "scripts.html" . }}
{{ partialCached "footer.html" . }}
{{ partial "scripts.html" . }}
</body>
{{ with .Site.Data.webpack }}
<script src="{{ relURL .main.js }}"></script>
{{ end }}

</html>
1 change: 1 addition & 0 deletions landing-pages/site/layouts/blog/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
{{ block "main" . }}{{ end }}
</main>
{{ partial "suggest-change" . }}
{{ partial "page-scroll-button.html" . }}
</div>
</div>
{{ partialCached "footer.html" . }}
Expand Down
1 change: 1 addition & 0 deletions landing-pages/site/layouts/community/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
{{ block "main" . }}{{ end }}
</main>
{{ partial "suggest-change" . }}
{{ partial "page-scroll-button.html" . }}
</div>
</div>
{{ partialCached "footer.html" . }}
Expand Down
1 change: 1 addition & 0 deletions landing-pages/site/layouts/docs/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
</main>
</div>
{{ partial "suggest-change" . }}
{{ partial "page-scroll-button.html" . }}
</div>
{{ partialCached "footer.html" . }}
{{ partial "scripts.html" . }}
Expand Down
1 change: 1 addition & 0 deletions landing-pages/site/layouts/install/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
{{ block "main" . }}{{ end }}
</main>
{{ partial "suggest-change" . }}
{{ partial "page-scroll-button.html" . }}
</div>
</div>
{{ partialCached "footer.html" . }}
Expand Down
1 change: 1 addition & 0 deletions landing-pages/site/layouts/meetups/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
{{ block "main" . }}{{ end }}
</main>
{{ partial "suggest-change" . }}
{{ partial "page-scroll-button.html" . }}
</div>
</div>
{{ partialCached "footer.html" . }}
Expand Down
26 changes: 26 additions & 0 deletions landing-pages/site/layouts/partials/page-scroll-button.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/}}

<button id="scrollToTopBtn" title="Go to top" style="display: none;">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-up">
<line x1="12" y1="19" x2="12" y2="5"></line>
<polyline points="5 12 12 5 19 12"></polyline>
</svg>
</button>
15 changes: 8 additions & 7 deletions landing-pages/site/layouts/partials/suggest-change.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/}}
under the License.]
*/}}

<div class="base-layout--button">
{{ $url := printf "https://github.com/apache/airflow-site/edit/main/landing-pages/site/content/%s/%s" $.Site.Language.Lang .Path }}
<a href={{ $url }}>
{{ partial "buttons/button-with-icon" (dict "text" "Suggest a change on this page" "class" "button-fixed") }}
</a>
</div>
{{ $url := printf "https://github.com/apache/airflow-site/edit/main/landing-pages/site/content/%s/%s"
$.Site.Language.Lang .Path }}
<a href={{ $url }}>
{{ partial "buttons/button-with-icon" (dict "text" "Suggest a change on this page" "class" "button-fixed") }}
</a>
</div>
1 change: 1 addition & 0 deletions landing-pages/site/layouts/privacy-notice/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
</main>
</div>
{{ partial "suggest-change" . }}
{{ partial "page-scroll-button.html" . }}
</div>
{{ partialCached "footer.html" . }}
{{ partial "scripts.html" . }}
Expand Down
1 change: 1 addition & 0 deletions landing-pages/site/layouts/roadmap/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
</main>
</div>
{{ partial "suggest-change" . }}
{{ partial "page-scroll-button.html" . }}
</div>
{{ partialCached "footer.html" . }}
{{ partial "scripts.html" . }}
Expand Down
1 change: 1 addition & 0 deletions landing-pages/site/layouts/taxonomy/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
{{ block "main" . }}{{ end }}
</main>
{{ partial "suggest-change" . }}
{{ partial "page-scroll-button.html" . }}
</div>
</div>
{{ partialCached "footer.html" . }}
Expand Down
1 change: 1 addition & 0 deletions landing-pages/site/layouts/use-cases/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
{{ block "main" . }}{{ end }}
</main>
{{ partial "suggest-change" . }}
{{ partial "page-scroll-button.html" . }}
</div>
</div>
{{ partialCached "footer.html" . }}
Expand Down
1 change: 1 addition & 0 deletions landing-pages/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import "./js/progressTracking";
import "./js/rating";
import "./js/makeTableResponsive";
import "./js/versionSelector";
import "./js/scroll-to-top";

if (document.querySelector("#search")) {
import(/* webpackChunkName: "search" */ "./js/searchBlogPosts");
Expand Down
77 changes: 77 additions & 0 deletions landing-pages/src/js/scroll-to-top.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/


// Enabled button with 1000px threshold
const scrollToTopBtn = document.getElementById('scrollToTopBtn');
const scrollThreshold = 1000;

function toggleScrollToTopButton() {
if (!scrollToTopBtn) return;

const scrollPosition = document.documentElement.scrollTop || document.body.scrollTop;

if (scrollPosition <= scrollThreshold) {
if (scrollToTopBtn.style.opacity !== '0' && scrollToTopBtn.style.display !== 'none') {
scrollToTopBtn.style.opacity = '0';
setTimeout(() => scrollToTopBtn.style.display = 'none', 300);
}
} else {
if (scrollToTopBtn.style.display === 'none') {
scrollToTopBtn.style.display = 'flex';
setTimeout(() => scrollToTopBtn.style.opacity = '1', 10);
}
}
}

function scrollToTop() {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
}

window.addEventListener('scroll', toggleScrollToTopButton);
scrollToTopBtn.addEventListener('click', scrollToTop);

scrollToTopBtn.onmouseover = function () {
this.style.backgroundColor = '#0056b3';
this.style.transform = 'scale(1.1)';
};

scrollToTopBtn.onmouseout = function () {
this.style.backgroundColor = '#007bff';
this.style.transform = 'scale(1)';
};

scrollToTopBtn.addEventListener('mousedown', function () {
this.style.border = '1.5px solid lightgreen';
});
scrollToTopBtn.addEventListener('mouseup', function () {
this.style.border = 'none';
});

scrollToTopBtn.addEventListener('focus', function () {
this.style.outline = '1px solid lightblue';
});
scrollToTopBtn.addEventListener('blur', function () {
this.style.outline = 'none';
});

toggleScrollToTopButton();
2 changes: 1 addition & 1 deletion landing-pages/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7547,4 +7547,4 @@ yocto-queue@^1.0.0:
zod@^3.25.51:
version "3.25.76"
resolved "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz"
integrity sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==
integrity sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==