Move contexts over to useXContext model

Fixes #4
This commit is contained in:
Ryan Gossiaux
2021-12-15 10:13:01 -08:00
parent f1edb17609
commit dbfb2c227e
12 changed files with 85 additions and 31 deletions

View File

@@ -5,11 +5,16 @@
isFocusWithinPopoverGroup(): boolean;
closeOthers(buttonId: string): void;
}
const POPOVER_GROUP_CONTEXT_NAME = "PopoverGroupContext";
export function usePopoverGroupContext(): PopoverGroupContext | undefined {
return getContext(POPOVER_GROUP_CONTEXT_NAME);
}
</script>
<script lang="ts">
import type { PopoverRegisterBag } from "./Popover.svelte";
import { setContext } from "svelte";
import { getContext, setContext } from "svelte";
let groupRef: HTMLDivElement | undefined;
let popovers: PopoverRegisterBag[] = [];
@@ -44,7 +49,7 @@
}
}
setContext("PopoverGroup", {
setContext(POPOVER_GROUP_CONTEXT_NAME, {
unregisterPopover,
registerPopover,
isFocusWithinPopoverGroup,