Skip to content

Commit

Permalink
extend useLink interface to accept initialProps
Browse files Browse the repository at this point in the history
  • Loading branch information
Stassi committed Nov 14, 2024
1 parent 8b004bb commit 7409f2f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 4 additions & 6 deletions public/leaflet-fullscreen/fullscreen-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ export function fullscreenMap({
const { get: getFullscreenState, toggle: toggleFullscreenState } =
useBoolean(false),
container = DomUtil.create('div', joinClassNames(containerClassNames)),
{ assign: linkAssign, onClick: onLinkClick } = useLink(
Object.assign(
DomUtil.create('a', joinClassNames(linkClassNames), container),
{ href: '#' },
),
),
{ assign: linkAssign, onClick: onLinkClick } = useLink({
element: DomUtil.create('a', joinClassNames(linkClassNames), container),
initialProps: { href: '#' },
}),
control = leafletControl({ position }),
map = leafletMap(id, mapOptions),
handleMapLifecycleChange = (documentFirstReady) =>
Expand Down
12 changes: 8 additions & 4 deletions public/leaflet-fullscreen/state/use-link.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { DomEvent } from '../../leaflet/leaflet-src.esm.js'

export function useLink(element) {
export function useLink({ element, initialProps }) {
function assign(props) {
Object.assign(element, props)
}

assign(initialProps)

return {
assign(props) {
Object.assign(element, props)
},
assign,
onClick(handler) {
DomEvent.on(element, 'click', handler)
},
Expand Down

0 comments on commit 7409f2f

Please sign in to comment.