From e1bd5868edbe1b4b857e453f5543c98549dc00cd Mon Sep 17 00:00:00 2001 From: Huh Hyeongjun Date: Tue, 25 Feb 2025 18:24:20 +0900 Subject: [PATCH] feat: loading icon on button --- src/components/map/Processing.tsx | 23 +++- src/components/nav/TopNav.tsx | 168 ++++++++++++++++++------------ 2 files changed, 125 insertions(+), 66 deletions(-) diff --git a/src/components/map/Processing.tsx b/src/components/map/Processing.tsx index 605e5da..5a0b6ae 100644 --- a/src/components/map/Processing.tsx +++ b/src/components/map/Processing.tsx @@ -1,5 +1,6 @@ import { useAreaStore } from "@/state/areaStore"; -import { css } from "@emotion/react"; +import { css, keyframes } from "@emotion/react"; +import { Loader2 } from "lucide-react"; import React, { useState } from "react"; interface Building { @@ -8,11 +9,20 @@ interface Building { geometry?: { lat: number; lng: number }[]; } +const spinAnimation = keyframes` +from { transform: rotate(0deg); } +to { transform: rotate(360deg); } +`; + export function BuildingHeights({ area }: { area: any }) { const [buildings, setBuildings] = useState([]); + const [loading, setLoading] = useState(false); + const appendAreas = useAreaStore((state) => state.appendAreas); const requestBuildings = () => { + setLoading(true); + const south = area[1].lat; const west = area[1].lng; const north = area[0].lat; @@ -40,6 +50,9 @@ export function BuildingHeights({ area }: { area: any }) { }) .catch((error) => { console.error("Error fetching building data:", error); + }) + .finally(() => { + setLoading(false); }); }; @@ -70,6 +83,14 @@ export function BuildingHeights({ area }: { area: any }) { })} onClick={requestBuildings} > + {loading && ( + + )} request
    `@media (max-width: ${bp}px)`); +interface ButtonProps + extends DetailedHTMLProps< + ButtonHTMLAttributes, + HTMLButtonElement + > { + isShow?: boolean; +} + export function TopNav({ step }: { step: number }) { const setThirdMode = useCarStore((state) => state.setThirdMode); + const [openModal, setOpenModal] = useState(false); return ( -
    + <>
    - - 🗺️ Map3d - -
    + + 🗺️ Map3d + +
    -
    +
    -
    - + window.open("https://github.com/cartesiancs/map3d")} + > + GitHub + + = 1} onClick={() => setOpenModal(true)}> + Options + + + setThirdMode(true)}> + Car Mode + +
    - + + setOpenModal(false)}> + + Options + + + + ); +} + +export function NavButton(props: ButtonProps) { + return ( + ); }