From 49b99b1bc482963440fe91a757abbd6fc470806a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Un=20=C3=89picier?= Date: Sun, 6 Oct 2024 16:01:57 +0200 Subject: [PATCH] :zap: Removed tooltip for now --- app/hooks/useActions.ts | 32 ++------------------------------ app/hooks/useData.ts | 6 +----- app/page.tsx | 35 +++++------------------------------ 3 files changed, 8 insertions(+), 65 deletions(-) diff --git a/app/hooks/useActions.ts b/app/hooks/useActions.ts index ff575fc..2111355 100644 --- a/app/hooks/useActions.ts +++ b/app/hooks/useActions.ts @@ -1,10 +1,7 @@ -import { PickingInfo } from 'deck.gl'; -import { FormEvent, useCallback } from 'react'; +import { FormEvent } from 'react'; export const useActions = ({ - deckRef, viewState, - setClickedItem, setIsAddLoveOpened, setIsLoading, setAddLoveMessage, @@ -75,30 +72,5 @@ export const useActions = ({ } }; - const onMapClick = useCallback( - (ev: React.MouseEvent) => { - if (!deckRef.current) return; - - const containerRect = ev.currentTarget.getBoundingClientRect(); - const x = ev.clientX - containerRect.left; - const y = ev.clientY - containerRect.top; - - const pickInfos: PickingInfo | null = deckRef.current.pickObject({ - x, - y, - radius: 1, - depth: 5, - }); - console.log('pickInfos: ', pickInfos); - if (!pickInfos) { - setClickedItem(null); - return; - } - - setClickedItem(pickInfos); - }, - [deckRef, setClickedItem] - ); - - return { toggleLoveMenu, addPoint, onMapClick }; + return { toggleLoveMenu, addPoint }; }; diff --git a/app/hooks/useData.ts b/app/hooks/useData.ts index 5e83332..8e8e826 100644 --- a/app/hooks/useData.ts +++ b/app/hooks/useData.ts @@ -1,5 +1,5 @@ -import { IconLayer, ScatterplotLayer } from 'deck.gl'; import { useEffect, useRef, useState } from 'react'; +import { IconLayer, ScatterplotLayer } from 'deck.gl'; import { StringifiedPinIcon } from '@/assets/PinIcon'; export const useData = () => { @@ -24,8 +24,6 @@ export const useData = () => { zoom: 5, }); - const [clickedItem, setClickedItem] = useState(null); - useEffect(() => { if ('geolocation' in navigator == false) { setCanUseGeolocation(false); @@ -121,8 +119,6 @@ export const useData = () => { geoError, layers, canUseGeolocation, - clickedItem, - setClickedItem, isAddLoveOpened, setIsAddLoveOpened, isLoading, diff --git a/app/page.tsx b/app/page.tsx index 85b21d0..98c4a87 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -6,7 +6,7 @@ // --------------------------------------------------- Components ------------------------------------------------------ import { DeckGL } from 'deck.gl'; import { Map } from 'react-map-gl'; -import Image from 'next/image'; +import Input from '@/components/Input/Input'; // --------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------- Hooks & Utils ---------------------------------------------------- @@ -16,13 +16,12 @@ import { useActions } from './hooks/useActions'; // ------------------------------------------------- Assets & Styles --------------------------------------------------- import HeartIcon from '@/assets/HeartIcon'; -import Input from '@/components/Input/Input'; import CloseIcon from '@/assets/CloseIcon'; import AddIcon from '@/assets/AddIcon'; -import 'mapbox-gl/dist/mapbox-gl.css'; -import './styles.scss'; import Loader from '@/assets/Loader'; import PinIcon from '@/assets/PinIcon'; +import 'mapbox-gl/dist/mapbox-gl.css'; +import './styles.scss'; // --------------------------------------------------------------------------------------------------------------------- const Home = () => { @@ -33,8 +32,6 @@ const Home = () => { geoError, canUseGeolocation, layers, - clickedItem, - setClickedItem, isAddLoveOpened, setIsAddLoveOpened, isLoading, @@ -43,10 +40,8 @@ const Home = () => { setAddLoveMessage, } = useData(); - const { toggleLoveMenu, addPoint, onMapClick } = useActions({ - deckRef, + const { toggleLoveMenu, addPoint } = useActions({ viewState, - setClickedItem, setIsAddLoveOpened, setIsLoading, setAddLoveMessage, @@ -67,10 +62,7 @@ const Home = () => { return (
-
+
{ } preserveDrawingBuffer > - {clickedItem && clickedItem.object ? ( -
- {clickedItem.object.properties.location} -
- ) : ( - <> - )}
{isAddLoveOpened && ( //