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

@@ -1,5 +1,5 @@
<script lang="ts">
import type { StateDefinition } from "./SwitchGroup.svelte";
import { useSwitchContext } from "./SwitchGroup.svelte";
import type { LabelContext } from "$lib/components/label/LabelProvider.svelte";
import type { DescriptionContext } from "$lib/components/description/DescriptionProvider.svelte";
import { useId } from "$lib/hooks/use-id";
@@ -9,7 +9,7 @@
const dispatch = createEventDispatcher();
export let checked = false;
let api: Writable<StateDefinition> | undefined = getContext("SwitchApi");
let api = useSwitchContext();
let labelContext: Writable<LabelContext> | undefined = getContext(
"headlessui-label-context"
);