Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
a3a5b52d
Commit
a3a5b52d
authored
Apr 15, 2026
by
boojack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: tweak location picker
parent
ab533290
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
22 deletions
+27
-22
LocationDialog.tsx
web/src/components/MemoMetadata/Location/LocationDialog.tsx
+2
-2
LocationPicker.tsx
web/src/components/map/LocationPicker.tsx
+25
-20
No files found.
web/src/components/MemoMetadata/Location/LocationDialog.tsx
View file @
a3a5b52d
...
@@ -35,7 +35,7 @@ export const LocationDialog = ({
...
@@ -35,7 +35,7 @@ export const LocationDialog = ({
return
(
return
(
<
Dialog
open=
{
open
}
onOpenChange=
{
onOpenChange
}
>
<
Dialog
open=
{
open
}
onOpenChange=
{
onOpenChange
}
>
<
DialogContent
className=
"max-w-[min(28rem,calc(100vw-2rem))] p-0!"
>
<
DialogContent
className=
"max-w-[min(28rem,calc(100vw-2rem))] p-0!"
showCloseButton=
{
false
}
>
<
VisuallyHidden
>
<
VisuallyHidden
>
<
DialogClose
/>
<
DialogClose
/>
</
VisuallyHidden
>
</
VisuallyHidden
>
...
@@ -47,7 +47,7 @@ export const LocationDialog = ({
...
@@ -47,7 +47,7 @@ export const LocationDialog = ({
</
VisuallyHidden
>
</
VisuallyHidden
>
<
div
className=
"flex flex-col"
>
<
div
className=
"flex flex-col"
>
<
div
className=
"w-full h-64 overflow-hidden rounded-t-md bg-muted/30"
>
<
div
className=
"w-full h-64 overflow-hidden rounded-t-md bg-muted/30"
>
<
LocationPicker
latlng=
{
position
}
onChange=
{
onPositionChange
}
/>
<
LocationPicker
className=
"h-full"
latlng=
{
position
}
onChange=
{
onPositionChange
}
/>
</
div
>
</
div
>
<
div
className=
"w-full flex flex-col p-3 gap-3"
>
<
div
className=
"w-full flex flex-col p-3 gap-3"
>
<
div
className=
"grid grid-cols-2 gap-3"
>
<
div
className=
"grid grid-cols-2 gap-3"
>
...
...
web/src/components/map/LocationPicker.tsx
View file @
a3a5b52d
...
@@ -6,26 +6,25 @@ import { MapContainer, Marker, useMap, useMapEvents } from "react-leaflet";
...
@@ -6,26 +6,25 @@ import { MapContainer, Marker, useMap, useMapEvents } from "react-leaflet";
import
{
cn
}
from
"@/lib/utils"
;
import
{
cn
}
from
"@/lib/utils"
;
import
{
defaultMarkerIcon
,
ThemedTileLayer
}
from
"./map-utils"
;
import
{
defaultMarkerIcon
,
ThemedTileLayer
}
from
"./map-utils"
;
interface
MarkerProps
{
interface
Location
MarkerProps
{
position
:
LatLng
|
undefined
;
position
:
LatLng
|
undefined
;
onChange
:
(
position
:
LatLng
)
=>
void
;
onChange
:
(
position
:
LatLng
)
=>
void
;
readonly
?:
boolean
;
readonly
?:
boolean
;
}
}
const
LocationMarker
=
(
props
:
MarkerProps
)
=>
{
const
LocationMarker
=
(
{
position
:
initialPosition
,
onChange
,
readonly
:
readOnly
}:
Location
MarkerProps
)
=>
{
const
[
position
,
setPosition
]
=
useState
(
props
.
p
osition
);
const
[
position
,
setPosition
]
=
useState
(
initialP
osition
);
const
initializedRef
=
useRef
(
false
);
const
initializedRef
=
useRef
(
false
);
const
map
=
useMapEvents
({
const
map
=
useMapEvents
({
click
(
e
)
{
click
(
e
)
{
if
(
props
.
reado
nly
)
{
if
(
readO
nly
)
{
return
;
return
;
}
}
setPosition
(
e
.
latlng
);
setPosition
(
e
.
latlng
);
map
.
locate
();
map
.
locate
();
// Call the parent onChange function.
onChange
(
e
.
latlng
);
props
.
onChange
(
e
.
latlng
);
},
},
locationfound
()
{},
locationfound
()
{},
});
});
...
@@ -37,15 +36,14 @@ const LocationMarker = (props: MarkerProps) => {
...
@@ -37,15 +36,14 @@ const LocationMarker = (props: MarkerProps) => {
}
}
},
[
map
]);
},
[
map
]);
// Keep marker and map in sync with external position updates
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
props
.
p
osition
)
{
if
(
initialP
osition
)
{
setPosition
(
props
.
p
osition
);
setPosition
(
initialP
osition
);
map
.
setView
(
props
.
p
osition
);
map
.
setView
(
initialP
osition
);
}
else
{
}
else
{
setPosition
(
undefined
);
setPosition
(
undefined
);
}
}
},
[
props
.
p
osition
,
map
]);
},
[
initialP
osition
,
map
]);
return
position
===
undefined
?
null
:
<
Marker
position=
{
position
}
icon=
{
defaultMarkerIcon
}
></
Marker
>;
return
position
===
undefined
?
null
:
<
Marker
position=
{
position
}
icon=
{
defaultMarkerIcon
}
></
Marker
>;
};
};
...
@@ -197,22 +195,29 @@ const MapCleanup = () => {
...
@@ -197,22 +195,29 @@ const MapCleanup = () => {
return
null
;
return
null
;
};
};
interface
Map
Props
{
interface
LocationPicker
Props
{
readonly
?:
boolean
;
readonly
?:
boolean
;
latlng
?:
LatLng
;
latlng
?:
LatLng
;
onChange
?:
(
position
:
LatLng
)
=>
void
;
onChange
?:
(
position
:
LatLng
)
=>
void
;
className
?:
string
;
}
}
const
DEFAULT_CENTER_LAT_LNG
=
new
LatLng
(
48.8584
,
2.2945
);
const
DEFAULT_CENTER_LAT_LNG
=
new
LatLng
(
48.8584
,
2.2945
);
const
noopOnLocationChange
=
()
=>
{};
const
L
eafletMap
=
(
props
:
Map
Props
)
=>
{
const
L
ocationPicker
=
({
readonly
:
readOnly
=
false
,
latlng
,
onChange
=
noopOnLocationChange
,
className
}:
LocationPicker
Props
)
=>
{
const
position
=
props
.
latlng
||
DEFAULT_CENTER_LAT_LNG
;
const
position
=
latlng
||
DEFAULT_CENTER_LAT_LNG
;
const
statusLabel
=
props
.
readonly
?
"Pinned location"
:
props
.
latlng
?
"Selected location"
:
"Choose a location"
;
const
statusLabel
=
readOnly
?
"Pinned location"
:
latlng
?
"Selected location"
:
"Choose a location"
;
return
(
return
(
<
div
className=
"memo-location-map relative isolate w-full overflow-hidden rounded-xl border border-border bg-background shadow-sm"
>
<
div
className=
{
cn
(
"memo-location-map relative isolate h-72 w-full overflow-hidden rounded-xl border border-border bg-background shadow-sm"
,
className
,
)
}
>
<
MapContainer
<
MapContainer
className=
"h-
72
w-full !bg-muted"
className=
"h-
full
w-full !bg-muted"
center=
{
position
}
center=
{
position
}
zoom=
{
13
}
zoom=
{
13
}
scrollWheelZoom=
{
false
}
scrollWheelZoom=
{
false
}
...
@@ -220,8 +225,8 @@ const LeafletMap = (props: MapProps) => {
...
@@ -220,8 +225,8 @@ const LeafletMap = (props: MapProps) => {
attributionControl=
{
false
}
attributionControl=
{
false
}
>
>
<
ThemedTileLayer
/>
<
ThemedTileLayer
/>
<
LocationMarker
position=
{
position
}
readonly=
{
props
.
readonly
}
onChange=
{
props
.
onChange
?
props
.
onChange
:
()
=>
{}
}
/>
<
LocationMarker
position=
{
position
}
readonly=
{
readOnly
}
onChange=
{
onChange
}
/>
<
MapControls
position=
{
props
.
latlng
}
/>
<
MapControls
position=
{
latlng
}
/>
<
MapCleanup
/>
<
MapCleanup
/>
</
MapContainer
>
</
MapContainer
>
...
@@ -234,4 +239,4 @@ const LeafletMap = (props: MapProps) => {
...
@@ -234,4 +239,4 @@ const LeafletMap = (props: MapProps) => {
);
);
};
};
export
default
L
eafletMap
;
export
default
L
ocationPicker
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment