mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 12:24:18 +00:00
Merge pull request #52 from KieIO/m7-lytran2
M7 Ly: error page, fix scroll to top
This commit is contained in:
commit
f5858140b5
9
pages/_error.tsx
Normal file
9
pages/_error.tsx
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { Layout } from 'src/components/common'
|
||||||
|
import { ErrorPage } from 'src/components/modules/error'
|
||||||
|
|
||||||
|
export default function NotFound() {
|
||||||
|
return (
|
||||||
|
<ErrorPage/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
NotFound.Layout = Layout
|
@ -3,7 +3,7 @@ import { useRouter } from 'next/router'
|
|||||||
import { FC } from 'react'
|
import { FC } from 'react'
|
||||||
import { useModalCommon } from 'src/components/hooks'
|
import { useModalCommon } from 'src/components/hooks'
|
||||||
import { BRAND, CATEGORY, FEATURED } from 'src/utils/constanst.utils'
|
import { BRAND, CATEGORY, FEATURED } from 'src/utils/constanst.utils'
|
||||||
import { CustomShapeSvg } from '..'
|
import { CustomShapeSvg, ScrollToTop } from '..'
|
||||||
import Footer from '../Footer/Footer'
|
import Footer from '../Footer/Footer'
|
||||||
import Header from '../Header/Header'
|
import Header from '../Header/Header'
|
||||||
import MenuNavigationProductList from '../MenuNavigationProductList/MenuNavigationProductList'
|
import MenuNavigationProductList from '../MenuNavigationProductList/MenuNavigationProductList'
|
||||||
@ -18,7 +18,7 @@ interface Props {
|
|||||||
const Layout: FC<Props> = ({ children }) => {
|
const Layout: FC<Props> = ({ children }) => {
|
||||||
const { locale = 'en-US' } = useRouter()
|
const { locale = 'en-US' } = useRouter()
|
||||||
const { visible: visibleFilter, openModal: openFilter, closeModal: closeFilter } = useModalCommon({ initialValue: false })
|
const { visible: visibleFilter, openModal: openFilter, closeModal: closeFilter } = useModalCommon({ initialValue: false })
|
||||||
|
|
||||||
const toggleFilter = () => {
|
const toggleFilter = () => {
|
||||||
if (visibleFilter) {
|
if (visibleFilter) {
|
||||||
closeFilter()
|
closeFilter()
|
||||||
@ -28,14 +28,15 @@ const Layout: FC<Props> = ({ children }) => {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<CommerceProvider locale={locale}>
|
<CommerceProvider locale={locale}>
|
||||||
<div className={s.mainLayout}>
|
<div className={s.mainLayout}>
|
||||||
<Header toggleFilter={toggleFilter}/>
|
<Header toggleFilter={toggleFilter} />
|
||||||
<main >{children}</main>
|
<main >{children}</main>
|
||||||
|
|
||||||
<CustomShapeSvg/>
|
<CustomShapeSvg />
|
||||||
<div className={s.filter}><MenuNavigationProductList categories={CATEGORY} brands={BRAND} featured={FEATURED} visible={visibleFilter} onClose={closeFilter}/> </div>
|
<div className={s.filter}><MenuNavigationProductList categories={CATEGORY} brands={BRAND} featured={FEATURED} visible={visibleFilter} onClose={closeFilter} /> </div>
|
||||||
<Footer />
|
<ScrollToTop visibilityHeight={1500} />
|
||||||
</div>
|
<Footer />
|
||||||
|
</div>
|
||||||
</CommerceProvider>
|
</CommerceProvider>
|
||||||
|
|
||||||
)
|
)
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
@import '../../../styles/utilities';
|
@import "../../../styles/utilities";
|
||||||
|
|
||||||
.scrollToTop {
|
.scrollToTop {
|
||||||
@apply hidden;
|
@apply hidden;
|
||||||
|
z-index: 9999;
|
||||||
|
|
||||||
@screen md {
|
@screen md {
|
||||||
&.show {
|
&.show {
|
||||||
@apply block rounded-lg fixed cursor-pointer;
|
@apply block rounded-lg fixed cursor-pointer;
|
||||||
right: 11.2rem;
|
right: 6.4rem;
|
||||||
bottom: 21.6rem;
|
bottom: 21.6rem;
|
||||||
width: 6.4rem;
|
width: 6.4rem;
|
||||||
height: 6.4rem;
|
height: 6.4rem;
|
||||||
background-color: var(--border-line);
|
background-color: var(--border-line);
|
||||||
}
|
@screen lg {
|
||||||
|
right: 11.2rem;
|
||||||
&.hide {
|
}
|
||||||
@apply hidden;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.scrollToTopBtn {
|
.scrollToTopBtn {
|
||||||
@apply outline-none w-full h-full;
|
@apply outline-none w-full h-full;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,47 +1,44 @@
|
|||||||
import React, { useState, useEffect, MutableRefObject } from 'react'
|
|
||||||
import classNames from 'classnames'
|
import classNames from 'classnames'
|
||||||
|
import React, { useEffect, useState } from 'react'
|
||||||
|
import ArrowUp from '../../icons/IconArrowUp'
|
||||||
import s from './ScrollToTop.module.scss'
|
import s from './ScrollToTop.module.scss'
|
||||||
|
|
||||||
import ArrowUp from '../../icons/IconArrowUp'
|
|
||||||
|
|
||||||
interface ScrollToTopProps {
|
interface ScrollToTopProps {
|
||||||
visibilityHeight?: number;
|
visibilityHeight?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ScrollToTop = ({ visibilityHeight=450 }: ScrollToTopProps) => {
|
const ScrollToTop = ({ visibilityHeight = 450 }: ScrollToTopProps) => {
|
||||||
|
const [showScrollToTop, setShowScrollToTop] = useState<boolean>();
|
||||||
const [scrollPosition, setSrollPosition] = useState(0);
|
|
||||||
const [showScrollToTop, setShowScrollToTop] = useState("hide");
|
|
||||||
|
|
||||||
function handleVisibleButton() {
|
function handleVisibleButton() {
|
||||||
const position = window.pageYOffset;
|
const scrollPosition = window.scrollY;
|
||||||
setSrollPosition(position);
|
|
||||||
|
|
||||||
if (scrollPosition > visibilityHeight) {
|
if (scrollPosition > visibilityHeight) {
|
||||||
return setShowScrollToTop("show")
|
setShowScrollToTop(true)
|
||||||
} else if (scrollPosition < visibilityHeight) {
|
} else {
|
||||||
return setShowScrollToTop("hide");
|
setShowScrollToTop(false)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
window.addEventListener("scroll", handleVisibleButton);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("scroll", handleVisibleButton);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
function handleScrollUp() {
|
function handleScrollUp() {
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addEventScroll() {
|
|
||||||
window.addEventListener("scroll", handleVisibleButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
addEventScroll();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(s.scrollToTop, {
|
<div className={classNames(s.scrollToTop, {
|
||||||
[s[`${showScrollToTop}`]]: showScrollToTop
|
[s.show]: showScrollToTop
|
||||||
})}
|
})}
|
||||||
onClick={handleScrollUp}
|
onClick={handleScrollUp}
|
||||||
>
|
>
|
||||||
<button className={s.scrollToTopBtn}>
|
<button className={s.scrollToTopBtn}>
|
||||||
<ArrowUp />
|
<ArrowUp />
|
||||||
</button>
|
</button>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
background-color: white;
|
background-color: white;
|
||||||
.inner{
|
.inner{
|
||||||
height: 100vh;
|
height: 70vh;
|
||||||
.logo{
|
.logo{
|
||||||
margin-top: 2rem;
|
margin-top: 2rem;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
background-color: white;
|
background-color: white;
|
||||||
.inner{
|
.inner{
|
||||||
height: 100vh;
|
height: 70vh;
|
||||||
.logo{
|
.logo{
|
||||||
margin-top: 2rem;
|
margin-top: 2rem;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user