Skip to content

Commit

Permalink
cleanup context menu radio item
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte committed Aug 3, 2023
1 parent d1e2541 commit 7e567de
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
showBookmarks: writable(true),
showFullURLs: writable(false)
};
const peopleRadioValue = writable("pedro");
</script>

<ContextMenu>
Expand Down Expand Up @@ -49,7 +51,7 @@
Show Full URLs
</ContextMenu.CheckboxItem>
<ContextMenu.Separator />
<ContextMenu.RadioGroup defaultValue="pedro">
<ContextMenu.RadioGroup value={peopleRadioValue}>
<ContextMenu.Label inset>People</ContextMenu.Label>
<ContextMenu.Separator />
<ContextMenu.RadioItem value="pedro">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<script lang="ts">
import type { HTMLAttributes } from "svelte/elements";
import { writable } from "svelte/store";
import { ctx, melt, type ContextRadioGroupProps } from ".";
let className: string | undefined | null = undefined;
export { className as class };
export let defaultValue: ContextRadioGroupProps["defaultValue"] = undefined;
export let value: ContextRadioGroupProps["value"] = writable(defaultValue);
export let onValueChange: ContextRadioGroupProps["onValueChange"] =
undefined;
type $$Props = HTMLAttributes<HTMLDivElement> &
ContextRadioGroupProps & {
class?: string | null;
};
const { radioGroup } = ctx.setRadioGroup($$restProps);
const radioGroup = ctx.setRadioGroup({
value,
onValueChange
});
$: console.log($value);
</script>

<div use:melt={$radioGroup} class={className} {...$$restProps}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { ctx, type DropdownSubmenuProps } from ".";
type $$Props = DropdownSubmenuProps;
import { ctx, type ContextSubmenuProps } from ".";
type $$Props = ContextSubmenuProps;
ctx.setSub($$restProps);
</script>

Expand Down
10 changes: 5 additions & 5 deletions apps/www/src/lib/components/ui/context-menu/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function get() {
}

function set(props: ContextMenuProps) {
const contextMenu = createContextMenu({ ...props, forceVisible: true });
const contextMenu = createContextMenu({ ...props });
setContext(NAME, contextMenu);
}

Expand All @@ -68,12 +68,12 @@ function setRadioGroup(props: ContextRadioGroupProps) {
const {
builders: { createMenuRadioGroup }
} = get();
const dropdownRadioGroup = createMenuRadioGroup(props);
setContext(RADIO_GROUP_NAME, dropdownRadioGroup);
const contextRadioGroup = createMenuRadioGroup(props);
setContext(RADIO_GROUP_NAME, contextRadioGroup);
const {
elements: { radioGroup }
} = dropdownRadioGroup;
return { radioGroup };
} = contextRadioGroup;
return radioGroup;
}

function getRadioItem() {
Expand Down

0 comments on commit 7e567de

Please sign in to comment.