Skip to content

Commit

Permalink
Add scroll to top button
Browse files Browse the repository at this point in the history
  • Loading branch information
ani-kalpachka committed Jul 22, 2024
1 parent 20de1ce commit 03a5a14
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
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

0 comments on commit 03a5a14

Please sign in to comment.