Skip to content

Commit

Permalink
fullscreen.state.get: UseBooleanGet replaces <boolean>fullscreen
Browse files Browse the repository at this point in the history
…& export `SetControlAnchorTitleOptions` subtypes:

- AnchorAssignTitleOptions
- ControlAnchorTitleStates
  • Loading branch information
Stassi committed Nov 15, 2024
1 parent efaed00 commit 4040f07
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/leaf/map/fullscreen/control/set-control-anchor-title.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import { type UseAnchor } from '../state/use-anchor'
import { type AnchorAssign } from '../state/use-anchor'
import { type UseBooleanGet } from '../state/use-boolean'

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

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

export function setControlAnchorTitle({
anchor: { assign: anchorAssign, titleStates: anchorTitleStates },
fullscreen,
fullscreen: {
state: { get: getFullscreenState },
},
}: SetControlAnchorTitleOptions): HTMLElement {
return anchorAssign({
title:
anchorTitleStates[
<keyof SetControlAnchorTitleOptions['anchor']['titleStates']>(
fullscreen.toString()
)
<keyof ControlAnchorTitleStates>getFullscreenState().toString()
],
})
}

0 comments on commit 4040f07

Please sign in to comment.