Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/lib/accordion/Accordion.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { createSingleSelectionContext } from "$lib/utils/singleselection.svelte";
import { untrack } from "svelte";

let { children, flush, multiple = false, class: className, transitionType, respectReducedMotion = true, classes, ...restProps }: AccordionProps = $props();
let { children, flush, multiple = false, class: className, transition, respectReducedMotion = true, classes, ...restProps }: AccordionProps = $props();

const theme = $derived(getTheme("accordion"));

Expand All @@ -16,8 +16,8 @@
get flush() {
return flush;
},
get transitionType() {
return transitionType;
get transition() {
return transition;
},
get respectReducedMotion() {
return respectReducedMotion;
Expand Down Expand Up @@ -51,7 +51,7 @@
@prop flush
@prop multiple = false
@prop class: className
@prop transitionType
@prop transition
@prop respectReducedMotion = true
@prop classes
@prop ...restProps
Expand Down
14 changes: 7 additions & 7 deletions src/lib/accordion/AccordionItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { prefersReducedMotion } from "svelte/motion";
import { accordionItem } from "./theme";

let { children, header, arrowup, arrowdown, open = $bindable(false), transitionType = slide, transitionParams, class: className, classes }: AccordionItemProps = $props();
let { children, header, arrowup, arrowdown, open = $bindable(false), transition = slide, transitionParams, class: className, classes }: AccordionItemProps = $props();

// Get context - it will be undefined if used outside Accordion
const ctx = getAccordionContext();
Expand All @@ -22,9 +22,9 @@
inactive: classes?.inactive || ctx?.classes?.inactive
});

const ctxTransitionType = $derived(ctx?.transitionType ?? transitionType);
// Check if transitionType is explicitly set to undefined in props
const useTransition = $derived(transitionType === "none" ? false : ctxTransitionType === "none" ? false : true);
const ctxTransitionType = $derived(ctx?.transition ?? transition);
// Check if transition is explicitly set to undefined in props
const useTransition = $derived(transition === "none" ? false : ctxTransitionType === "none" ? false : true);

// Get respectReducedMotion from context (defaults to true)
const ctxRespectReducedMotion = $derived(ctx?.respectReducedMotion ?? true);
Expand Down Expand Up @@ -81,8 +81,8 @@
</h2>

{#if useTransition}
{#if open && transitionType !== "none"}
<div data-part="content-wrapper" class={contentWrapperCls} transition:transitionType={effectiveTransitionParams as ParamsType}>
{#if open && transition !== "none"}
<div data-part="content-wrapper" class={contentWrapperCls} transition:transition={effectiveTransitionParams as ParamsType}>
<div data-part="content" class={content({ class: clsx(theme?.content, finalClasses.content) })}>
{@render children()}
</div>
Expand All @@ -107,7 +107,7 @@
@prop arrowup
@prop arrowdown
@prop open = $bindable(false)
@prop transitionType = slide
@prop transition = slide
@prop transitionParams
@prop class: className
@prop classes
Expand Down
6 changes: 3 additions & 3 deletions src/lib/alert/Alert.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class: className,
dismissable,
transition = fade,
params,
transitionParams,
listContent,
borderAccent,
closeButtonProps,
Expand All @@ -46,7 +46,7 @@
const isBrowser = typeof window !== "undefined";

// Respect reduced motion preference by setting duration to 0
const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...params, duration: 0 } : params);
const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...transitionParams, duration: 0 } : transitionParams);

let ref: HTMLDivElement | undefined = $state(undefined);

Expand Down Expand Up @@ -111,7 +111,7 @@
@prop class: className
@prop dismissable
@prop transition = fade
@prop params
@prop transitionParams
@prop listContent
@prop borderAccent
@prop closeButtonProps
Expand Down
6 changes: 3 additions & 3 deletions src/lib/badge/Badge.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
target,
rounded,
transition = fade,
params,
transitionParams,
closeButtonProps,
...restProps
}: BadgeProps = $props();
Expand All @@ -49,7 +49,7 @@
const isBrowser = typeof window !== "undefined";

