Skip to content

Commit

Permalink
Merge pull request #8 from huntabyte/fix/dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte authored Aug 8, 2023
2 parents aea094c + fe27357 commit 4692b9b
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-cobras-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@huntabyte/primitives": patch
---

[Menu Primitives] Fix `sideOffset` prop
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ node_modules
pnpm-lock.yaml
package-lock.json
yarn.lock
.changeset/
.prettierrc
package.json
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ node_modules
pnpm-lock.yaml
package-lock.json
yarn.lock
.changeset/
.prettierrc
package.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Primitives
# Primitives (WIP)

Headless Svelte components built with [Melt UI](https://melt-ui.com) builders.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { melt } from "@melt-ui/svelte";
import type { ContentProps } from "../types.js";
import { ctx } from "../ctx.js";
import type { Transition } from "$internal/types.js";
type T = $$Generic<Transition>;
type $$Props = ContentProps<T>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import type { TriggerProps } from "../types.js";
type $$Props = TriggerProps;
export let asChild: boolean = false;
export let asChild = false;
const trigger = ctx.get().elements.trigger;
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import type { ContentProps } from "../types.js";
type $$Props = ContentProps;
const {
elements: { menu: content },
states: { open }
} = ctx.get();
export let sideOffset: $$Props["sideOffset"] = 5;
const { content, open } = ctx.getContent(sideOffset);
</script>

{#if $open}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/primitives/context-menu/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function getSubTrigger() {
return subTrigger;
}

function getContent(sideoffset = -4) {
function getContent(sideoffset = 5) {
const {
elements: { menu: content },
states: { open },
Expand Down
4 changes: 3 additions & 1 deletion src/lib/primitives/context-menu/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ type RadioGroupProps = Expand<
> &
HTMLDivAttributes;

type ContentProps = HTMLDivAttributes;
type ContentProps = {
sideOffset?: number;
} & HTMLDivAttributes;
type GroupProps = HTMLDivAttributes;
type ItemProps = HTMLDivAttributes;
type CheckboxItemIndicatorProps = HTMLDivAttributes;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/primitives/dialog/components/DialogOverlay.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script lang="ts">
import { melt } from "@melt-ui/svelte";
import { ctx } from "../ctx.js";
import type { AlertDialogOverlayProps } from "../types.js";
import type { OverlayProps } from "../types.js";
type $$Props = AlertDialogOverlayProps;
type $$Props = OverlayProps;
const overlay = ctx.getOverlay();
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import type { ContentProps } from "../types.js";
type $$Props = ContentProps;
const { open, content } = ctx.getContent();
export let sideOffset: $$Props["sideOffset"] = 5;
const { open, content } = ctx.getContent(sideOffset);
</script>

{#if $open}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/primitives/dropdown-menu/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function getSubTrigger() {
return subTrigger;
}

function getContent(sideoffset = -4) {
function getContent(sideoffset = 5) {
const {
elements: { menu: content },
states: { open },
Expand Down
4 changes: 3 additions & 1 deletion src/lib/primitives/dropdown-menu/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ type RadioGroupProps = Expand<
> &
HTMLDivAttributes;

type ContentProps = HTMLDivAttributes;
type ContentProps = {
sideOffset?: number;
} & HTMLDivAttributes;
type GroupProps = HTMLDivAttributes;
type ItemProps = HTMLDivAttributes;
type CheckboxItemIndicatorProps = HTMLDivAttributes;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/primitives/menubar/components/MenubarContent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import type { ContentProps } from "../types.js";
type $$Props = ContentProps;
export let sideOffset = 4;
const { content, open } = ctx.getContent(sideOffset);
export let sideOffset: $$Props["sideOffset"] = 4;
const { content } = ctx.getContent(sideOffset);
</script>

<div use:melt={$content} {...$$restProps}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import type { SubContentProps } from "../types.js";
type $$Props = SubContentProps;
const { subContent, subOpen } = ctx.getSubContent();
const { subContent } = ctx.getSubContent();
</script>

<div use:melt={$subContent} {...$$restProps}>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/primitives/menubar/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function getSubTrigger() {
return subTrigger;
}

function getContent(sideOffset = 4) {
function getContent(sideOffset = 5) {
const {
elements: { menu: content },
states: { open },
Expand Down
2 changes: 1 addition & 1 deletion src/lib/primitives/select/components/Select.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
export let label: $$Props["label"] = undefined;
const {
states: { open: localOpen, value: localValue, valueLabel },
states: { open: localOpen, value: localValue },
updateOption
} = ctx.set({
required,
Expand Down

0 comments on commit 4692b9b

Please sign in to comment.