mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
Add basic transition gif implementation and fix search engine
This commit is contained in:
@@ -1,71 +1,96 @@
|
||||
import {
|
||||
Modal,
|
||||
ModalOverlay,
|
||||
ModalContent,
|
||||
ModalBody,
|
||||
Box,
|
||||
} from "@chakra-ui/react"
|
||||
import {
|
||||
Modal,
|
||||
ModalOverlay,
|
||||
ModalContent,
|
||||
ModalBody,
|
||||
Box,
|
||||
} from '@chakra-ui/react'
|
||||
|
||||
import decadesManifest from '../../../../static_data/decadesManifest.json';
|
||||
import { useRouter } from "next/router";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import ImageMapper from "react-img-mapper"
|
||||
import decadesManifest from '../../../../static_data/decadesManifest.json'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import ImageMapper from 'react-img-mapper'
|
||||
import Image from 'next/image'
|
||||
|
||||
export default function MarkerCardModal(props: {
|
||||
isOpen: boolean,
|
||||
onModalClose: () => void,
|
||||
decade: string,
|
||||
isOpen: boolean
|
||||
onModalClose: () => void
|
||||
decade: string
|
||||
}) {
|
||||
const { locale } = useRouter()
|
||||
const containerRef = useRef<any>()
|
||||
|
||||
const {locale} = useRouter();
|
||||
const containerRef = useRef<any>();
|
||||
const decadeColor =
|
||||
decadesManifest[props.decade as keyof typeof decadesManifest].color
|
||||
|
||||
const decadeColor = decadesManifest[props.decade as keyof typeof decadesManifest].color;
|
||||
|
||||
const [width, setWidth] = useState(200);
|
||||
const [width, setWidth] = useState(200)
|
||||
const [isMapLoaded, setIsMapLoaded] = useState<boolean>(false)
|
||||
|
||||
const [mapDefinition, setMapDefinition] = useState<any>()
|
||||
const [mapDefinition, setMapDefinition] = useState<any>()
|
||||
const [isTransitionCompleted, setIsTransitionComplited] =
|
||||
useState<boolean>(false)
|
||||
|
||||
const getContainerSize = () => {
|
||||
if(containerRef.current != undefined) {
|
||||
setWidth(containerRef.current.clientWidth);
|
||||
}
|
||||
};
|
||||
|
||||
const getMapDefinition = async () => {
|
||||
const tempMapDefinition = await import("../../../../static_data/regions/abruzzo/" + props.decade + "/plan/manifest.json")
|
||||
tempMapDefinition.areas.forEach((area: any) => {
|
||||
area.href = "/" + locale + area.href
|
||||
})
|
||||
setMapDefinition(tempMapDefinition)
|
||||
const getContainerSize = () => {
|
||||
if (containerRef.current != undefined) {
|
||||
setWidth(containerRef.current.clientWidth)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getContainerSize()
|
||||
}, [isMapLoaded]);
|
||||
|
||||
useEffect(() => {
|
||||
getMapDefinition()
|
||||
return window.addEventListener("resize", getContainerSize);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal onClose={props.onModalClose} isOpen={props.isOpen} isCentered>
|
||||
<ModalOverlay />
|
||||
<ModalContent rounded={"lg"}>
|
||||
<ModalBody rounded={"lg"} style={{background: 'linear-gradient(120deg, ' + decadeColor + ' 0%, #000000 130%)'}} p={5}>
|
||||
<Box
|
||||
w={'full'}
|
||||
ref={containerRef}
|
||||
>
|
||||
<ImageMapper onLoad={() => setIsMapLoaded(true)} natural stayHighlighted responsive={true} parentWidth={width} map={mapDefinition} src={"/regions/abruzzo/" + props.decade + "/plan/plan.jpeg"}></ImageMapper>
|
||||
</Box>
|
||||
</ModalBody>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
const getMapDefinition = async () => {
|
||||
const tempMapDefinition = await import(
|
||||
'../../../../static_data/regions/abruzzo/' +
|
||||
props.decade +
|
||||
'/plan/manifest.json'
|
||||
)
|
||||
tempMapDefinition.areas.forEach((area: any) => {
|
||||
area.href = '/' + locale + area.href
|
||||
})
|
||||
setMapDefinition(tempMapDefinition)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getMapDefinition()
|
||||
return window.addEventListener('resize', getContainerSize)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal onClose={props.onModalClose} isOpen={props.isOpen} isCentered>
|
||||
<ModalOverlay />
|
||||
<ModalContent rounded={'lg'}>
|
||||
<ModalBody
|
||||
rounded={'lg'}
|
||||
style={{
|
||||
background:
|
||||
'linear-gradient(120deg, ' + decadeColor + ' 0%, #000000 130%)',
|
||||
}}
|
||||
p={5}
|
||||
>
|
||||
<Box w={'full'} ref={containerRef}>
|
||||
{!isTransitionCompleted ? (
|
||||
<Image
|
||||
src={'/regions/abruzzo/11/plan/transition.gif'}
|
||||
height={200}
|
||||
width={200}
|
||||
onLoad={() =>
|
||||
setInterval(() => {
|
||||
setIsTransitionComplited(true)
|
||||
}, 5000)
|
||||
}
|
||||
></Image>
|
||||
) : (
|
||||
<ImageMapper
|
||||
onLoad={() => setInterval(() => getContainerSize(), 10)}
|
||||
responsive={true}
|
||||
parentWidth={width}
|
||||
map={mapDefinition}
|
||||
src={'/regions/abruzzo/' + props.decade + '/plan/plan.jpeg'}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
</ModalBody>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import { Logo, Container } from '@components/ui'
|
||||
import { Searchbar, UserNav } from '@components/common'
|
||||
import { useDisclosure } from '@chakra-ui/react'
|
||||
import NavBarFiltersDrawer from './NavBarFiltersDrawer'
|
||||
import { useRouter } from 'next/router'
|
||||
|
||||
interface Link {
|
||||
href: string
|
||||
@@ -23,6 +24,8 @@ const Navbar: FC<NavbarProps> = ({ links }) => {
|
||||
onClose: onCloseDrawer,
|
||||
} = useDisclosure()
|
||||
|
||||
const { locale } = useRouter()
|
||||
|
||||
return (
|
||||
<>
|
||||
<NavBarFiltersDrawer
|
||||
@@ -40,7 +43,9 @@ const Navbar: FC<NavbarProps> = ({ links }) => {
|
||||
</Link>
|
||||
<nav className={s.navMenu}>
|
||||
<Link href="/search">
|
||||
<a className={s.link}>All</a>
|
||||
<a className={s.link}>
|
||||
{locale === 'it' ? 'Prodotti' : 'All'}
|
||||
</a>
|
||||
</Link>
|
||||
{links?.map((l) => (
|
||||
<Link href={l.href} key={l.href}>
|
||||
|
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"title": "ACME Storefront | Powered by Next.js Commerce",
|
||||
"titleTemplate": "%s - ACME Storefront",
|
||||
"description": "Next.js Commerce - https://www.nextjs.org/commerce",
|
||||
"title": "SafaraEcommerce",
|
||||
"titleTemplate": "%s - SafaraEcommerce",
|
||||
"description": "SafaraEcommerce",
|
||||
"openGraph": {
|
||||
"title": "ACME Storefront | Powered by Next.js Commerce",
|
||||
"title": "SafaraEcommerce",
|
||||
"description": "Next.js Commerce - https://www.nextjs.org/commerce",
|
||||
"type": "website",
|
||||
"url": "https://nextjs.org/commerce",
|
||||
|
@@ -36,6 +36,7 @@
|
||||
"clsx": "^1.1.1",
|
||||
"email-validator": "^2.0.4",
|
||||
"framer-motion": "^7.10.3",
|
||||
"image-crossfade-react": "^1.0.0",
|
||||
"js-cookie": "^3.0.1",
|
||||
"keen-slider": "^6.7.0",
|
||||
"lodash.random": "^3.2.0",
|
||||
@@ -46,6 +47,7 @@
|
||||
"postcss": "^8.3.5",
|
||||
"postcss-nesting": "^10.1.10",
|
||||
"react": "^18.2.0",
|
||||
"react-crossfade-image": "^1.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-fast-marquee": "^1.3.1",
|
||||
"react-h5-audio-player": "^3.8.6",
|
||||
|
BIN
site/public/regions/abruzzo/11/plan/transition.gif
Normal file
BIN
site/public/regions/abruzzo/11/plan/transition.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 50 KiB |
Reference in New Issue
Block a user