- {props.children ? (
- Children.toArray(props.children).map((child) =>
- isValidElement<{ item: Item; test: string }>(child)
- ? cloneElement(child, { item: props.item })
- : '',
- )
- ) : (
-
- )}
+ {props.children ?? }
{infoExpanded ? (
diff --git a/src/Components/Map/UtopiaMap.tsx b/src/Components/Map/UtopiaMap.tsx
index 8097928b..da909e3b 100644
--- a/src/Components/Map/UtopiaMap.tsx
+++ b/src/Components/Map/UtopiaMap.tsx
@@ -51,6 +51,7 @@ function UtopiaMap({
showFilterControl = false,
showGratitudeControl = false,
showLayerControl = true,
+ showZoomControl = false,
showThemeControl = false,
defaultTheme,
donationWidget,
@@ -74,6 +75,8 @@ function UtopiaMap({
showLayerControl?: boolean
/** show the layer control widget (default true) */
showGratitudeControl?: boolean
+ /** show zoom control widget (default false) */
+ showZoomControl?: boolean
/** show a widget to switch the theme */
showThemeControl?: boolean
/** the defaut theme */
@@ -89,7 +92,7 @@ function UtopiaMap({
style={{ height, width }}
center={new LatLng(center[0], center[1])}
zoom={zoom}
- zoomControl={false}
+ zoomControl={showZoomControl}
maxZoom={19}
>
(null)
-
- useTheme(defaultTheme)
-
+ const { setPopupForm } = usePopupForm()
const layers = useLayers()
const addVisibleLayer = useAddVisibleLayer()
const leafletRefs = useLeafletRefs()
-
const location = useLocation()
const map = useMap()
+ useTheme(defaultTheme)
+
useEffect(() => {
layers.forEach((layer) => addVisibleLayer(layer))
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -128,7 +126,7 @@ export function UtopiaMapInner({
// eslint-disable-next-line no-console
console.log(e.latlng.lat + ',' + e.latlng.lng)
if (selectNewItemPosition) {
- setMapClicked({ position: e.latlng, setItemFormPopup })
+ setMapClicked({ position: e.latlng, setItemFormPopup: setPopupForm })
}
},
moveend: () => {},
@@ -287,15 +285,7 @@ export function UtopiaMapInner({
maxClusterRadius={50}
removeOutsideVisibleBounds={false}
>
- {Children.toArray(children).map((child) =>
- isValidElement<{
- setItemFormPopup: React.Dispatch>
- itemFormPopup: ItemFormPopupProps | null
- clusterRef: React.MutableRefObject
- }>(child)
- ? cloneElement(child, { setItemFormPopup, itemFormPopup, clusterRef })
- : child,
- )}
+ {children}
{geo && (
{
if (selectNewItemPosition) {
e.layer.closePopup()
- setMapClicked({ position: e.latlng, setItemFormPopup })
+ setMapClicked({ position: e.latlng, setItemFormPopup: setPopupForm })
}
},
}}
diff --git a/src/Components/Map/hooks/usePopupForm.tsx b/src/Components/Map/hooks/usePopupForm.tsx
new file mode 100644
index 00000000..497c5931
--- /dev/null
+++ b/src/Components/Map/hooks/usePopupForm.tsx
@@ -0,0 +1,34 @@
+import { createContext, useContext, useState } from 'react'
+
+import type { PopupFormState } from '#types/PopupFormState'
+
+type UsePopupFormManagerResult = ReturnType
+
+const PoupFormContext = createContext({
+ popupForm: {} as PopupFormState | null,
+ setPopupForm: () => {
+ /* empty function */
+ },
+})
+
+function usePopupFormManager(): {
+ popupForm: PopupFormState | null
+ setPopupForm: React.Dispatch>
+} {
+ const [popupForm, setPopupForm] = useState(null)
+
+ return { popupForm, setPopupForm }
+}
+
+interface Props {
+ children?: React.ReactNode
+}
+
+export const PopupFormProvider: React.FunctionComponent = ({ children }: Props) => (
+ {children}
+)
+
+export const usePopupForm = (): UsePopupFormManagerResult => {
+ const { popupForm, setPopupForm } = useContext(PoupFormContext)
+ return { popupForm, setPopupForm }
+}
diff --git a/src/Components/Map/hooks/useSelectPosition.tsx b/src/Components/Map/hooks/useSelectPosition.tsx
index e53e0193..e1ebf9dc 100644
--- a/src/Components/Map/hooks/useSelectPosition.tsx
+++ b/src/Components/Map/hooks/useSelectPosition.tsx
@@ -15,14 +15,14 @@ import { useUpdateItem } from './useItems'
import { useHasUserPermission } from './usePermissions'
import type { Item } from '#types/Item'
-import type { ItemFormPopupProps } from '#types/ItemFormPopupProps'
import type { LayerProps } from '#types/LayerProps'
+import type { PopupFormState } from '#types/PopupFormState'
import type { Point } from 'geojson'
import type { LatLng } from 'leaflet'
interface PolygonClickedProps {
position: LatLng
- setItemFormPopup: React.Dispatch>
+ setItemFormPopup: React.Dispatch>
}
type UseSelectPositionManagerResult = ReturnType
@@ -60,7 +60,9 @@ function useSelectPositionManager(): {
useEffect(() => {
if (selectPosition != null) {
+ // selectPosition can be null, Layer or Item
if ('menuIcon' in selectPosition) {
+ // if selectPosition is a Layer
mapClicked &&
mapClicked.setItemFormPopup({
layer: selectPosition,
@@ -69,6 +71,7 @@ function useSelectPositionManager(): {
setSelectPosition(null)
}
if ('text' in selectPosition) {
+ // if selectPosition is an Item
const position =
mapClicked?.position.lng &&
({
diff --git a/src/Components/Map/index.tsx b/src/Components/Map/index.tsx
index 6ef08d6c..0dbcc233 100644
--- a/src/Components/Map/index.tsx
+++ b/src/Components/Map/index.tsx
@@ -2,8 +2,7 @@ export { UtopiaMap } from './UtopiaMap'
export * from './Layer'
export { Tags } from './Tags'
export * from './Permissions'
-export { ItemForm } from './ItemForm'
-export { ItemView } from './ItemView'
+/*
export { PopupTextAreaInput } from './Subcomponents/ItemPopupComponents/PopupTextAreaInput'
export { PopupStartEndInput } from './Subcomponents/ItemPopupComponents/PopupStartEndInput'
export { PopupTextInput } from './Subcomponents/ItemPopupComponents/PopupTextInput'
@@ -11,3 +10,4 @@ export { PopupCheckboxInput } from './Subcomponents/ItemPopupComponents/PopupChe
export { TextView } from './Subcomponents/ItemPopupComponents/TextView'
export { StartEndView } from './Subcomponents/ItemPopupComponents/StartEndView'
export { PopupButton } from './Subcomponents/ItemPopupComponents/PopupButton'
+*/
diff --git a/src/Components/Profile/Subcomponents/ProfileStartEndForm.tsx b/src/Components/Profile/Subcomponents/ProfileStartEndForm.tsx
index e5f67ffe..fa7d20c4 100644
--- a/src/Components/Profile/Subcomponents/ProfileStartEndForm.tsx
+++ b/src/Components/Profile/Subcomponents/ProfileStartEndForm.tsx
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unsafe-return */
-import { PopupStartEndInput } from '#components/Map'
+import { PopupStartEndInput } from '#components/Map/Subcomponents/ItemPopupComponents'
import type { Item } from '#types/Item'
diff --git a/src/Components/Profile/Subcomponents/ProfileStartEndView.tsx b/src/Components/Profile/Subcomponents/ProfileStartEndView.tsx
index d490d725..67ac93f3 100644
--- a/src/Components/Profile/Subcomponents/ProfileStartEndView.tsx
+++ b/src/Components/Profile/Subcomponents/ProfileStartEndView.tsx
@@ -1,4 +1,4 @@
-import { StartEndView } from '#components/Map'
+import { StartEndView } from '#components/Map/Subcomponents/ItemPopupComponents'
import type { Item } from '#types/Item'
diff --git a/src/Components/Profile/Subcomponents/ProfileTextView.tsx b/src/Components/Profile/Subcomponents/ProfileTextView.tsx
index df1d5e77..2adbb3e1 100644
--- a/src/Components/Profile/Subcomponents/ProfileTextView.tsx
+++ b/src/Components/Profile/Subcomponents/ProfileTextView.tsx
@@ -1,6 +1,6 @@
import { get } from 'radash'
-import { TextView } from '#components/Map'
+import { TextView } from '#components/Map/Subcomponents/ItemPopupComponents'
import type { Item } from '#types/Item'
diff --git a/src/Components/Profile/Templates/OnepagerView.tsx b/src/Components/Profile/Templates/OnepagerView.tsx
index 088b92a6..7c2d8077 100644
--- a/src/Components/Profile/Templates/OnepagerView.tsx
+++ b/src/Components/Profile/Templates/OnepagerView.tsx
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */
-import { TextView } from '#components/Map'
+import { TextView } from '#components/Map/Subcomponents/ItemPopupComponents'
import { ContactInfoView } from '#components/Profile/Subcomponents/ContactInfoView'
import { GroupSubHeaderView } from '#components/Profile/Subcomponents/GroupSubHeaderView'
diff --git a/src/Components/Profile/Templates/SimpleView.tsx b/src/Components/Profile/Templates/SimpleView.tsx
index 894c3459..46b0d7ba 100644
--- a/src/Components/Profile/Templates/SimpleView.tsx
+++ b/src/Components/Profile/Templates/SimpleView.tsx
@@ -1,4 +1,4 @@
-import { TextView } from '#components/Map'
+import { TextView } from '#components/Map/Subcomponents/ItemPopupComponents'
import type { Item } from '#types/Item'
diff --git a/src/Components/Profile/Templates/TabsForm.tsx b/src/Components/Profile/Templates/TabsForm.tsx
index 0a735955..f9931b28 100644
--- a/src/Components/Profile/Templates/TabsForm.tsx
+++ b/src/Components/Profile/Templates/TabsForm.tsx
@@ -10,8 +10,8 @@ import { useCallback, useEffect, useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { TextAreaInput } from '#components/Input'
-import { PopupStartEndInput, TextView } from '#components/Map'
import { useUpdateItem } from '#components/Map/hooks/useItems'
+import { PopupStartEndInput, TextView } from '#components/Map/Subcomponents/ItemPopupComponents'
import { ActionButton } from '#components/Profile/Subcomponents/ActionsButton'
import { LinkedItemsHeaderView } from '#components/Profile/Subcomponents/LinkedItemsHeaderView'
import { TagsWidget } from '#components/Profile/Subcomponents/TagsWidget'
diff --git a/src/Components/Profile/Templates/TabsView.tsx b/src/Components/Profile/Templates/TabsView.tsx
index c14ca054..5dce43a4 100644
--- a/src/Components/Profile/Templates/TabsView.tsx
+++ b/src/Components/Profile/Templates/TabsView.tsx
@@ -10,9 +10,9 @@ import { useCallback, useEffect, useRef, useState } from 'react'
import { Link, useNavigate } from 'react-router-dom'
import { useAppState } from '#components/AppShell/hooks/useAppState'
-import { StartEndView, TextView } from '#components/Map'
import { useAddFilterTag } from '#components/Map/hooks/useFilter'
import { useItems } from '#components/Map/hooks/useItems'
+import { StartEndView, TextView } from '#components/Map/Subcomponents/ItemPopupComponents'
import { ActionButton } from '#components/Profile/Subcomponents/ActionsButton'
import { LinkedItemsHeaderView } from '#components/Profile/Subcomponents/LinkedItemsHeaderView'
import { TagView } from '#components/Templates/TagView'
diff --git a/src/Components/Templates/ItemCard.tsx b/src/Components/Templates/ItemCard.tsx
index 02d86240..6e07688e 100644
--- a/src/Components/Templates/ItemCard.tsx
+++ b/src/Components/Templates/ItemCard.tsx
@@ -1,7 +1,7 @@
import { useNavigate } from 'react-router-dom'
-import { StartEndView, TextView } from '#components/Map'
import useWindowDimensions from '#components/Map/hooks/useWindowDimension'
+import { StartEndView, TextView } from '#components/Map/Subcomponents/ItemPopupComponents'
import { HeaderView } from '#components/Map/Subcomponents/ItemPopupComponents/HeaderView'
import { DateUserInfo } from './DateUserInfo'
diff --git a/src/Components/Templates/OverlayItemsIndexPage.tsx b/src/Components/Templates/OverlayItemsIndexPage.tsx
index 482d639e..68818dfe 100644
--- a/src/Components/Templates/OverlayItemsIndexPage.tsx
+++ b/src/Components/Templates/OverlayItemsIndexPage.tsx
@@ -9,7 +9,6 @@ import { toast } from 'react-toastify'
import { useAuth } from '#components/Auth/useAuth'
import { TextInput, TextAreaInput } from '#components/Input'
-import { PopupStartEndInput } from '#components/Map'
import { useFilterTags } from '#components/Map/hooks/useFilter'
import { useAddItem, useItems, useRemoveItem } from '#components/Map/hooks/useItems'
import { useLayers } from '#components/Map/hooks/useLayers'
@@ -17,6 +16,7 @@ import { useAddTag, useGetItemTags, useTags } from '#components/Map/hooks/useTag
import { Control } from '#components/Map/Subcomponents/Controls/Control'
import { SearchControl } from '#components/Map/Subcomponents/Controls/SearchControl'
import { TagsControl } from '#components/Map/Subcomponents/Controls/TagsControl'
+import { PopupStartEndInput } from '#components/Map/Subcomponents/ItemPopupComponents'
import { PlusButton } from '#components/Profile/Subcomponents/PlusButton'
import { hashTagRegex } from '#utils/HashTagRegex'
import { randomColor } from '#utils/RandomColor'
diff --git a/src/assets/css/leaflet.css b/src/assets/css/leaflet.css
index 5451da91..ede0d425 100644
--- a/src/assets/css/leaflet.css
+++ b/src/assets/css/leaflet.css
@@ -1,4 +1,4 @@
-.leaflet-control-attribution {
+ .leaflet-control-attribution {
display: none;
}
@@ -56,4 +56,43 @@
.leaflet-popup-close-button span {
color: var(--color-base-content);
opacity: 50%;
-}
\ No newline at end of file
+}
+
+.leaflet-top {
+ top: 6em
+}
+
+.leaflet-left {
+ left: 0.5em
+}
+
+.leaflet-control-zoom {
+ border-radius: var(--radius-box);
+ color: var(--color-base-content);
+ background-color: var(--color-base-100);
+ width: calc(var(--tw-spacing) * 10);
+ border: 2px solid var(--color-base-300) !important;
+ box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1) !important;
+}
+
+.leaflet-control-zoom-in {
+ border-top-left-radius: var(--radius-box) !important;
+ border-top-right-radius: var(--radius-box) !important;
+ color: var(--color-base-content) !important;
+ background-color: var(--color-base-100) !important;
+ width: calc(var(--tw-spacing) * 9) !important;
+ border-bottom: 1px solid var(--color-base-300) !important;
+ height: calc(var(--tw-spacing) * 9) !important;
+ line-height: 40px !important;
+}
+
+.leaflet-control-zoom-out {
+ border-bottom-left-radius: var(--radius-box) !important;
+ border-bottom-right-radius: var(--radius-box) !important;
+ color: var(--color-base-content) !important;
+ background-color: var(--color-base-100) !important;
+ width: calc(var(--tw-spacing) * 9) !important;
+ height: calc(var(--tw-spacing) * 9) !important;
+ line-height: 40px !important;
+}
+
diff --git a/src/index.tsx b/src/index.tsx
index b84d77a2..07ec6212 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -8,6 +8,7 @@ export * from './Components/Profile'
export * from './Components/Gaming'
export * from './Components/Templates'
export * from './Components/Input'
+export * from './Components/Item'
declare global {
interface Window {
diff --git a/src/types/LayerProps.d.ts b/src/types/LayerProps.d.ts
index b625d830..771688b1 100644
--- a/src/types/LayerProps.d.ts
+++ b/src/types/LayerProps.d.ts
@@ -1,5 +1,4 @@
import type { Item } from './Item'
-import type { ItemFormPopupProps } from './ItemFormPopupProps'
import type { ItemsApi } from './ItemsApi'
import type { ItemType } from './ItemType'
import type { MarkerIcon } from './MarkerIcon'
@@ -27,8 +26,4 @@ export interface LayerProps {
public_edit_items?: boolean
listed?: boolean
item_presets?: Record
- setItemFormPopup?: React.Dispatch>
- itemFormPopup?: ItemFormPopupProps | null
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- clusterRef?: any
}
diff --git a/src/types/ItemFormPopupProps.d.ts b/src/types/PopupFormState.ts
similarity index 53%
rename from src/types/ItemFormPopupProps.d.ts
rename to src/types/PopupFormState.ts
index 64e880bb..1cf0890d 100644
--- a/src/types/ItemFormPopupProps.d.ts
+++ b/src/types/PopupFormState.ts
@@ -2,10 +2,8 @@ import type { Item } from './Item'
import type { LayerProps } from './LayerProps'
import type { LatLng } from 'leaflet'
-export interface ItemFormPopupProps {
+export interface PopupFormState {
position: LatLng
layer: LayerProps
item?: Item
- children?: React.ReactNode
- setItemFormPopup?: React.Dispatch>
}
diff --git a/src/types/UtopiaMapProps.d.ts b/src/types/UtopiaMapProps.d.ts
index d44ae83a..3d85374e 100644
--- a/src/types/UtopiaMapProps.d.ts
+++ b/src/types/UtopiaMapProps.d.ts
@@ -13,6 +13,7 @@ export interface UtopiaMapProps {
showLayerControl?: boolean
showGratitudeControl?: boolean
showThemeControl?: boolean
+ showZoomControl?: boolean
infoText?: string
donationWidget?: boolean
defaultTheme?: string