// Respect reduced motion preference by setting duration to 0
const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...params, duration: 0 } : params);
const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...transitionParams, duration: 0 } : transitionParams);

let ref: HTMLDivElement | undefined = $state(undefined);

Expand Down Expand Up @@ -103,7 +103,7 @@
@prop target
@prop rounded
@prop transition = fade
@prop params
@prop transitionParams
@prop closeButtonProps
@prop ...restProps
-->
6 changes: 3 additions & 3 deletions src/lib/banner/Banner.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class: className,
classes,
transition = fade,
params,
transitionParams,
onclose,
closeButtonProps,
...restProps
Expand All @@ -35,7 +35,7 @@
const isBrowser = typeof window !== "undefined";

// Respect reduced motion preference by setting duration to 0
const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...params, duration: 0 } : params);
const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...transitionParams, duration: 0 } : transitionParams);

let ref: HTMLDivElement | undefined = $state(undefined);
function close(event: MouseEvent) {
Expand Down Expand Up @@ -86,7 +86,7 @@
@prop class: className
@prop classes
@prop transition = fade
@prop params
@prop transitionParams
@prop onclose
@prop closeButtonProps
@prop ...restProps
Expand Down
11 changes: 7 additions & 4 deletions src/lib/drawer/Drawer.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { innerWidth, innerHeight } from "svelte/reactivity/window";
import type { DrawerProps } from "$lib";
import Dialog from "$lib/dialog/Dialog.svelte";
import { getTheme } from "$lib/theme-provider/themeUtils";
Expand Down Expand Up @@ -71,12 +72,14 @@

// set the values for transition start position
const dlg = ev.currentTarget;
const { innerWidth = 0, innerHeight = 0 } = dlg.ownerDocument.defaultView ?? {};

const rect = dlg.getBoundingClientRect();

x = placement === "left" ? rect.left : placement === "right" ? rect.right - innerWidth : undefined;
y = placement === "top" ? rect.top : placement === "bottom" ? rect.bottom - innerHeight : undefined;
const vw = innerWidth.current ?? 0;
const vh = innerHeight.current ?? 0;

x = placement === "left" ? rect.left : placement === "right" ? rect.right - vw : undefined;

y = placement === "top" ? rect.top : placement === "bottom" ? rect.bottom - vh : undefined;

await tick(); // let transition start

Expand Down
9 changes: 8 additions & 1 deletion src/lib/forms/select/MultiSelect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,14 @@
{#if children}
{@render children({ item, clear: () => clearThisOption(item) })}
{:else}
<Badge color="gray" large={size === "lg"} dismissable params={{ duration: 100 }} onclose={() => clearThisOption(item)} class={["mx-0.5 px-2 py-0", disabled && "pointer-events-none"]}>
<Badge
color="gray"
large={size === "lg"}
dismissable
transitionParams={{ duration: 100 }}
onclose={() => clearThisOption(item)}
class={["mx-0.5 px-2 py-0", disabled && "pointer-events-none"]}
>
{item.name}
</Badge>
{/if}
Expand Down
18 changes: 8 additions & 10 deletions src/lib/sidebar/Sidebar.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { innerWidth } from "svelte/reactivity/window";
import type { Attachment } from "svelte/attachments";
import type { SidebarContextType, SidebarProps } from "$lib/types";
import { getTheme } from "$lib/theme-provider/themeUtils";
Expand All @@ -21,7 +22,7 @@
activateClickOutside = true,
backdrop = true,
transition = fly,
params,
transitionParams,
ariaLabel,
activeUrl = "",
class: className,
Expand All @@ -42,8 +43,7 @@
"2xl": 1536
};

let innerWidth: number = $state(-1);
let isLargeScreen = $derived(disableBreakpoints ? false : alwaysOpen || innerWidth >= breakpointValues[breakpoint]);
let isLargeScreen = $derived(disableBreakpoints ? false : alwaysOpen || (innerWidth.current ?? 0) >= breakpointValues[breakpoint]);

// Create reactive context for activeUrl using getter
const activeUrlContext = {
Expand Down Expand Up @@ -79,9 +79,9 @@

const isBrowser = typeof window !== "undefined";

let transitionParams = $derived(
isBrowser && prefersReducedMotion.current ? { ...(params ? params : { x: -320, duration: 200, easing: sineIn }), duration: 0 } : params ? params : { x: -320, duration: 200, easing: sineIn }
);
const defaultTransitionParams = { x: -320, duration: 200, easing: sineIn };

let finalTransitionParams = $derived(isBrowser && prefersReducedMotion.current ? { ...(transitionParams ?? defaultTransitionParams), duration: 0 } : (transitionParams ?? defaultTransitionParams));

setSidebarContext(sidebarCtx);

Expand Down Expand Up @@ -134,8 +134,6 @@
};
</script>

<svelte:window bind:innerWidth />

{#if !disableBreakpoints}
{#if isOpen || isLargeScreen}
{#if isOpen && !alwaysOpen}
Expand All @@ -151,7 +149,7 @@
{/if}
<aside
{@attach trapFocusAttachment}
transition:transition={!alwaysOpen ? transitionParams : undefined}
transition:transition={!alwaysOpen ? finalTransitionParams : undefined}
{...restProps}
data-scope="sidebar"
data-part="base"
Expand Down Expand Up @@ -187,7 +185,7 @@
@prop activateClickOutside = true
@prop backdrop = true
@prop transition = fly
@prop params
@prop transitionParams
@prop ariaLabel
@prop activeUrl = ""
@prop class: className
Expand Down
19 changes: 16 additions & 3 deletions src/lib/sidebar/SidebarDropdownWrapper.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,20 @@
import { slide } from "svelte/transition";
import { sidebarDropdownWrapper } from "./theme";

let { children, arrowup, arrowdown, icon, isOpen = $bindable(), label, transition = slide, params, class: className, classes, onclick, ...restProps }: SidebarDropdownWrapperProps = $props();
let {
children,
arrowup,
arrowdown,
icon,
isOpen = $bindable(),
label,
transition = slide,
transitionParams,
class: className,
classes,
onclick,
...restProps
}: SidebarDropdownWrapperProps = $props();

const styling = $derived(classes);

Expand All @@ -18,7 +31,7 @@

const isBrowser = typeof window !== "undefined";

const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...(params as ParamsType), duration: 0 } : (params as ParamsType));
const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...(transitionParams as ParamsType), duration: 0 } : (transitionParams as ParamsType));

let ctx = getSidebarContext() || { isSingle: false };

Expand Down Expand Up @@ -88,7 +101,7 @@
@prop isOpen = $bindable()
@prop label
@prop transition = slide
@prop params
@prop transitionParams
@prop class: className
@prop classes
@prop onclick
Expand Down
6 changes: 3 additions & 3 deletions src/lib/toast/Toast.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
color = "primary",
position,
align = true,
params,
transitionParams,
transition = fly,
class: className,
classes,
Expand All @@ -34,7 +34,7 @@
const isBrowser = typeof window !== "undefined";

// Respect reduced motion preference by setting duration to 0
const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...params, duration: 0 } : params);
const effectiveParams = $derived(isBrowser && prefersReducedMotion.current ? { ...transitionParams, duration: 0 } : transitionParams);

let ref: HTMLDivElement | undefined = $state(undefined);

Expand Down Expand Up @@ -88,7 +88,7 @@
@prop color = "primary"
@prop position
@prop align = true
@prop params
@prop transitionParams
@prop transition = fly
@prop class: className
@prop classes
Expand Down
Loading