-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from plezanje-net/edit-crag
New crag, Edit crag basics
- Loading branch information
Showing
4 changed files
with
65 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
"use client"; | ||
|
||
import { Marker, Popup } from "react-leaflet"; | ||
import L from "leaflet"; | ||
import { ReactNode } from "react"; | ||
import { useClientRenderToString } from "@/hooks/useClientRenderToString"; | ||
import IconMarkerWall from "../ui/icons/marker-wall"; | ||
import IconMarkerParking from "../ui/icons/marker-parking"; | ||
import { IconSize } from "../ui/icons/icon-size"; | ||
|
||
type TLazyMapMarkerProps = { | ||
type: "parking" | "wall"; | ||
position: [number, number]; | ||
popupContent?: ReactNode; | ||
interactive?: boolean; | ||
hidden?: boolean; | ||
}; | ||
|
||
function LazyMapMarker({ | ||
type, | ||
position, | ||
popupContent, | ||
interactive = true, | ||
hidden, | ||
}: TLazyMapMarkerProps) { | ||
const [icon] = useClientRenderToString( | ||
type === "parking" ? ( | ||
<IconMarkerParking size={IconSize.xl} /> | ||
) : ( | ||
<IconMarkerWall size={IconSize.xl} /> | ||
) | ||
); | ||
|
||
return ( | ||
<Marker | ||
icon={L.divIcon({ | ||
className: "", | ||
html: icon, | ||
iconSize: [52, 52], | ||
iconAnchor: [26, 52], | ||
popupAnchor: [0, -46], | ||
})} | ||
position={position} | ||
interactive={interactive} | ||
opacity={hidden ? 0 : 1} | ||
> | ||
{popupContent && <Popup>{popupContent}</Popup>} | ||
</Marker> | ||
); | ||
} | ||
|
||
export default LazyMapMarker; | ||
export type { TLazyMapMarkerProps }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,12 @@ | ||
"use client"; | ||
import dynamic from "next/dynamic"; | ||
import { TLazyMapMarkerProps as TMapMarkerProps } from "./lazy-map-marker"; | ||
|
||
import { Marker, Popup } from "react-leaflet"; | ||
import L from "leaflet"; | ||
import { ReactNode } from "react"; | ||
import { useClientRenderToString } from "@/hooks/useClientRenderToString"; | ||
import IconMarkerWall from "../ui/icons/marker-wall"; | ||
import IconMarkerParking from "../ui/icons/marker-parking"; | ||
import { IconSize } from "../ui/icons/icon-size"; | ||
const LazyMapMarker = dynamic(() => import("./lazy-map-marker"), { | ||
ssr: false, | ||
}); | ||
|
||
type TMapMarkerProps = { | ||
type: "parking" | "wall"; | ||
position: [number, number]; | ||
popupContent?: ReactNode; | ||
interactive?: boolean; | ||
}; | ||
|
||
function MapMarker({ | ||
type, | ||
position, | ||
popupContent, | ||
interactive = true, | ||
}: TMapMarkerProps) { | ||
const [icon] = useClientRenderToString( | ||
type === "parking" ? ( | ||
<IconMarkerParking size={IconSize.xl} /> | ||
) : ( | ||
<IconMarkerWall size={IconSize.xl} /> | ||
) | ||
); | ||
|
||
return ( | ||
<Marker | ||
icon={L.divIcon({ | ||
className: "", | ||
html: icon, | ||
iconSize: [52, 52], | ||
iconAnchor: [26, 52], | ||
popupAnchor: [0, -46], | ||
})} | ||
position={position} | ||
interactive={interactive} | ||
> | ||
{popupContent && <Popup>{popupContent}</Popup>} | ||
</Marker> | ||
); | ||
function MapMarker(props: TMapMarkerProps) { | ||
return <LazyMapMarker {...props} />; | ||
} | ||
|
||
export default MapMarker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters