Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
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;
}
}
62 changes: 33 additions & 29 deletions landing-pages/site/layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -1,44 +1,48 @@
{{/*
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
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
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.
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.
*/}}

<!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>
<script src="{{ relURL .main.js }}"></script>
{{ end }}
</html>

</html>
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>
6 changes: 6 additions & 0 deletions landing-pages/site/layouts/partials/suggest-change.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@
{{ partial "buttons/button-with-icon" (dict "text" "Suggest a change on this page" "class" "button-fixed") }}
</a>
</div>

<!-- Scroll to Top Button -->
<button id="scrollToTopBtn"></button>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think this code should be added here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay , can i add new section for this button ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think it would be best to implement it in a way similar to "Suggest a change on this page" button.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @choo121600 i have added new section for the button . please review it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the scrollToTop button belongs in landing-pages/site/layouts/partials/suggest-change.html.
since they serve different functions.



7 changes: 4 additions & 3 deletions landing-pages/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
* under the License.
*/

import {shuffleNodeChildren} from "./js/committersList";
import {showMore} from "./js/showMore";
import {handleActiveVideo} from "./js/handleActiveVideo";
import { shuffleNodeChildren } from "./js/committersList";
import { showMore } from "./js/showMore";
import { handleActiveVideo } from "./js/handleActiveVideo";
import "./js/navbarScroll";
import "./js/drawer";
import "./js/contentDrawer";
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 1200px threshold
const scrollToTopBtn = document.getElementById('scrollToTopBtn');
const scrollThreshold = 1200;

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();
Loading
Loading