pelatform-ui 1.3.0 → 1.4.0

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.
@@ -0,0 +1,22 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as class_variance_authority_types from 'class-variance-authority/types';
3
+ import * as React from 'react';
4
+ import { VariantProps } from 'class-variance-authority';
5
+
6
+ declare const alertVariants: (props?: ({
7
+ variant?: "default" | "destructive" | "info" | "success" | "warning" | "invert" | null | undefined;
8
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
9
+ declare function Alert({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>): react_jsx_runtime.JSX.Element;
10
+ declare function AlertTitle({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
11
+ declare function AlertDescription({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
12
+ declare function AlertAction({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
13
+
14
+ declare const buttonVariants: (props?: ({
15
+ variant?: "link" | "default" | "outline" | "secondary" | "ghost" | "destructive" | null | undefined;
16
+ size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
17
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
18
+ declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
19
+ asChild?: boolean;
20
+ }): react_jsx_runtime.JSX.Element;
21
+
22
+ export { Alert as A, Button as B, AlertAction as a, AlertDescription as b, AlertTitle as c, buttonVariants as d };
@@ -0,0 +1,193 @@
1
+ "use client";
2
+
3
+ // src/ui/animation/hover-background.tsx
4
+ import * as React from "react";
5
+ import { motion, useMotionValue, useSpring } from "motion/react";
6
+ import { cn } from "@pelatform/utils";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ function HoverBackground({
9
+ className,
10
+ objectCount = 12,
11
+ children,
12
+ colors = {},
13
+ ...props
14
+ }) {
15
+ const {
16
+ background = "bg-gradient-to-br from-slate-900 via-purple-900 to-slate-900",
17
+ objects = [
18
+ "bg-cyan-400/20",
19
+ "bg-purple-400/20",
20
+ "bg-fuchsia-400/20",
21
+ "bg-violet-400/20",
22
+ "bg-blue-400/20",
23
+ "bg-indigo-400/20"
24
+ ],
25
+ glow = "shadow-cyan-400/50"
26
+ } = colors;
27
+ const [isHovered, setIsHovered] = React.useState(false);
28
+ const mouseX = useMotionValue(0);
29
+ const mouseY = useMotionValue(0);
30
+ const springX = useSpring(mouseX, {
31
+ stiffness: 300,
32
+ damping: 30,
33
+ // Slower return to center when hover ends
34
+ restSpeed: 0.1,
35
+ restDelta: 0.1
36
+ });
37
+ const springY = useSpring(mouseY, {
38
+ stiffness: 300,
39
+ damping: 30,
40
+ restSpeed: 0.1,
41
+ restDelta: 0.1
42
+ });
43
+ const animatedObjects = React.useMemo(
44
+ () => Array.from({ length: objectCount }, (_, i) => {
45
+ const shape = Math.random() > 0.5 ? "circle" : "square";
46
+ return {
47
+ id: i,
48
+ x: Math.random() * 90 + 5,
49
+ // 5-95% to avoid edges
50
+ y: Math.random() * 90 + 5,
51
+ size: Math.random() * 60 + 20,
52
+ // 20-80px
53
+ color: objects[i % objects.length],
54
+ delay: Math.random() * 2,
55
+ shape,
56
+ floatDirection: Math.random() > 0.5 ? 1 : -1,
57
+ breathDuration: Math.random() * 3 + 3,
58
+ // 3-6 seconds
59
+ parallaxStrength: Math.random() * 0.5 + 0.3,
60
+ // 0.3-0.8 for more varied parallax depth
61
+ baseRotation: Math.random() * 360
62
+ // Random starting rotation offset
63
+ };
64
+ }),
65
+ [objectCount, objects]
66
+ );
67
+ const handleMouseMove = (event) => {
68
+ if (!isHovered) return;
69
+ const rect = event.currentTarget.getBoundingClientRect();
70
+ const centerX = rect.width / 2;
71
+ const centerY = rect.height / 2;
72
+ const x = (event.clientX - rect.left - centerX) / centerX;
73
+ const y = (event.clientY - rect.top - centerY) / centerY;
74
+ mouseX.set(x * 15);
75
+ mouseY.set(y * 15);
76
+ };
77
+ const handleHoverStart = () => {
78
+ setIsHovered(true);
79
+ };
80
+ const handleHoverEnd = () => {
81
+ setIsHovered(false);
82
+ mouseX.set(0);
83
+ mouseY.set(0);
84
+ };
85
+ return /* @__PURE__ */ jsxs(
86
+ motion.div,
87
+ {
88
+ "data-slot": "hover-background",
89
+ className: cn("relative size-full overflow-hidden", background, className),
90
+ onHoverStart: handleHoverStart,
91
+ onHoverEnd: handleHoverEnd,
92
+ onMouseMove: handleMouseMove,
93
+ whileHover: { scale: 1.02 },
94
+ transition: { duration: 0.3, ease: "easeOut" },
95
+ animate: {
96
+ backgroundPosition: ["0% 50%", "100% 50%", "0% 50%"]
97
+ },
98
+ style: {
99
+ backgroundSize: "200% 200%"
100
+ },
101
+ ...props,
102
+ children: [
103
+ /* @__PURE__ */ jsx(
104
+ motion.div,
105
+ {
106
+ className: "absolute inset-0 bg-gradient-radial from-white/5 via-transparent to-transparent",
107
+ animate: {
108
+ opacity: [0.3, 0.6, 0.3],
109
+ scale: [1, 1.1, 1]
110
+ },
111
+ transition: {
112
+ duration: 4,
113
+ repeat: Infinity,
114
+ ease: "easeInOut"
115
+ }
116
+ }
117
+ ),
118
+ animatedObjects.map((obj) => /* @__PURE__ */ jsx(
119
+ motion.div,
120
+ {
121
+ className: cn(
122
+ "absolute border border-white/10 backdrop-blur-sm",
123
+ obj.color,
124
+ obj.shape === "circle" ? "rounded-full" : "rotate-45 rounded-lg"
125
+ ),
126
+ style: {
127
+ left: `${obj.x}%`,
128
+ top: `${obj.y}%`,
129
+ width: obj.size,
130
+ height: obj.size,
131
+ // Apply parallax with individual object strength
132
+ x: springX.get() * obj.parallaxStrength,
133
+ y: springY.get() * obj.parallaxStrength
134
+ },
135
+ initial: {
136
+ scale: 0.6,
137
+ opacity: 0.4,
138
+ rotate: obj.baseRotation
139
+ },
140
+ animate: {
141
+ // Default state animations - breathing with base rotation offset
142
+ scale: [0.6, 0.8, 0.6],
143
+ opacity: [0.4, 0.6, 0.4],
144
+ rotate: obj.shape === "circle" ? [obj.baseRotation, obj.baseRotation + 10, obj.baseRotation] : [obj.baseRotation, obj.baseRotation + 5, obj.baseRotation],
145
+ y: [0, obj.floatDirection * 15, 0],
146
+ x: [0, obj.floatDirection * 8, 0]
147
+ },
148
+ transition: {
149
+ duration: obj.breathDuration,
150
+ delay: obj.delay,
151
+ ease: "easeInOut",
152
+ repeat: Infinity,
153
+ repeatType: "reverse"
154
+ },
155
+ whileHover: {
156
+ scale: 1.5,
157
+ boxShadow: `0 0 30px ${glow.replace("shadow-", "").replace("/50", "")}`
158
+ }
159
+ },
160
+ obj.id
161
+ )),
162
+ isHovered && /* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute inset-0", children: Array.from({ length: 20 }).map((_, i) => /* @__PURE__ */ jsx(
163
+ motion.div,
164
+ {
165
+ className: "absolute h-1 w-1 rounded-full bg-white/60",
166
+ style: {
167
+ left: `${Math.random() * 100}%`,
168
+ top: `${Math.random() * 100}%`
169
+ },
170
+ initial: { opacity: 0, scale: 0 },
171
+ animate: {
172
+ opacity: [0, 1, 0],
173
+ scale: [0, 1, 0],
174
+ y: [0, -50, -100]
175
+ },
176
+ transition: {
177
+ duration: 3,
178
+ delay: Math.random() * 2,
179
+ repeat: Infinity,
180
+ ease: "easeOut"
181
+ }
182
+ },
183
+ `particle-${i}`
184
+ )) }),
185
+ /* @__PURE__ */ jsx("div", { className: "relative z-10 size-full", children })
186
+ ]
187
+ }
188
+ );
189
+ }
190
+
191
+ export {
192
+ HoverBackground
193
+ };
@@ -0,0 +1,53 @@
1
+ "use client";
2
+
3
+ // src/hooks/use-meta-color.ts
4
+ import * as React from "react";
5
+ import { useTheme } from "next-themes";
6
+ import { META_THEME_COLORS, THEME_MODES } from "@pelatform/utils";
7
+ function useMetaColor(defaultColors) {
8
+ const { resolvedTheme } = useTheme();
9
+ const isSystemDarkMode = React.useCallback(() => {
10
+ if (typeof window === "undefined") return false;
11
+ return window.matchMedia("(prefers-color-scheme: dark)").matches;
12
+ }, []);
13
+ const getEffectiveTheme = React.useCallback(
14
+ (theme) => {
15
+ if (theme === THEME_MODES.SYSTEM) {
16
+ return isSystemDarkMode() ? THEME_MODES.DARK : THEME_MODES.LIGHT;
17
+ }
18
+ return theme;
19
+ },
20
+ [isSystemDarkMode]
21
+ );
22
+ const metaColor = React.useMemo(() => {
23
+ const colorsToUse = defaultColors ?? META_THEME_COLORS;
24
+ const effectiveTheme = getEffectiveTheme(resolvedTheme);
25
+ if (effectiveTheme === THEME_MODES.DARK) {
26
+ return colorsToUse[THEME_MODES.DARK];
27
+ } else if (effectiveTheme === THEME_MODES.LIGHT) {
28
+ return colorsToUse[THEME_MODES.LIGHT];
29
+ }
30
+ return colorsToUse[THEME_MODES.LIGHT];
31
+ }, [resolvedTheme, defaultColors, getEffectiveTheme]);
32
+ const setMetaColor = React.useCallback((color) => {
33
+ const metaTag = document.querySelector('meta[name="theme-color"]');
34
+ if (metaTag) {
35
+ metaTag.setAttribute("content", color);
36
+ } else {
37
+ const newMetaTag = document.createElement("meta");
38
+ newMetaTag.name = "theme-color";
39
+ newMetaTag.content = color;
40
+ document.head.appendChild(newMetaTag);
41
+ }
42
+ }, []);
43
+ return {
44
+ /** Current meta theme color based on resolved theme */
45
+ metaColor,
46
+ /** Function to manually set meta theme color */
47
+ setMetaColor
48
+ };
49
+ }
50
+
51
+ export {
52
+ useMetaColor
53
+ };