Skip to content

Commit

Permalink
anchor contains assign & titleStates
Browse files Browse the repository at this point in the history
  • Loading branch information
Stassi committed Nov 15, 2024
1 parent 3f4ed46 commit ed45db2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
8 changes: 5 additions & 3 deletions src/leaf/map/fullscreen/control/control-added-listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type ControlAddedListenerOptions = {
anchor: {
assign: UseAnchor['assign']
onClick: UseAnchor['onClick']
titleStates: SetControlAnchorTitleOptions['anchorTitleStates']
titleStates: SetControlAnchorTitleOptions['anchor']['titleStates']
}
container: { element: HTMLElement }
}
Expand All @@ -40,8 +40,10 @@ export function controlAddedListener({
}: ControlAddedListenerOptions): ControlAddedListener {
return function handleControlAdded(map: Map): HTMLElement {
setControlAnchorTitle({
anchorAssign,
anchorTitleStates,
anchor: {
assign: anchorAssign,
titleStates: anchorTitleStates,
},
fullscreen: getFullscreenState(),
})

Expand Down
11 changes: 6 additions & 5 deletions src/leaf/map/fullscreen/control/set-control-anchor-title.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { type UseAnchor } from '../state/use-anchor'

export type SetControlAnchorTitleOptions = {
anchorAssign: UseAnchor['assign']
anchorTitleStates: Record<'false' | 'true', string>
anchor: {
assign: UseAnchor['assign']
titleStates: Record<'false' | 'true', string>
}
fullscreen: boolean
}

export function setControlAnchorTitle({
anchorAssign,
anchorTitleStates,
anchor: { assign: anchorAssign, titleStates: anchorTitleStates },
fullscreen,
}: SetControlAnchorTitleOptions): HTMLElement {
return anchorAssign({
title:
anchorTitleStates[
<keyof SetControlAnchorTitleOptions['anchorTitleStates']>(
<keyof SetControlAnchorTitleOptions['anchor']['titleStates']>(
fullscreen.toString()
)
],
Expand Down
2 changes: 1 addition & 1 deletion src/leaf/map/fullscreen/fullscreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type FullscreenMapOptions = MapOptions & {
anchor: {
attributes: Record<string, string>
tag: string
titleStates: SetControlAnchorTitleOptions['anchorTitleStates']
titleStates: SetControlAnchorTitleOptions['anchor']['titleStates']
}
container: {
tag: string
Expand Down
5 changes: 2 additions & 3 deletions src/leaf/map/fullscreen/map/map-lifecycle-listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type MapLifecycleListenerOptions = {
control: {
anchor: {
assign: UseAnchor['assign']
titleStates: SetControlAnchorTitleOptions['anchorTitleStates']
titleStates: SetControlAnchorTitleOptions['anchor']['titleStates']
}
}
fullscreen: {
Expand Down Expand Up @@ -57,8 +57,7 @@ export function mapLifecycleListener({
map.invalidateSize()
toggleFullscreenState()
setControlAnchorTitle({
anchorAssign,
anchorTitleStates,
anchor: { assign: anchorAssign, titleStates: anchorTitleStates },
fullscreen: getFullscreenState(),
})
},
Expand Down

0 comments on commit ed45db2

Please sign in to comment.