Skip to content

Commit

Permalink
next: Menubar (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte authored Jun 12, 2024
1 parent ba7ebfa commit c83f4a2
Show file tree
Hide file tree
Showing 229 changed files with 1,613 additions and 1,676 deletions.
4 changes: 3 additions & 1 deletion packages/bits-ui/src/lib/bits/accordion/accordion.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type AccordionBaseStateProps = ReadableBoxedValues<{
disabled: boolean;
orientation: Orientation;
loop: boolean;
ref: HTMLElement | null | undefined;
}>;

class AccordionBaseState {
Expand All @@ -48,7 +49,7 @@ class AccordionBaseState {
this.orientation = props.orientation;
this.#loop = props.loop;
this.rovingFocusGroup = useRovingFocus({
rootNode: this.node,
rootNodeId: this.id,
candidateSelector: TRIGGER_ATTR,
loop: this.#loop,
orientation: this.orientation,
Expand Down Expand Up @@ -356,6 +357,7 @@ type InitAccordionProps = {
disabled: boolean;
orientation: Orientation;
loop: boolean;
ref: HTMLElement | null | undefined;
}>;

const [setAccordionRootContext, getAccordionRootContext] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@
let {
child,
asChild,
el = $bindable(),
ref = $bindable(),
id = useId(),
forceMount = false,
children,
...restProps
}: AccordionContentProps = $props();
const state = useAccordionContent({
const contentState = useAccordionContent({
forceMount: box.with(() => forceMount),
id: box.with(() => id),
});
</script>

<PresenceLayer forceMount={true} present={state.present} {id}>
<PresenceLayer forceMount={true} present={contentState.present} {id}>
{#snippet presence({ present })}
{@const mergedProps = mergeProps(restProps, state.props, {
{@const mergedProps = mergeProps(restProps, contentState.props, {
hidden: !present.value,
})}
{#if asChild}
{@render child?.({
props: mergedProps,
})}
{:else}
<div {...mergedProps} bind:this={el}>
<div {...mergedProps} bind:this={ref}>
{@render children?.()}
</div>
{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
level = 2,
children,
child,
el = $bindable(),
ref = $bindable(),
...restProps
}: AccordionHeaderProps = $props();
const state = useAccordionHeader({
const headerState = useAccordionHeader({
level: box.with(() => level),
});
const mergedProps = $derived(mergeProps(restProps, state.props));
const mergedProps = $derived(mergeProps(restProps, headerState.props));
</script>

{#if asChild}
{@render child?.({ props: mergedProps })}
{:else}
<div {...mergedProps} bind:this={el}>
<div {...mergedProps} bind:this={ref}>
{@render children?.()}
</div>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
value,
children,
child,
el = $bindable(),
ref = $bindable(),
...restProps
}: AccordionItemProps = $props();
const state = useAccordionItem({
const itemState = useAccordionItem({
value: box.with(() => value),
disabled: box.with(() => disabled),
});
const mergedProps = $derived(mergeProps(restProps, state.props));
const mergedProps = $derived(mergeProps(restProps, itemState.props));
</script>

{#if asChild}
{@render child?.({ props: mergedProps })}
{:else}
<div {...mergedProps} bind:this={el}>
<div {...mergedProps} bind:this={ref}>
{@render children?.()}
</div>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@
let {
disabled = false,
asChild,
el = $bindable(),
ref = $bindable(),
id = useId(),
children,
child,
...restProps
}: AccordionTriggerProps = $props();
const state = useAccordionTrigger({
const triggerState = useAccordionTrigger({
disabled: box.with(() => disabled),
id: box.with(() => id),
});
const mergedProps = $derived(mergeProps(restProps, state.props));
const mergedProps = $derived(mergeProps(restProps, triggerState.props));
</script>

{#if asChild}
{@render child?.({ props: mergedProps })}
{:else}
<button bind:this={el} type="button" {...mergedProps}>
<button bind:this={ref} type="button" {...mergedProps}>
{@render children?.()}
</button>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
child,
type,
value = $bindable(),
el = $bindable(),
ref = $bindable(),
id = useId(),
onValueChange,
loop = true,
Expand All @@ -22,7 +22,7 @@
value === undefined && (value = type === "single" ? "" : []);
const state = useAccordionRoot({
const rootState = useAccordionRoot({
type,
value: box.with(
() => value!,
Expand All @@ -35,15 +35,16 @@
disabled: box.with(() => disabled),
loop: box.with(() => loop),
orientation: box.with(() => orientation),
ref: box.with(() => ref),
});
const mergedProps = $derived(mergeProps(restProps, state.props));
const mergedProps = $derived(mergeProps(restProps, rootState.props));
</script>

{#if asChild}
{@render child?.({ props: mergedProps })}
{:else}
<div bind:this={el} {...mergedProps}>
<div bind:this={ref} {...mergedProps}>
{@render children?.()}
</div>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<slot {builder} />
{:else}
<button
bind:this={el}
bind:this={ref}
use:melt={builder}
type="button"
{...$$restProps}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<slot {builder} />
{:else}
<button
bind:this={el}
bind:this={ref}
use:melt={builder}
type="button"
{...$$restProps}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<slot {builder} />
{:else if transition && $open}
<div
bind:this={el}
bind:this={ref}
transition:transition={transitionConfig}
use:melt={builder}
on:pointerdown
Expand All @@ -56,7 +56,7 @@
</div>
{:else if inTransition && outTransition && $open}
<div
bind:this={el}
bind:this={ref}
in:inTransition={inTransitionConfig}
out:outTransition={outTransitionConfig}
use:melt={builder}
Expand All @@ -73,7 +73,7 @@
</div>
{:else if inTransition && $open}
<div
bind:this={el}
bind:this={ref}
in:inTransition={inTransitionConfig}
use:melt={builder}
on:pointerdown
Expand All @@ -89,7 +89,7 @@
</div>
{:else if outTransition && $open}
<div
bind:this={el}
bind:this={ref}
out:outTransition={outTransitionConfig}
use:melt={builder}
on:pointerdown
Expand All @@ -105,7 +105,7 @@
</div>
{:else if $open}
<div
bind:this={el}
bind:this={ref}
use:melt={builder}
on:pointerdown
on:pointermove
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{#if asChild}
<slot {builder} />
{:else}
<div bind:this={el} use:melt={builder} {...$$restProps}>
<div bind:this={ref} use:melt={builder} {...$$restProps}>
<slot {builder} />
</div>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,28 @@
<slot {builder} />
{:else if transition && $open}
<div
bind:this={el}
bind:this={ref}
transition:transition={transitionConfig}
use:melt={builder}
{...$$restProps}
/>
{:else if inTransition && outTransition && $open}
<div
bind:this={el}
bind:this={ref}
in:inTransition={inTransitionConfig}
out:outTransition={outTransitionConfig}
use:melt={builder}
{...$$restProps}
/>
{:else if inTransition && $open}
<div bind:this={el} in:inTransition={inTransitionConfig} use:melt={builder} {...$$restProps} />
<div bind:this={ref} in:inTransition={inTransitionConfig} use:melt={builder} {...$$restProps} />
{:else if outTransition && $open}
<div
bind:this={el}
bind:this={ref}
out:outTransition={outTransitionConfig}
use:melt={builder}
{...$$restProps}
/>
{:else if $open}
<div bind:this={el} use:melt={builder} {...$$restProps} />
<div bind:this={ref} use:melt={builder} {...$$restProps} />
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{#if asChild}
<slot {builder} />
{:else}
<div bind:this={el} use:melt={builder} {...$$restProps}>
<div bind:this={ref} use:melt={builder} {...$$restProps}>
<slot {builder} />
</div>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{#if asChild}
<slot {builder} />
{:else}
<svelte:element this={level} bind:this={el} use:melt={builder} {...$$restProps}>
<svelte:element this={level} bind:this={ref} use:melt={builder} {...$$restProps}>
<slot {builder} />
</svelte:element>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<slot {builder} />
{:else}
<button
bind:this={el}
bind:this={ref}
use:melt={builder}
type="button"
on:m-click={dispatch}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script lang="ts">
import type { Props } from "../index.js";
let { ratio, children, el = $bindable(), ...restProps }: Props = $props();
let { ratio, children, ref = $bindable(), ...restProps }: Props = $props();
</script>

<div style:position="relative" style:width="100%" style:padding-bottom="{ratio ? 100 / ratio : 0}%">
<div
bind:this={el}
bind:this={ref}
style:position="absolute"
style:top="0"
style:right="0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
import { useAvatarFallback } from "../avatar.svelte.js";
import { mergeProps } from "$lib/internal/mergeProps.js";
let { asChild, children, child, el = $bindable(), ...restProps }: FallbackProps = $props();
let { asChild, children, child, ref = $bindable(), ...restProps }: FallbackProps = $props();
const state = useAvatarFallback();
const fallbackState = useAvatarFallback();
const mergedProps = $derived(mergeProps(restProps, state.props));
const mergedProps = $derived(mergeProps(restProps, fallbackState.props));
</script>

{#if asChild}
{@render child?.({ props: mergedProps })}
{:else}
<span bind:this={el} {...mergedProps}>
<span bind:this={ref} {...mergedProps}>
{@render children?.()}
</span>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
import { useAvatarImage } from "../avatar.svelte.js";
import { mergeProps } from "$lib/internal/mergeProps.js";
let { src, asChild, child, el = $bindable(), ...restProps }: ImageProps = $props();
let { src, asChild, child, ref = $bindable(), ...restProps }: ImageProps = $props();
const state = useAvatarImage({
const imageState = useAvatarImage({
src: box.with(() => src),
});
const mergedProps = $derived(mergeProps(restProps, state.props));
const mergedProps = $derived(mergeProps(restProps, imageState.props));
</script>

{#if asChild}
{@render child?.({ props: mergedProps })}
{:else}
<img bind:this={el} {...mergedProps} {src} />
<img bind:this={ref} {...mergedProps} {src} />
{/if}
Loading

0 comments on commit c83f4a2

Please sign in to comment.