Skip to content

Commit

Permalink
Svelte 5 - Marquee
Browse files Browse the repository at this point in the history
  • Loading branch information
f-elix committed Nov 28, 2024
1 parent 87152f6 commit 17d215b
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 44 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-lizards-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@288-toolkit/marquee": major
---

Migrate to svelte 5
38 changes: 24 additions & 14 deletions packages/components/marquee/dist/Marquee.svelte
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
<script lang="ts">
import { debounce } from '@288-toolkit/timeout';
/**
* The direction of the marquee.
*/
export let direction: 'natural' | 'inverted' = 'natural';
/**
* The orientation of the marquee. Default: `horizontal`.
*/
export let orientation: 'vertical' | 'horizontal' = 'horizontal';
/**
* Wether the marquee should pause when hovered. Default: `false`.
*/
export let stopOnHover = false;
interface Props {
/**
* The direction of the marquee.
*/
direction?: 'natural' | 'inverted';
/**
* The orientation of the marquee. Default: `horizontal`.
*/
orientation?: 'vertical' | 'horizontal';
/**
* Wether the marquee should pause when hovered. Default: `false`.
*/
stopOnHover?: boolean;
children?: import('svelte').Snippet<[any]>;
}
let {
direction = 'natural',
orientation = 'horizontal',
stopOnHover = false,
children
}: Props = $props();
const minCopies = 2;
let copies = minCopies;
let copies = $state(minCopies);
const setCopies = (el: HTMLElement) => {
const observer = new ResizeObserver(
Expand Down Expand Up @@ -55,7 +65,7 @@
{#each new Array(copies) as _, i}
{@const copy = i > 0}
<div class="_marquee" aria-hidden={copy || null}>
<slot {copy} />
{@render children?.({ copy })}
</div>
{/each}
{/key}
Expand Down
22 changes: 11 additions & 11 deletions packages/components/marquee/dist/Marquee.svelte.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import { SvelteComponent } from "svelte";
declare const __propDef: {
props: {
/**
* The direction of the marquee.
*/ direction?: "natural" | "inverted" | undefined;
* The direction of the marquee.
*/
direction?: "natural" | "inverted" | undefined;
/**
* The orientation of the marquee. Default: `horizontal`.
*/ orientation?: "vertical" | "horizontal" | undefined;
* The orientation of the marquee. Default: `horizontal`.
*/
orientation?: "vertical" | "horizontal" | undefined;
/**
* Wether the marquee should pause when hovered. Default: `false`.
*/ stopOnHover?: boolean | undefined;
* Wether the marquee should pause when hovered. Default: `false`.
*/
stopOnHover?: boolean | undefined;
children?: import("svelte").Snippet<[any]> | undefined;
};
events: {
[evt: string]: CustomEvent<any>;
};
slots: {
default: {
copy: any;
};
};
slots: {};
};
export type MarqueeProps = typeof __propDef.props;
export type MarqueeEvents = typeof __propDef.events;
Expand Down
2 changes: 1 addition & 1 deletion packages/components/marquee/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}
},
"peerDependencies": {
"svelte": "4.x || 5.x"
"svelte": "5.x"
},
"dependencies": {
"@288-toolkit/timeout": "workspace:^"
Expand Down
38 changes: 24 additions & 14 deletions packages/components/marquee/src/lib/Marquee.svelte
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
<script lang="ts">
import { debounce } from '@288-toolkit/timeout';
/**
* The direction of the marquee.
*/
export let direction: 'natural' | 'inverted' = 'natural';
/**
* The orientation of the marquee. Default: `horizontal`.
*/
export let orientation: 'vertical' | 'horizontal' = 'horizontal';
/**
* Wether the marquee should pause when hovered. Default: `false`.
*/
export let stopOnHover = false;
interface Props {
/**
* The direction of the marquee.
*/
direction?: 'natural' | 'inverted';
/**
* The orientation of the marquee. Default: `horizontal`.
*/
orientation?: 'vertical' | 'horizontal';
/**
* Wether the marquee should pause when hovered. Default: `false`.
*/
stopOnHover?: boolean;
children?: import('svelte').Snippet<[any]>;
}
let {
direction = 'natural',
orientation = 'horizontal',
stopOnHover = false,
children
}: Props = $props();
const minCopies = 2;
let copies = minCopies;
let copies = $state(minCopies);
const setCopies = (el: HTMLElement) => {
const observer = new ResizeObserver(
Expand Down Expand Up @@ -55,7 +65,7 @@
{#each new Array(copies) as _, i}
{@const copy = i > 0}
<div class="_marquee" aria-hidden={copy || null}>
<slot {copy} />
{@render children?.({ copy })}
</div>
{/each}
{/key}
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 17d215b

Please sign in to comment.