2025-10-20 14:39:53 +00:00
|
|
|
<script lang="ts">
|
2026-08-29 17:20:39 +00:00
|
|
|
import type {Maybe} from "@welshman/lib"
|
2026-01-29 19:11:08 +00:00
|
|
|
import {isMobile} from "@lib/html"
|
2025-10-20 14:39:53 +00:00
|
|
|
import Button from "@lib/components/Button.svelte"
|
|
|
|
|
import Tippy from "@lib/components/Tippy.svelte"
|
2026-08-29 17:20:39 +00:00
|
|
|
import type {TippyController} from "@lib/components/Tippy.svelte"
|
2026-03-11 23:15:37 +00:00
|
|
|
import IconPickerModal from "@app/components/IconPickerModal.svelte"
|
|
|
|
|
import IconPickerPopover from "@app/components/IconPickerPopover.svelte"
|
2026-06-08 21:14:40 +00:00
|
|
|
import {pushModal, popModal} from "@app/modal"
|
2025-10-20 14:39:53 +00:00
|
|
|
|
|
|
|
|
const {...props} = $props()
|
|
|
|
|
|
2026-01-29 19:11:08 +00:00
|
|
|
const open = () => {
|
|
|
|
|
if (isMobile) {
|
2026-03-11 23:29:24 +00:00
|
|
|
pushModal(IconPickerModal, {onSelect: onClick}, {nested: true})
|
2026-01-29 19:11:08 +00:00
|
|
|
} else {
|
2026-08-29 17:20:39 +00:00
|
|
|
tippy?.show()
|
2026-01-29 19:11:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const close = () => {
|
|
|
|
|
if (isMobile) {
|
2026-03-11 23:29:24 +00:00
|
|
|
popModal()
|
2026-01-29 19:11:08 +00:00
|
|
|
} else {
|
2026-08-29 17:20:39 +00:00
|
|
|
tippy?.hide()
|
2026-01-29 19:11:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
2025-10-20 14:39:53 +00:00
|
|
|
|
|
|
|
|
const onClick = (iconUrl: string) => {
|
|
|
|
|
props.onSelect(iconUrl)
|
2026-01-29 19:11:08 +00:00
|
|
|
close()
|
2025-10-20 14:39:53 +00:00
|
|
|
}
|
|
|
|
|
|
2026-08-29 17:20:39 +00:00
|
|
|
let tippy: Maybe<TippyController> = $state()
|
2025-10-20 14:39:53 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<Tippy
|
2026-08-29 17:20:39 +00:00
|
|
|
bind:controller={tippy}
|
2026-03-11 23:15:37 +00:00
|
|
|
component={IconPickerPopover}
|
2026-09-26 05:28:23 +00:00
|
|
|
strayMargin={50}
|
2025-10-20 14:39:53 +00:00
|
|
|
props={{onSelect: onClick}}
|
2026-02-10 01:40:10 +00:00
|
|
|
params={{trigger: "manual", interactive: true, placement: "top-end"}}>
|
2025-10-20 14:39:53 +00:00
|
|
|
<Button onclick={open} class={props.class}>
|
|
|
|
|
{@render props.children?.()}
|
|
|
|
|
</Button>
|
|
|
|
|
</Tippy>
|