Skip to content

Commit

Permalink
control/anchor integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Stassi committed Nov 15, 2024
1 parent a9e99f1 commit ed87c6c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/leaf/map/fullscreen/control/control-added-listener.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DomEvent, type Map } from 'leaflet'

import { type UseAnchor } from '../state/use-anchor'
import { type UseBooleanGet } from '../state/use-boolean'

import { type ControlAnchor } from './anchor/anchor'
import {
type AnchorAssignTitleOptions,
setControlAnchorTitle,
Expand All @@ -11,7 +11,7 @@ import {
export type ControlAddedListenerOptions = {
map: {
control: {
anchor: AnchorAssignTitleOptions & UseAnchor
anchor: AnchorAssignTitleOptions & ControlAnchor
container: { element: HTMLElement }
}
fullscreen: { state: { get: UseBooleanGet } }
Expand Down
5 changes: 3 additions & 2 deletions src/leaf/map/fullscreen/control/set-control-anchor-title.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { type AnchorAssign } from '../state/use-anchor'
import { type UseBooleanGet } from '../state/use-boolean'

import { type ControlAnchorAssign } from './anchor/anchor'

export type ControlAnchorTitleStates = Record<'false' | 'true', string>
export type AnchorAssignTitleOptions = {
assign: AnchorAssign
assign: ControlAnchorAssign
titleStates: ControlAnchorTitleStates
}

Expand Down
27 changes: 14 additions & 13 deletions src/leaf/map/fullscreen/fullscreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import {
mapLifecycleListener,
} from './map/map-lifecycle-listener'
import {
type AnchorAttributes,
type UseAnchor,
useAnchor,
} from './state/use-anchor'
type ControlAnchor,
type ControlAnchorAttributes,
controlAnchor,
} from './control/anchor/anchor'
import { useBoolean } from './state/use-boolean'

const leafletControl = <(options: ControlOptions) => Control>(
Expand All @@ -36,7 +36,7 @@ export type FullscreenMapOptions = MapOptions & {
}
control: {
anchor: {
attributes: AnchorAttributes
attributes: ControlAnchorAttributes
tag: string
titleStates: ControlAnchorTitleStates
}
Expand Down Expand Up @@ -98,14 +98,15 @@ export function fullscreenMap({
containerTag,
joinClassNames(containerClassNames),
),
{ assign: anchorAssign, onClick: anchorOnClick }: UseAnchor = useAnchor({
attributes: anchorAttributes,
element: DomUtil.create(
anchorTag,
joinClassNames(anchorClassNames),
containerElement,
),
}),
{ assign: anchorAssign, onClick: anchorOnClick }: ControlAnchor =
controlAnchor({
attributes: anchorAttributes,
element: DomUtil.create(
anchorTag,
joinClassNames(anchorClassNames),
containerElement,
),
}),
control: Control = leafletControl({ position }),
map: Map = leafletMap(id, mapOptions),
handleMapLifecycleChange: (
Expand Down
4 changes: 2 additions & 2 deletions src/leaf/map/fullscreen/map/map-lifecycle-listener.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DomEvent, DomUtil, type Map } from 'leaflet'

import { type AnchorAssign } from '../state/use-anchor'
import { type ControlAnchorAssign } from '../control/anchor/anchor'
import { type UseBoolean } from '../state/use-boolean'
import {
setControlAnchorTitle,
Expand All @@ -13,7 +13,7 @@ export type MapLifecycleListenerOptions = {
map: {
control: {
anchor: {
assign: AnchorAssign
assign: ControlAnchorAssign
titleStates: ControlAnchorTitleStates
}
}
Expand Down

0 comments on commit ed87c6c

Please sign in to comment.