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

Add Scroll to top button #1890

Merged
merged 1 commit into from
Jul 22, 2024
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: 0 additions & 2 deletions src/components/client/faq/FaqPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import React, { useMemo, useState } from 'react'
import Layout from 'components/client/layout/Layout'

import ContactUs from './ContactUs'
import ScrollToTop from './ScrollToTop'
import VerticalTabs from './VerticalTabs'
import ExpandableListItem from './ExpandableListItem'
import {
Expand Down Expand Up @@ -81,7 +80,6 @@ export default function FaqPage({ section }: Props) {
</Stack>
</TabContext>
<ContactUs />
<ScrollToTop />
</Layout>
)
}
2 changes: 2 additions & 0 deletions src/components/client/layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import DetailsModal from 'components/admin/modal/DetailsModal'

import AppNavBar from './AppNavBar'
import MobileNav from './nav/MobileNav/MobileNav'
import ScrollToTop from './ScrollToTop'

const createPageTitle = (suffix: string, title?: string) => {
if (title) {
Expand Down Expand Up @@ -135,6 +136,7 @@ export default function Layout({
<DetailsModal />
</Container>
{!hideFooter && <Footer />}
<ScrollToTop />
</Container>
)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useEffect, useState } from 'react'

import { ArrowCircleUp } from '@mui/icons-material'
import { Box } from '@mui/material'

Expand All @@ -8,7 +9,7 @@ const ScrollToTop = () => {
const [isVisible, setIsVisible] = useState(false)

const toggleVisibility = () => {
if (window.pageYOffset > 300) {
if (window.pageYOffset > 700) {
setIsVisible(true)
} else {
setIsVisible(false)
Expand All @@ -31,10 +32,19 @@ const ScrollToTop = () => {
<div>
{isVisible && (
<Box
sx={{ position: 'fixed', cursor: 'pointer', right: '6rem', bottom: '0.6rem' }}
sx={{
position: 'fixed',
cursor: 'pointer',
right: theme.spacing(3),
bottom: theme.spacing(2),
}}
onClick={scrollToTop}>
<ArrowCircleUp
sx={{ width: '65px', height: '65px', color: theme.palette.primary.main }}
sx={{
width: theme.spacing(8),
height: theme.spacing(8),
color: theme.palette.primary.main,
}}
/>
</Box>
)}
Expand Down
Loading