@allshift/ui 0.1.0 → 0.2.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.
- package/dist/index.cjs +241 -0
- package/dist/index.d.cts +82 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.js +211 -0
- package/package.json +31 -3
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
HolographicShine: () => HolographicShine,
|
|
34
|
+
ScrollGenerateCard: () => ScrollGenerateCard,
|
|
35
|
+
ShiftCard: () => ShiftCard,
|
|
36
|
+
TiltCard: () => TiltCard
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(index_exports);
|
|
39
|
+
|
|
40
|
+
// src/components/ShiftCard.tsx
|
|
41
|
+
var import_framer_motion = require("framer-motion");
|
|
42
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
43
|
+
function ShiftCard({ children, className = "", blur = 12, style, ...props }) {
|
|
44
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
45
|
+
import_framer_motion.motion.div,
|
|
46
|
+
{
|
|
47
|
+
className: `shift-card ${className}`,
|
|
48
|
+
style: {
|
|
49
|
+
backdropFilter: `blur(${blur}px)`,
|
|
50
|
+
WebkitBackdropFilter: `blur(${blur}px)`,
|
|
51
|
+
...style
|
|
52
|
+
},
|
|
53
|
+
...props,
|
|
54
|
+
children
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/components/TiltCard.tsx
|
|
60
|
+
var import_react = require("react");
|
|
61
|
+
var import_framer_motion2 = require("framer-motion");
|
|
62
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
63
|
+
function TiltCard({
|
|
64
|
+
children,
|
|
65
|
+
stiffness = 300,
|
|
66
|
+
damping = 28,
|
|
67
|
+
maxRotateX = 4,
|
|
68
|
+
maxRotateY = 7,
|
|
69
|
+
style,
|
|
70
|
+
...rest
|
|
71
|
+
}) {
|
|
72
|
+
const ref = (0, import_react.useRef)(null);
|
|
73
|
+
const rawX = (0, import_framer_motion2.useMotionValue)(0);
|
|
74
|
+
const rawY = (0, import_framer_motion2.useMotionValue)(0);
|
|
75
|
+
const rotateY = (0, import_framer_motion2.useSpring)((0, import_framer_motion2.useTransform)(rawX, [-1, 1], [-maxRotateY, maxRotateY]), {
|
|
76
|
+
stiffness,
|
|
77
|
+
damping
|
|
78
|
+
});
|
|
79
|
+
const rotateX = (0, import_framer_motion2.useSpring)((0, import_framer_motion2.useTransform)(rawY, [-1, 1], [maxRotateX, -maxRotateX]), {
|
|
80
|
+
stiffness,
|
|
81
|
+
damping
|
|
82
|
+
});
|
|
83
|
+
function onMouseMove(e) {
|
|
84
|
+
const el = ref.current;
|
|
85
|
+
if (!el) return;
|
|
86
|
+
const rect = el.getBoundingClientRect();
|
|
87
|
+
rawX.set(((e.clientX - rect.left) / rect.width - 0.5) * 2);
|
|
88
|
+
rawY.set(((e.clientY - rect.top) / rect.height - 0.5) * 2);
|
|
89
|
+
}
|
|
90
|
+
function onMouseLeave() {
|
|
91
|
+
rawX.set(0);
|
|
92
|
+
rawY.set(0);
|
|
93
|
+
}
|
|
94
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
95
|
+
import_framer_motion2.motion.div,
|
|
96
|
+
{
|
|
97
|
+
ref,
|
|
98
|
+
onMouseMove,
|
|
99
|
+
onMouseLeave,
|
|
100
|
+
style: { perspective: 900, rotateX, rotateY, ...style },
|
|
101
|
+
...rest,
|
|
102
|
+
children
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/components/HolographicShine.tsx
|
|
108
|
+
var import_react2 = require("react");
|
|
109
|
+
var import_framer_motion3 = require("framer-motion");
|
|
110
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
111
|
+
function HolographicShine({
|
|
112
|
+
rgb = "255,255,255",
|
|
113
|
+
intensity = 0.18,
|
|
114
|
+
children,
|
|
115
|
+
className,
|
|
116
|
+
style
|
|
117
|
+
}) {
|
|
118
|
+
const ref = (0, import_react2.useRef)(null);
|
|
119
|
+
const mouseX = (0, import_framer_motion3.useMotionValue)(0);
|
|
120
|
+
const mouseY = (0, import_framer_motion3.useMotionValue)(0);
|
|
121
|
+
const springX = (0, import_framer_motion3.useSpring)(mouseX, { stiffness: 260, damping: 26 });
|
|
122
|
+
const springY = (0, import_framer_motion3.useSpring)(mouseY, { stiffness: 260, damping: 26 });
|
|
123
|
+
const background = import_framer_motion3.useMotionTemplate`radial-gradient(260px circle at ${springX}px ${springY}px, rgba(${rgb},${intensity}), transparent 70%)`;
|
|
124
|
+
function onMouseMove(e) {
|
|
125
|
+
const rect = ref.current?.getBoundingClientRect();
|
|
126
|
+
if (!rect) return;
|
|
127
|
+
mouseX.set(e.clientX - rect.left);
|
|
128
|
+
mouseY.set(e.clientY - rect.top);
|
|
129
|
+
}
|
|
130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
131
|
+
"div",
|
|
132
|
+
{
|
|
133
|
+
ref,
|
|
134
|
+
onMouseMove,
|
|
135
|
+
className,
|
|
136
|
+
style: { position: "relative", ...style },
|
|
137
|
+
children: [
|
|
138
|
+
children,
|
|
139
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
140
|
+
import_framer_motion3.motion.div,
|
|
141
|
+
{
|
|
142
|
+
style: {
|
|
143
|
+
position: "absolute",
|
|
144
|
+
inset: 0,
|
|
145
|
+
borderRadius: "inherit",
|
|
146
|
+
background,
|
|
147
|
+
pointerEvents: "none"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// src/components/ScrollGenerateCard.tsx
|
|
157
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
158
|
+
var import_framer_motion4 = require("framer-motion");
|
|
159
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
160
|
+
var DEFAULT_WIDTHS = [72, 85, 60, 80];
|
|
161
|
+
function ScrollGenerateCard({
|
|
162
|
+
children,
|
|
163
|
+
skeletonDuration = 360,
|
|
164
|
+
delay = 0,
|
|
165
|
+
margin = "-60px 0px",
|
|
166
|
+
className,
|
|
167
|
+
skeletonRows = 4,
|
|
168
|
+
skeletonWidths = DEFAULT_WIDTHS
|
|
169
|
+
}) {
|
|
170
|
+
const ref = import_react3.default.useRef(null);
|
|
171
|
+
const inView = (0, import_framer_motion4.useInView)(ref, { once: true, margin });
|
|
172
|
+
const [phase, setPhase] = (0, import_react3.useState)("idle");
|
|
173
|
+
(0, import_react3.useEffect)(() => {
|
|
174
|
+
if (!inView) return;
|
|
175
|
+
const t1 = setTimeout(() => setPhase("skeleton"), delay);
|
|
176
|
+
const t2 = setTimeout(() => setPhase("live"), delay + skeletonDuration);
|
|
177
|
+
return () => {
|
|
178
|
+
clearTimeout(t1);
|
|
179
|
+
clearTimeout(t2);
|
|
180
|
+
};
|
|
181
|
+
}, [inView, delay, skeletonDuration]);
|
|
182
|
+
const widths = skeletonWidths.slice(0, skeletonRows);
|
|
183
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { ref, className, style: { position: "relative" }, children: [
|
|
184
|
+
phase === "skeleton" && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
185
|
+
import_framer_motion4.motion.div,
|
|
186
|
+
{
|
|
187
|
+
initial: { opacity: 0 },
|
|
188
|
+
animate: { opacity: 1 },
|
|
189
|
+
exit: { opacity: 0 },
|
|
190
|
+
style: {
|
|
191
|
+
position: "absolute",
|
|
192
|
+
inset: 0,
|
|
193
|
+
borderRadius: "inherit",
|
|
194
|
+
padding: "1.5rem",
|
|
195
|
+
display: "flex",
|
|
196
|
+
flexDirection: "column",
|
|
197
|
+
gap: "0.75rem",
|
|
198
|
+
overflow: "hidden"
|
|
199
|
+
},
|
|
200
|
+
children: [
|
|
201
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
202
|
+
import_framer_motion4.motion.div,
|
|
203
|
+
{
|
|
204
|
+
animate: { x: ["-100%", "200%"] },
|
|
205
|
+
transition: { duration: 1.1, repeat: Infinity, ease: "linear" },
|
|
206
|
+
style: {
|
|
207
|
+
position: "absolute",
|
|
208
|
+
inset: 0,
|
|
209
|
+
background: "linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.06) 50%, transparent 100%)",
|
|
210
|
+
pointerEvents: "none"
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
),
|
|
214
|
+
widths.map((w, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
215
|
+
"div",
|
|
216
|
+
{
|
|
217
|
+
style: {
|
|
218
|
+
height: "0.7rem",
|
|
219
|
+
width: `${w}%`,
|
|
220
|
+
borderRadius: "0.4rem",
|
|
221
|
+
background: "rgba(255,255,255,0.08)",
|
|
222
|
+
animation: "pulse 1.8s ease-in-out infinite",
|
|
223
|
+
animationDelay: `${i * 120}ms`
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
i
|
|
227
|
+
))
|
|
228
|
+
]
|
|
229
|
+
}
|
|
230
|
+
),
|
|
231
|
+
phase === "live" && children(phase),
|
|
232
|
+
phase === "idle" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { visibility: "hidden" }, children: children("idle") })
|
|
233
|
+
] });
|
|
234
|
+
}
|
|
235
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
236
|
+
0 && (module.exports = {
|
|
237
|
+
HolographicShine,
|
|
238
|
+
ScrollGenerateCard,
|
|
239
|
+
ShiftCard,
|
|
240
|
+
TiltCard
|
|
241
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { ReactNode, CSSProperties } from 'react';
|
|
3
|
+
import { MotionProps } from 'framer-motion';
|
|
4
|
+
|
|
5
|
+
interface ShiftCardProps extends MotionProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
blur?: number;
|
|
10
|
+
}
|
|
11
|
+
declare function ShiftCard({ children, className, blur, style, ...props }: ShiftCardProps): React.JSX.Element;
|
|
12
|
+
|
|
13
|
+
interface TiltCardProps extends Omit<React__default.HTMLAttributes<HTMLDivElement>, keyof MotionProps>, MotionProps {
|
|
14
|
+
/** Spring stiffness for the tilt. Default 300. */
|
|
15
|
+
stiffness?: number;
|
|
16
|
+
/** Spring damping. Default 28. */
|
|
17
|
+
damping?: number;
|
|
18
|
+
/** Max degrees of X rotation. Default 4. */
|
|
19
|
+
maxRotateX?: number;
|
|
20
|
+
/** Max degrees of Y rotation. Default 7. */
|
|
21
|
+
maxRotateY?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Drop-in wrapper that adds physics-spring 3-D tilt on mouse move.
|
|
25
|
+
* Renders a `motion.div`; all extra props forwarded.
|
|
26
|
+
*/
|
|
27
|
+
declare function TiltCard({ children, stiffness, damping, maxRotateX, maxRotateY, style, ...rest }: TiltCardProps): React__default.JSX.Element;
|
|
28
|
+
|
|
29
|
+
interface HolographicShineProps {
|
|
30
|
+
/** RGB triplet for the shine tint, e.g. "0,229,240". Default neutral white. */
|
|
31
|
+
rgb?: string;
|
|
32
|
+
/** Intensity 0–1 of the shine overlay. Default 0.18. */
|
|
33
|
+
intensity?: number;
|
|
34
|
+
children?: React__default.ReactNode;
|
|
35
|
+
className?: string;
|
|
36
|
+
style?: React__default.CSSProperties;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Wrapper that paints a cursor-tracked radial holographic shine over its
|
|
40
|
+
* children. Combine with TiltCard for the full effect.
|
|
41
|
+
*/
|
|
42
|
+
declare function HolographicShine({ rgb, intensity, children, className, style, }: HolographicShineProps): React__default.JSX.Element;
|
|
43
|
+
|
|
44
|
+
type Phase = "idle" | "skeleton" | "live";
|
|
45
|
+
interface ScrollGenerateCardProps {
|
|
46
|
+
/**
|
|
47
|
+
* The real card content. Rendered in the "live" phase.
|
|
48
|
+
* Passed the current phase so content can animate itself in.
|
|
49
|
+
*/
|
|
50
|
+
children: (phase: Phase) => React__default.ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* Milliseconds of skeleton phase before switching to live. Default 360.
|
|
53
|
+
*/
|
|
54
|
+
skeletonDuration?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Stagger delay in ms before the skeleton phase starts (for grid staggering). Default 0.
|
|
57
|
+
*/
|
|
58
|
+
delay?: number;
|
|
59
|
+
/**
|
|
60
|
+
* IntersectionObserver margin. Default "-60px 0px".
|
|
61
|
+
*/
|
|
62
|
+
margin?: string;
|
|
63
|
+
className?: string;
|
|
64
|
+
/** Skeleton placeholder rows to show. Default 4. */
|
|
65
|
+
skeletonRows?: number;
|
|
66
|
+
/** Widths (in %) of each skeleton row. Deterministic to avoid hydration mismatch. */
|
|
67
|
+
skeletonWidths?: number[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Scroll-triggered three-phase card:
|
|
71
|
+
* idle (off-screen invisible) → skeleton (shimmer placeholder) → live (real content)
|
|
72
|
+
*
|
|
73
|
+
* Usage:
|
|
74
|
+
* ```tsx
|
|
75
|
+
* <ScrollGenerateCard delay={index * 80}>
|
|
76
|
+
* {(phase) => <MyCard className={phase === "live" ? "opacity-100" : "opacity-0"} />}
|
|
77
|
+
* </ScrollGenerateCard>
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
declare function ScrollGenerateCard({ children, skeletonDuration, delay, margin, className, skeletonRows, skeletonWidths, }: ScrollGenerateCardProps): React__default.JSX.Element;
|
|
81
|
+
|
|
82
|
+
export { HolographicShine, type HolographicShineProps, ScrollGenerateCard, type ScrollGenerateCardProps, ShiftCard, type ShiftCardProps, TiltCard, type TiltCardProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { ReactNode, CSSProperties } from 'react';
|
|
3
|
+
import { MotionProps } from 'framer-motion';
|
|
4
|
+
|
|
5
|
+
interface ShiftCardProps extends MotionProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
blur?: number;
|
|
10
|
+
}
|
|
11
|
+
declare function ShiftCard({ children, className, blur, style, ...props }: ShiftCardProps): React.JSX.Element;
|
|
12
|
+
|
|
13
|
+
interface TiltCardProps extends Omit<React__default.HTMLAttributes<HTMLDivElement>, keyof MotionProps>, MotionProps {
|
|
14
|
+
/** Spring stiffness for the tilt. Default 300. */
|
|
15
|
+
stiffness?: number;
|
|
16
|
+
/** Spring damping. Default 28. */
|
|
17
|
+
damping?: number;
|
|
18
|
+
/** Max degrees of X rotation. Default 4. */
|
|
19
|
+
maxRotateX?: number;
|
|
20
|
+
/** Max degrees of Y rotation. Default 7. */
|
|
21
|
+
maxRotateY?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Drop-in wrapper that adds physics-spring 3-D tilt on mouse move.
|
|
25
|
+
* Renders a `motion.div`; all extra props forwarded.
|
|
26
|
+
*/
|
|
27
|
+
declare function TiltCard({ children, stiffness, damping, maxRotateX, maxRotateY, style, ...rest }: TiltCardProps): React__default.JSX.Element;
|
|
28
|
+
|
|
29
|
+
interface HolographicShineProps {
|
|
30
|
+
/** RGB triplet for the shine tint, e.g. "0,229,240". Default neutral white. */
|
|
31
|
+
rgb?: string;
|
|
32
|
+
/** Intensity 0–1 of the shine overlay. Default 0.18. */
|
|
33
|
+
intensity?: number;
|
|
34
|
+
children?: React__default.ReactNode;
|
|
35
|
+
className?: string;
|
|
36
|
+
style?: React__default.CSSProperties;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Wrapper that paints a cursor-tracked radial holographic shine over its
|
|
40
|
+
* children. Combine with TiltCard for the full effect.
|
|
41
|
+
*/
|
|
42
|
+
declare function HolographicShine({ rgb, intensity, children, className, style, }: HolographicShineProps): React__default.JSX.Element;
|
|
43
|
+
|
|
44
|
+
type Phase = "idle" | "skeleton" | "live";
|
|
45
|
+
interface ScrollGenerateCardProps {
|
|
46
|
+
/**
|
|
47
|
+
* The real card content. Rendered in the "live" phase.
|
|
48
|
+
* Passed the current phase so content can animate itself in.
|
|
49
|
+
*/
|
|
50
|
+
children: (phase: Phase) => React__default.ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* Milliseconds of skeleton phase before switching to live. Default 360.
|
|
53
|
+
*/
|
|
54
|
+
skeletonDuration?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Stagger delay in ms before the skeleton phase starts (for grid staggering). Default 0.
|
|
57
|
+
*/
|
|
58
|
+
delay?: number;
|
|
59
|
+
/**
|
|
60
|
+
* IntersectionObserver margin. Default "-60px 0px".
|
|
61
|
+
*/
|
|
62
|
+
margin?: string;
|
|
63
|
+
className?: string;
|
|
64
|
+
/** Skeleton placeholder rows to show. Default 4. */
|
|
65
|
+
skeletonRows?: number;
|
|
66
|
+
/** Widths (in %) of each skeleton row. Deterministic to avoid hydration mismatch. */
|
|
67
|
+
skeletonWidths?: number[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Scroll-triggered three-phase card:
|
|
71
|
+
* idle (off-screen invisible) → skeleton (shimmer placeholder) → live (real content)
|
|
72
|
+
*
|
|
73
|
+
* Usage:
|
|
74
|
+
* ```tsx
|
|
75
|
+
* <ScrollGenerateCard delay={index * 80}>
|
|
76
|
+
* {(phase) => <MyCard className={phase === "live" ? "opacity-100" : "opacity-0"} />}
|
|
77
|
+
* </ScrollGenerateCard>
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
declare function ScrollGenerateCard({ children, skeletonDuration, delay, margin, className, skeletonRows, skeletonWidths, }: ScrollGenerateCardProps): React__default.JSX.Element;
|
|
81
|
+
|
|
82
|
+
export { HolographicShine, type HolographicShineProps, ScrollGenerateCard, type ScrollGenerateCardProps, ShiftCard, type ShiftCardProps, TiltCard, type TiltCardProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// src/components/ShiftCard.tsx
|
|
2
|
+
import { motion } from "framer-motion";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
function ShiftCard({ children, className = "", blur = 12, style, ...props }) {
|
|
5
|
+
return /* @__PURE__ */ jsx(
|
|
6
|
+
motion.div,
|
|
7
|
+
{
|
|
8
|
+
className: `shift-card ${className}`,
|
|
9
|
+
style: {
|
|
10
|
+
backdropFilter: `blur(${blur}px)`,
|
|
11
|
+
WebkitBackdropFilter: `blur(${blur}px)`,
|
|
12
|
+
...style
|
|
13
|
+
},
|
|
14
|
+
...props,
|
|
15
|
+
children
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// src/components/TiltCard.tsx
|
|
21
|
+
import { useRef } from "react";
|
|
22
|
+
import {
|
|
23
|
+
motion as motion2,
|
|
24
|
+
useMotionValue,
|
|
25
|
+
useTransform,
|
|
26
|
+
useSpring
|
|
27
|
+
} from "framer-motion";
|
|
28
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
29
|
+
function TiltCard({
|
|
30
|
+
children,
|
|
31
|
+
stiffness = 300,
|
|
32
|
+
damping = 28,
|
|
33
|
+
maxRotateX = 4,
|
|
34
|
+
maxRotateY = 7,
|
|
35
|
+
style,
|
|
36
|
+
...rest
|
|
37
|
+
}) {
|
|
38
|
+
const ref = useRef(null);
|
|
39
|
+
const rawX = useMotionValue(0);
|
|
40
|
+
const rawY = useMotionValue(0);
|
|
41
|
+
const rotateY = useSpring(useTransform(rawX, [-1, 1], [-maxRotateY, maxRotateY]), {
|
|
42
|
+
stiffness,
|
|
43
|
+
damping
|
|
44
|
+
});
|
|
45
|
+
const rotateX = useSpring(useTransform(rawY, [-1, 1], [maxRotateX, -maxRotateX]), {
|
|
46
|
+
stiffness,
|
|
47
|
+
damping
|
|
48
|
+
});
|
|
49
|
+
function onMouseMove(e) {
|
|
50
|
+
const el = ref.current;
|
|
51
|
+
if (!el) return;
|
|
52
|
+
const rect = el.getBoundingClientRect();
|
|
53
|
+
rawX.set(((e.clientX - rect.left) / rect.width - 0.5) * 2);
|
|
54
|
+
rawY.set(((e.clientY - rect.top) / rect.height - 0.5) * 2);
|
|
55
|
+
}
|
|
56
|
+
function onMouseLeave() {
|
|
57
|
+
rawX.set(0);
|
|
58
|
+
rawY.set(0);
|
|
59
|
+
}
|
|
60
|
+
return /* @__PURE__ */ jsx2(
|
|
61
|
+
motion2.div,
|
|
62
|
+
{
|
|
63
|
+
ref,
|
|
64
|
+
onMouseMove,
|
|
65
|
+
onMouseLeave,
|
|
66
|
+
style: { perspective: 900, rotateX, rotateY, ...style },
|
|
67
|
+
...rest,
|
|
68
|
+
children
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/components/HolographicShine.tsx
|
|
74
|
+
import { useRef as useRef2 } from "react";
|
|
75
|
+
import {
|
|
76
|
+
motion as motion3,
|
|
77
|
+
useMotionTemplate,
|
|
78
|
+
useMotionValue as useMotionValue2,
|
|
79
|
+
useSpring as useSpring2
|
|
80
|
+
} from "framer-motion";
|
|
81
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
82
|
+
function HolographicShine({
|
|
83
|
+
rgb = "255,255,255",
|
|
84
|
+
intensity = 0.18,
|
|
85
|
+
children,
|
|
86
|
+
className,
|
|
87
|
+
style
|
|
88
|
+
}) {
|
|
89
|
+
const ref = useRef2(null);
|
|
90
|
+
const mouseX = useMotionValue2(0);
|
|
91
|
+
const mouseY = useMotionValue2(0);
|
|
92
|
+
const springX = useSpring2(mouseX, { stiffness: 260, damping: 26 });
|
|
93
|
+
const springY = useSpring2(mouseY, { stiffness: 260, damping: 26 });
|
|
94
|
+
const background = useMotionTemplate`radial-gradient(260px circle at ${springX}px ${springY}px, rgba(${rgb},${intensity}), transparent 70%)`;
|
|
95
|
+
function onMouseMove(e) {
|
|
96
|
+
const rect = ref.current?.getBoundingClientRect();
|
|
97
|
+
if (!rect) return;
|
|
98
|
+
mouseX.set(e.clientX - rect.left);
|
|
99
|
+
mouseY.set(e.clientY - rect.top);
|
|
100
|
+
}
|
|
101
|
+
return /* @__PURE__ */ jsxs(
|
|
102
|
+
"div",
|
|
103
|
+
{
|
|
104
|
+
ref,
|
|
105
|
+
onMouseMove,
|
|
106
|
+
className,
|
|
107
|
+
style: { position: "relative", ...style },
|
|
108
|
+
children: [
|
|
109
|
+
children,
|
|
110
|
+
/* @__PURE__ */ jsx3(
|
|
111
|
+
motion3.div,
|
|
112
|
+
{
|
|
113
|
+
style: {
|
|
114
|
+
position: "absolute",
|
|
115
|
+
inset: 0,
|
|
116
|
+
borderRadius: "inherit",
|
|
117
|
+
background,
|
|
118
|
+
pointerEvents: "none"
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/components/ScrollGenerateCard.tsx
|
|
128
|
+
import React3, { useEffect, useState } from "react";
|
|
129
|
+
import { motion as motion4, useInView } from "framer-motion";
|
|
130
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
131
|
+
var DEFAULT_WIDTHS = [72, 85, 60, 80];
|
|
132
|
+
function ScrollGenerateCard({
|
|
133
|
+
children,
|
|
134
|
+
skeletonDuration = 360,
|
|
135
|
+
delay = 0,
|
|
136
|
+
margin = "-60px 0px",
|
|
137
|
+
className,
|
|
138
|
+
skeletonRows = 4,
|
|
139
|
+
skeletonWidths = DEFAULT_WIDTHS
|
|
140
|
+
}) {
|
|
141
|
+
const ref = React3.useRef(null);
|
|
142
|
+
const inView = useInView(ref, { once: true, margin });
|
|
143
|
+
const [phase, setPhase] = useState("idle");
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
if (!inView) return;
|
|
146
|
+
const t1 = setTimeout(() => setPhase("skeleton"), delay);
|
|
147
|
+
const t2 = setTimeout(() => setPhase("live"), delay + skeletonDuration);
|
|
148
|
+
return () => {
|
|
149
|
+
clearTimeout(t1);
|
|
150
|
+
clearTimeout(t2);
|
|
151
|
+
};
|
|
152
|
+
}, [inView, delay, skeletonDuration]);
|
|
153
|
+
const widths = skeletonWidths.slice(0, skeletonRows);
|
|
154
|
+
return /* @__PURE__ */ jsxs2("div", { ref, className, style: { position: "relative" }, children: [
|
|
155
|
+
phase === "skeleton" && /* @__PURE__ */ jsxs2(
|
|
156
|
+
motion4.div,
|
|
157
|
+
{
|
|
158
|
+
initial: { opacity: 0 },
|
|
159
|
+
animate: { opacity: 1 },
|
|
160
|
+
exit: { opacity: 0 },
|
|
161
|
+
style: {
|
|
162
|
+
position: "absolute",
|
|
163
|
+
inset: 0,
|
|
164
|
+
borderRadius: "inherit",
|
|
165
|
+
padding: "1.5rem",
|
|
166
|
+
display: "flex",
|
|
167
|
+
flexDirection: "column",
|
|
168
|
+
gap: "0.75rem",
|
|
169
|
+
overflow: "hidden"
|
|
170
|
+
},
|
|
171
|
+
children: [
|
|
172
|
+
/* @__PURE__ */ jsx4(
|
|
173
|
+
motion4.div,
|
|
174
|
+
{
|
|
175
|
+
animate: { x: ["-100%", "200%"] },
|
|
176
|
+
transition: { duration: 1.1, repeat: Infinity, ease: "linear" },
|
|
177
|
+
style: {
|
|
178
|
+
position: "absolute",
|
|
179
|
+
inset: 0,
|
|
180
|
+
background: "linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.06) 50%, transparent 100%)",
|
|
181
|
+
pointerEvents: "none"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
widths.map((w, i) => /* @__PURE__ */ jsx4(
|
|
186
|
+
"div",
|
|
187
|
+
{
|
|
188
|
+
style: {
|
|
189
|
+
height: "0.7rem",
|
|
190
|
+
width: `${w}%`,
|
|
191
|
+
borderRadius: "0.4rem",
|
|
192
|
+
background: "rgba(255,255,255,0.08)",
|
|
193
|
+
animation: "pulse 1.8s ease-in-out infinite",
|
|
194
|
+
animationDelay: `${i * 120}ms`
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
i
|
|
198
|
+
))
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
),
|
|
202
|
+
phase === "live" && children(phase),
|
|
203
|
+
phase === "idle" && /* @__PURE__ */ jsx4("div", { style: { visibility: "hidden" }, children: children("idle") })
|
|
204
|
+
] });
|
|
205
|
+
}
|
|
206
|
+
export {
|
|
207
|
+
HolographicShine,
|
|
208
|
+
ScrollGenerateCard,
|
|
209
|
+
ShiftCard,
|
|
210
|
+
TiltCard
|
|
211
|
+
};
|
package/package.json
CHANGED
|
@@ -1,25 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allshift/ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Shift family shared FEEL layer —
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Shift family shared FEEL layer — glass morphism, 3D tilt physics, holographic shine, scroll-triggered generation. Brand-neutral by design.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
7
7
|
"type": "module",
|
|
8
8
|
"files": [
|
|
9
|
+
"dist",
|
|
9
10
|
"styles",
|
|
10
11
|
"styles.css",
|
|
11
12
|
"README.md"
|
|
12
13
|
],
|
|
14
|
+
"main": "./dist/index.cjs",
|
|
15
|
+
"module": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
13
17
|
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"require": "./dist/index.cjs"
|
|
22
|
+
},
|
|
14
23
|
"./styles.css": "./styles/shift-ui.css",
|
|
15
24
|
"./package.json": "./package.json"
|
|
16
25
|
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsup",
|
|
28
|
+
"dev": "tsup --watch",
|
|
29
|
+
"type-check": "tsc --noEmit"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"framer-motion": ">=10",
|
|
33
|
+
"react": ">=18"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/react": "^19.2.17",
|
|
37
|
+
"framer-motion": "^12.40.0",
|
|
38
|
+
"react": "^19.2.7",
|
|
39
|
+
"tsup": "^8.5.1",
|
|
40
|
+
"typescript": "^6.0.3"
|
|
41
|
+
},
|
|
17
42
|
"publishConfig": {
|
|
18
43
|
"access": "public"
|
|
19
44
|
},
|
|
20
45
|
"keywords": [
|
|
21
46
|
"shift",
|
|
22
47
|
"design-system",
|
|
23
|
-
"feel-layer"
|
|
48
|
+
"feel-layer",
|
|
49
|
+
"glass-morphism",
|
|
50
|
+
"framer-motion",
|
|
51
|
+
"3d-tilt"
|
|
24
52
|
]
|
|
25
53
|
}
|