mapcomplete/UI/Base/IfNot.svelte

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
446 B
Svelte
Raw Normal View History

2023-03-28 05:13:48 +02:00
<script lang="ts">
import { UIEventSource } from "../../Logic/UIEventSource"
import { onDestroy } from "svelte"
2023-03-28 05:13:48 +02:00
/**
* For some stupid reason, it is very hard to let {#if} work together with UIEventSources, so we wrap then here
*/
export let condition: UIEventSource<boolean>
let _c = !condition.data
onDestroy(
condition.addCallback((c) => {
_c = !c
return false
})
)
2023-03-28 05:13:48 +02:00
</script>
{#if _c}
<slot />
2023-03-28 05:13:48 +02:00
{/if}