-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fullscreen.state.get: UseBooleanGet
replaces <boolean>fullscreen
…
…& export `SetControlAnchorTitleOptions` subtypes: - AnchorAssignTitleOptions - ControlAnchorTitleStates
- Loading branch information
Showing
1 changed file
with
14 additions
and
10 deletions.
There are no files selected for viewing
24 changes: 14 additions & 10 deletions
24
src/leaf/map/fullscreen/control/set-control-anchor-title.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
], | ||
}) | ||
} |