@theguild/components 9.3.0-alpha-20250130185600-40bf89127bd373fa4c03b808908da89ac759d2e7 → 9.3.0-alpha-20250131164907-dbad02c7f607e631c4c6d1b14c288380b6242ce2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/index.d.mts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/marquee/index.d.mts +29 -0
- package/dist/components/marquee/index.js +102 -0
- package/dist/components/marquee/use-tween-playback-rate.d.mts +3 -0
- package/dist/components/marquee/use-tween-playback-rate.js +27 -0
- package/dist/index.d.mts +1 -0
- package/package.json +1 -1
|
@@ -32,6 +32,7 @@ export { ContactButton, ContactButtonProps, ContactTextLink, ContactTextLinkProp
|
|
|
32
32
|
export { Giscus } from './giscus.mjs';
|
|
33
33
|
export { VersionDropdown, VersionDropdownProps } from './version-dropdown.mjs';
|
|
34
34
|
export { Dropdown, DropdownContent, DropdownItem, DropdownTrigger } from './dropdown.mjs';
|
|
35
|
+
export { Marquee, MarqueeProps, MarqueeRows, MarqueeRowsProps } from './marquee/index.mjs';
|
|
35
36
|
export { FrequentlyAskedQuestions } from './faq/index.mjs';
|
|
36
37
|
export { ComparisonTable } from './comparison-table/index.mjs';
|
|
37
38
|
export { HiveLayoutConfig } from './hive-layout-config.mjs';
|
package/dist/components/index.js
CHANGED
|
@@ -32,6 +32,7 @@ import { Giscus } from "./giscus";
|
|
|
32
32
|
export * from "./product-card";
|
|
33
33
|
export * from "./version-dropdown";
|
|
34
34
|
export * from "./dropdown";
|
|
35
|
+
export * from "./marquee";
|
|
35
36
|
import { FrequentlyAskedQuestions } from "./faq";
|
|
36
37
|
import { ComparisonTable } from "./comparison-table";
|
|
37
38
|
import { HiveLayoutConfig } from "./hive-layout-config";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import react__default, { ReactNode, ReactElement } from 'react';
|
|
3
|
+
|
|
4
|
+
declare const PresetSpeedToMs: {
|
|
5
|
+
fast: number;
|
|
6
|
+
normal: number;
|
|
7
|
+
slow: number;
|
|
8
|
+
};
|
|
9
|
+
interface MarqueeProps extends react__default.HTMLAttributes<HTMLDivElement> {
|
|
10
|
+
direction?: 'left' | 'right';
|
|
11
|
+
speed?: keyof typeof PresetSpeedToMs | number;
|
|
12
|
+
pauseOnHover?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Seconds to stop the animation
|
|
15
|
+
*/
|
|
16
|
+
pauseDurationSeconds?: number;
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
declare function Marquee({ direction, speed, pauseOnHover, className, children, pauseDurationSeconds, ...rest }: MarqueeProps): react_jsx_runtime.JSX.Element;
|
|
20
|
+
interface MarqueeRowsProps extends react__default.HTMLAttributes<HTMLElement>, Pick<MarqueeProps, 'pauseOnHover' | 'speed'> {
|
|
21
|
+
rows: number;
|
|
22
|
+
children: ReactElement[];
|
|
23
|
+
}
|
|
24
|
+
declare function MarqueeRows({ children, rows, pauseOnHover, speed, className, ...rest }: MarqueeRowsProps): react_jsx_runtime.JSX.Element;
|
|
25
|
+
declare namespace MarqueeRows {
|
|
26
|
+
var Rows: typeof MarqueeRows;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { Marquee, type MarqueeProps, MarqueeRows, type MarqueeRowsProps };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "@theguild/components";
|
|
4
|
+
import { useTweenPlaybackRate } from "./use-tween-playback-rate";
|
|
5
|
+
const PresetSpeedToMs = {
|
|
6
|
+
fast: 2e4,
|
|
7
|
+
normal: 4e4,
|
|
8
|
+
slow: 6e4
|
|
9
|
+
};
|
|
10
|
+
function Marquee({
|
|
11
|
+
direction = "left",
|
|
12
|
+
speed = "normal",
|
|
13
|
+
pauseOnHover = false,
|
|
14
|
+
className,
|
|
15
|
+
children,
|
|
16
|
+
pauseDurationSeconds = 1,
|
|
17
|
+
...rest
|
|
18
|
+
}) {
|
|
19
|
+
const animationDuration = typeof speed === "number" ? speed : PresetSpeedToMs[speed];
|
|
20
|
+
const tweenPlaybackRate = useTweenPlaybackRate();
|
|
21
|
+
const STEP = 1 / (pauseDurationSeconds * 1e3);
|
|
22
|
+
return /* @__PURE__ */ jsxs(
|
|
23
|
+
"div",
|
|
24
|
+
{
|
|
25
|
+
className: cn(
|
|
26
|
+
"[mask-image:linear-gradient(to_right,transparent,white_20%,white_80%,transparent)]",
|
|
27
|
+
className
|
|
28
|
+
),
|
|
29
|
+
...rest,
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ jsxs(
|
|
32
|
+
"ul",
|
|
33
|
+
{
|
|
34
|
+
className: cn(
|
|
35
|
+
"flex w-max animate-[marquee_var(--animation-duration)_var(--animation-direction)_linear_infinite] gap-2 py-1"
|
|
36
|
+
),
|
|
37
|
+
style: {
|
|
38
|
+
"--animation-duration": `${animationDuration}ms`,
|
|
39
|
+
"--animation-direction": direction === "left" ? "forwards" : "reverse"
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
41
|
+
},
|
|
42
|
+
onMouseEnter: pauseOnHover ? (event) => {
|
|
43
|
+
const animation = event.currentTarget.getAnimations()[0];
|
|
44
|
+
if (animation) tweenPlaybackRate(animation, -STEP);
|
|
45
|
+
} : void 0,
|
|
46
|
+
onMouseLeave: pauseOnHover ? (event) => {
|
|
47
|
+
const animation = event.currentTarget.getAnimations()[0];
|
|
48
|
+
if (animation) tweenPlaybackRate(animation, STEP);
|
|
49
|
+
} : void 0,
|
|
50
|
+
children: [
|
|
51
|
+
children,
|
|
52
|
+
children
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
/* @__PURE__ */ jsx("style", {
|
|
57
|
+
href: "Marquee-keyframes",
|
|
58
|
+
/* css */
|
|
59
|
+
children: `
|
|
60
|
+
@keyframes marquee {
|
|
61
|
+
to {
|
|
62
|
+
translate: calc(-50% - .5rem);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
`
|
|
66
|
+
})
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
function MarqueeRows({
|
|
72
|
+
children,
|
|
73
|
+
rows,
|
|
74
|
+
pauseOnHover,
|
|
75
|
+
speed,
|
|
76
|
+
className,
|
|
77
|
+
...rest
|
|
78
|
+
}) {
|
|
79
|
+
const chunkSize = Math.ceil(children.length / rows);
|
|
80
|
+
const chunks = [];
|
|
81
|
+
for (let i = 0; i < rows; i++) {
|
|
82
|
+
chunks.push(children.slice(i * chunkSize, (i + 1) * chunkSize));
|
|
83
|
+
}
|
|
84
|
+
return /* @__PURE__ */ jsx("div", { className: cn("overflow-hidden", className), ...rest, children: chunks.map((chunk, index) => /* @__PURE__ */ jsxs(
|
|
85
|
+
Marquee,
|
|
86
|
+
{
|
|
87
|
+
direction: index % 2 ? "left" : "right",
|
|
88
|
+
pauseOnHover,
|
|
89
|
+
speed,
|
|
90
|
+
children: [
|
|
91
|
+
chunk,
|
|
92
|
+
index === chunks.length - 1 && chunk
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
index
|
|
96
|
+
)) });
|
|
97
|
+
}
|
|
98
|
+
MarqueeRows.Rows = MarqueeRows;
|
|
99
|
+
export {
|
|
100
|
+
Marquee,
|
|
101
|
+
MarqueeRows
|
|
102
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
function useTweenPlaybackRate() {
|
|
3
|
+
const slowingHandle = useRef(null);
|
|
4
|
+
const resumingHandle = useRef(null);
|
|
5
|
+
const time = useRef(null);
|
|
6
|
+
return function tweenPlaybackRate(animation, step) {
|
|
7
|
+
const currentHandle = step > 0 ? resumingHandle : slowingHandle;
|
|
8
|
+
const oppositeHandle = step > 0 ? slowingHandle : resumingHandle;
|
|
9
|
+
if (oppositeHandle.current) {
|
|
10
|
+
cancelAnimationFrame(oppositeHandle.current);
|
|
11
|
+
oppositeHandle.current = time.current = null;
|
|
12
|
+
}
|
|
13
|
+
const now = performance.now();
|
|
14
|
+
if (time.current) {
|
|
15
|
+
const deltaTime = now - time.current;
|
|
16
|
+
const { playbackRate } = animation;
|
|
17
|
+
const newValue = Math.min(Math.max(playbackRate + step * deltaTime, 0), 1);
|
|
18
|
+
if (newValue === playbackRate) return;
|
|
19
|
+
animation.updatePlaybackRate(newValue);
|
|
20
|
+
}
|
|
21
|
+
time.current = now;
|
|
22
|
+
currentHandle.current = requestAnimationFrame(() => tweenPlaybackRate(animation, step));
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
useTweenPlaybackRate
|
|
27
|
+
};
|
package/dist/index.d.mts
CHANGED
|
@@ -35,6 +35,7 @@ export { ContactButton, ContactButtonProps, ContactTextLink, ContactTextLinkProp
|
|
|
35
35
|
export { Giscus } from './components/giscus.mjs';
|
|
36
36
|
export { VersionDropdown, VersionDropdownProps } from './components/version-dropdown.mjs';
|
|
37
37
|
export { Dropdown, DropdownContent, DropdownItem, DropdownTrigger } from './components/dropdown.mjs';
|
|
38
|
+
export { Marquee, MarqueeProps, MarqueeRows, MarqueeRowsProps } from './components/marquee/index.mjs';
|
|
38
39
|
export { FrequentlyAskedQuestions } from './components/faq/index.mjs';
|
|
39
40
|
export { ComparisonTable } from './components/comparison-table/index.mjs';
|
|
40
41
|
export { HiveLayoutConfig } from './components/hive-layout-config.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theguild/components",
|
|
3
|
-
"version": "9.3.0-alpha-
|
|
3
|
+
"version": "9.3.0-alpha-20250131164907-dbad02c7f607e631c4c6d1b14c288380b6242ce2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "https://github.com/the-guild-org/docs",
|
|
6
6
|
"directory": "packages/components"
|