From f17dbe0741c93c4a2662520424de5e7ea1be674a Mon Sep 17 00:00:00 2001 From: clintonlunn Date: Wed, 29 May 2024 19:11:26 -0600 Subject: [PATCH] refactor: arranging buttons for mobile and desktop, anchor popup for mobile and not mobile --- .../general/components/AreaLatLngForm.tsx | 20 ++++++++++--------- src/components/maps/CoordinatePickerPopup.tsx | 14 +++++++++++-- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/app/(default)/editArea/[slug]/general/components/AreaLatLngForm.tsx b/src/app/(default)/editArea/[slug]/general/components/AreaLatLngForm.tsx index cebd96a2a..c2b54db0a 100644 --- a/src/app/(default)/editArea/[slug]/general/components/AreaLatLngForm.tsx +++ b/src/app/(default)/editArea/[slug]/general/components/AreaLatLngForm.tsx @@ -37,17 +37,19 @@ export const AreaLatLngForm: React.FC<{ initLat: number, initLng: number, uuid: > {isLeaf ? ( -
- +
+
+ +
- diff --git a/src/components/maps/CoordinatePickerPopup.tsx b/src/components/maps/CoordinatePickerPopup.tsx index 470d069c9..ca65612c6 100644 --- a/src/components/maps/CoordinatePickerPopup.tsx +++ b/src/components/maps/CoordinatePickerPopup.tsx @@ -1,3 +1,4 @@ +import { useResponsive } from '@/js/hooks' import * as Popover from '@radix-ui/react-popover' import { useCallback } from 'react' import { MapInstance } from 'react-map-gl' @@ -16,6 +17,7 @@ export const CoordinatePickerPopup: React.FC = ({ in const { coordinates, mapInstance } = info const { lng: longitude, lat: latitude } = coordinates const screenXY = mapInstance?.project(coordinates) + const { isMobile } = useResponsive() const handleConfirmClick = useCallback((e: React.MouseEvent) => { e.stopPropagation() @@ -24,15 +26,23 @@ export const CoordinatePickerPopup: React.FC = ({ in if (screenXY == null) return null + const anchorClass = isMobile + ? 'fixed top-15 left-1/2 transform -translate-x-1/2' + : 'fixed top-1/3 left-1/2 transform -translate-x-1/2' + return ( - + e.stopPropagation()} >