react-tilt-button 0.0.6 → 0.0.7
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/README.md +32 -0
- package/dist/react-tilt-button.css +1 -1
- package/dist/react-tilt-button.es.js +168 -153
- package/dist/react-tilt-button.umd.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -168,6 +168,34 @@ These override the selected variant.
|
|
|
168
168
|
| `borderColor` |
|
|
169
169
|
| `borderWidth` |
|
|
170
170
|
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Glare / Specular Highlight (Optional)
|
|
174
|
+
|
|
175
|
+
The button supports a **dynamic specular glare highlight** that simulates light reflecting off the surface.
|
|
176
|
+
|
|
177
|
+
It automatically shifts based on hover position (left / middle / right) and fades out on press.
|
|
178
|
+
|
|
179
|
+
### Props
|
|
180
|
+
|
|
181
|
+
| Prop | Type | Default | Description |
|
|
182
|
+
| -------------- | ------ | --------- | ----------------------------------- |
|
|
183
|
+
| `glareColor` | string | `#ffffff` | Color of the glare highlight |
|
|
184
|
+
| `glareOpacity` | number | `0` | Intensity of the glare (0 → 1) |
|
|
185
|
+
| `glareWidth` | number | `0` | Width of glare band (0 → 100, in %) |
|
|
186
|
+
|
|
187
|
+
### Example
|
|
188
|
+
|
|
189
|
+
```jsx
|
|
190
|
+
<TiltButton
|
|
191
|
+
glareColor="#ffffff"
|
|
192
|
+
glareOpacity={0.12}
|
|
193
|
+
glareWidth={60}
|
|
194
|
+
>
|
|
195
|
+
Shiny Button
|
|
196
|
+
</TiltButton>
|
|
197
|
+
|
|
198
|
+
|
|
171
199
|
---
|
|
172
200
|
|
|
173
201
|
### Misc
|
|
@@ -201,6 +229,9 @@ All visuals are driven by CSS variables:
|
|
|
201
229
|
- `--text-color`
|
|
202
230
|
- `--border-color`
|
|
203
231
|
- `--border-width`
|
|
232
|
+
- `--glare-rgb`
|
|
233
|
+
- `--glare-alpha`
|
|
234
|
+
- `--glare-width`
|
|
204
235
|
|
|
205
236
|
So you can theme it externally if needed.
|
|
206
237
|
|
|
@@ -222,3 +253,4 @@ It is a **physical, tactile UI primitive** that behaves like an object:
|
|
|
222
253
|
## License
|
|
223
254
|
|
|
224
255
|
Use it. Ship it. Modify it.
|
|
256
|
+
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.soft-btn{--button-raise-level: 14px;--press-inset: 5px;--button-hover-pressure: 2;--transform-speed: .16s;--radius: 14px;--surface-color: #f3f4f6;--side-color: #d1d5db;--text-color: #111827;--border-color: rgba(0, 0, 0, .35);--border-width: 2px;position:relative;border:none;background:transparent;padding:0;cursor:pointer;-webkit-user-select:none;user-select:none}.soft-btn__wrapper{position:relative;display:block;width:100%;height:100%;transform-style:preserve-3d}.soft-btn__wrapper:before{content:"";position:absolute;left:0;right:0;bottom:0;height:calc(100% - var(--button-raise-level));background:var(--side-color);border-bottom-left-radius:var(--radius);border-bottom-right-radius:var(--radius);border-radius:var(--radius)}.soft-btn__content{position:relative;width:100%;height:calc(100% - var(--button-raise-level));background:var(--surface-color);color:var(--text-color);border-radius:var(--radius);display:flex;align-items:center;justify-content:center;font-size:18px;font-weight:600;transform:translateY(0);transition:transform var(--transform-speed) ease-out;will-change:transform;backface-visibility:hidden;transform-origin:center}.soft-btn__inner{display:inline-flex;align-items:center;gap:10px}.soft-btn--bordered .soft-btn__content{box-shadow:inset 0 0 0 var(--border-width) var(--border-color)}.soft-btn--middle .soft-btn__content{transform:translateY(calc(1px * var(--button-hover-pressure)))}.soft-btn--left .soft-btn__content{transform:skewY(calc(-1deg * var(--button-hover-pressure)))}.soft-btn--right .soft-btn__content{transform:skewY(calc(1deg * var(--button-hover-pressure)))}.soft-btn--active .soft-btn__content{transform:translateY(var(--press-inset));transition:transform calc(var(--transform-speed) * .8) ease-out}.soft-btn--disabled{opacity:.6;pointer-events:none}
|
|
1
|
+
.soft-btn{--button-raise-level: 14px;--press-inset: 5px;--button-hover-pressure: 2;--transform-speed: .16s;--radius: 14px;--surface-color: #f3f4f6;--side-color: #d1d5db;--text-color: #111827;--border-color: rgba(0, 0, 0, .35);--border-width: 2px;--glare-rgb: 255, 255, 255;--glare-alpha: 0;--glare-width: 0;position:relative;border:none;background:transparent;padding:0;cursor:pointer;-webkit-user-select:none;user-select:none}.soft-btn__wrapper{position:relative;display:block;width:100%;height:100%;transform-style:preserve-3d}.soft-btn__wrapper:before{content:"";position:absolute;left:0;right:0;bottom:0;height:calc(100% - var(--button-raise-level));background:var(--side-color);border-bottom-left-radius:var(--radius);border-bottom-right-radius:var(--radius);border-radius:var(--radius);z-index:1}.soft-btn__content{position:relative;width:100%;height:calc(100% - var(--button-raise-level));background:var(--surface-color);color:var(--text-color);border-radius:var(--radius);display:flex;align-items:center;justify-content:center;font-size:18px;font-weight:600;transform:translateY(0);transition:transform var(--transform-speed) ease-out;will-change:transform;backface-visibility:hidden;transform-origin:center;z-index:2}.soft-btn__inner{display:inline-flex;align-items:center;gap:10px;z-index:4}.soft-btn--bordered .soft-btn__content{box-shadow:inset 0 0 0 var(--border-width) var(--border-color)}.soft-btn--middle .soft-btn__content{transform:translateY(calc(1px * var(--button-hover-pressure)))}.soft-btn--left .soft-btn__content{transform:skewY(calc(-1deg * var(--button-hover-pressure)))}.soft-btn--right .soft-btn__content{transform:skewY(calc(1deg * var(--button-hover-pressure)))}.soft-btn__content:after{content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;background:linear-gradient(90deg,rgba(var(--glare-rgb),0) calc(50% - var(--glare-width) * 1%),rgba(var(--glare-rgb),calc(var(--glare-alpha) * .5)) calc(50% - var(--glare-width) * .5%),rgba(var(--glare-rgb),var(--glare-alpha)) 50%,rgba(var(--glare-rgb),calc(var(--glare-alpha) * .5)) calc(50% + var(--glare-width) * .5%),rgba(var(--glare-rgb),0) calc(50% + var(--glare-width) * 1%));background-size:200% 100%;background-position:50% 50%;opacity:0;transition:opacity .16s ease,background-position var(--transform-speed) ease;z-index:3}.soft-btn--right .soft-btn__content:after{opacity:1;background-position:0% 50%}.soft-btn--middle .soft-btn__content:after{opacity:1;background-position:50% 50%}.soft-btn--left .soft-btn__content:after{opacity:1;background-position:100% 50%}.soft-btn--active .soft-btn__content{transform:translateY(var(--press-inset));transition:transform calc(var(--transform-speed) * .8) ease-out}.soft-btn--disabled{opacity:.6;pointer-events:none}.soft-btn--disabled .soft-btn__content:after{opacity:0}.soft-btn--active .soft-btn__content:after{opacity:1;background:rgba(var(--glare-rgb),var(--glare-alpha));background-position:50% 50%}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import
|
|
2
|
-
var U = { exports: {} },
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
function
|
|
1
|
+
import Ee, { useRef as ve, useState as ne } from "react";
|
|
2
|
+
var U = { exports: {} }, y = {};
|
|
3
|
+
var ae;
|
|
4
|
+
function Re() {
|
|
5
|
+
if (ae) return y;
|
|
6
|
+
ae = 1;
|
|
7
|
+
var s = /* @__PURE__ */ Symbol.for("react.transitional.element"), a = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
8
|
+
function l(f, c, u) {
|
|
9
9
|
var d = null;
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
for (var b in
|
|
13
|
-
b !== "key" && (
|
|
14
|
-
} else
|
|
15
|
-
return
|
|
16
|
-
$$typeof:
|
|
17
|
-
type:
|
|
10
|
+
if (u !== void 0 && (d = "" + u), c.key !== void 0 && (d = "" + c.key), "key" in c) {
|
|
11
|
+
u = {};
|
|
12
|
+
for (var b in c)
|
|
13
|
+
b !== "key" && (u[b] = c[b]);
|
|
14
|
+
} else u = c;
|
|
15
|
+
return c = u.ref, {
|
|
16
|
+
$$typeof: s,
|
|
17
|
+
type: f,
|
|
18
18
|
key: d,
|
|
19
|
-
ref:
|
|
20
|
-
props:
|
|
19
|
+
ref: c !== void 0 ? c : null,
|
|
20
|
+
props: u
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return y.Fragment = a, y.jsx = l, y.jsxs = l, y;
|
|
24
24
|
}
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
function
|
|
28
|
-
return
|
|
29
|
-
function
|
|
25
|
+
var S = {};
|
|
26
|
+
var se;
|
|
27
|
+
function Ce() {
|
|
28
|
+
return se || (se = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
29
|
+
function s(e) {
|
|
30
30
|
if (e == null) return null;
|
|
31
31
|
if (typeof e == "function")
|
|
32
|
-
return e.$$typeof ===
|
|
32
|
+
return e.$$typeof === v ? null : e.displayName || e.name || null;
|
|
33
33
|
if (typeof e == "string") return e;
|
|
34
34
|
switch (e) {
|
|
35
|
-
case
|
|
35
|
+
case h:
|
|
36
36
|
return "Fragment";
|
|
37
|
-
case
|
|
37
|
+
case X:
|
|
38
38
|
return "Profiler";
|
|
39
39
|
case J:
|
|
40
40
|
return "StrictMode";
|
|
41
|
-
case
|
|
41
|
+
case H:
|
|
42
42
|
return "Suspense";
|
|
43
|
-
case
|
|
43
|
+
case $:
|
|
44
44
|
return "SuspenseList";
|
|
45
|
-
case
|
|
45
|
+
case I:
|
|
46
46
|
return "Activity";
|
|
47
47
|
}
|
|
48
48
|
if (typeof e == "object")
|
|
@@ -51,30 +51,30 @@ function Ee() {
|
|
|
51
51
|
), e.$$typeof) {
|
|
52
52
|
case q:
|
|
53
53
|
return "Portal";
|
|
54
|
-
case
|
|
54
|
+
case G:
|
|
55
55
|
return e.displayName || "Context";
|
|
56
|
-
case X:
|
|
57
|
-
return (e._context.displayName || "Context") + ".Consumer";
|
|
58
56
|
case z:
|
|
57
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
58
|
+
case A:
|
|
59
59
|
var r = e.render;
|
|
60
60
|
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
61
|
-
case
|
|
62
|
-
return r = e.displayName || null, r !== null ? r :
|
|
63
|
-
case
|
|
61
|
+
case Z:
|
|
62
|
+
return r = e.displayName || null, r !== null ? r : s(e.type) || "Memo";
|
|
63
|
+
case m:
|
|
64
64
|
r = e._payload, e = e._init;
|
|
65
65
|
try {
|
|
66
|
-
return
|
|
66
|
+
return s(e(r));
|
|
67
67
|
} catch {
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
return null;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function a(e) {
|
|
73
73
|
return "" + e;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function l(e) {
|
|
76
76
|
try {
|
|
77
|
-
|
|
77
|
+
a(e);
|
|
78
78
|
var r = !1;
|
|
79
79
|
} catch {
|
|
80
80
|
r = !0;
|
|
@@ -86,29 +86,29 @@ function Ee() {
|
|
|
86
86
|
r,
|
|
87
87
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
88
88
|
o
|
|
89
|
-
),
|
|
89
|
+
), a(e);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
if (e ===
|
|
94
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
92
|
+
function f(e) {
|
|
93
|
+
if (e === h) return "<>";
|
|
94
|
+
if (typeof e == "object" && e !== null && e.$$typeof === m)
|
|
95
95
|
return "<...>";
|
|
96
96
|
try {
|
|
97
|
-
var r =
|
|
97
|
+
var r = s(e);
|
|
98
98
|
return r ? "<" + r + ">" : "<...>";
|
|
99
99
|
} catch {
|
|
100
100
|
return "<...>";
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
function
|
|
104
|
-
var e =
|
|
103
|
+
function c() {
|
|
104
|
+
var e = R.A;
|
|
105
105
|
return e === null ? null : e.getOwner();
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function u() {
|
|
108
108
|
return Error("react-stack-top-frame");
|
|
109
109
|
}
|
|
110
110
|
function d(e) {
|
|
111
|
-
if (
|
|
111
|
+
if (W.call(e, "key")) {
|
|
112
112
|
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
113
113
|
if (r && r.isReactWarning) return !1;
|
|
114
114
|
}
|
|
@@ -116,7 +116,7 @@ function Ee() {
|
|
|
116
116
|
}
|
|
117
117
|
function b(e, r) {
|
|
118
118
|
function t() {
|
|
119
|
-
|
|
119
|
+
p || (p = !0, console.error(
|
|
120
120
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
121
121
|
r
|
|
122
122
|
));
|
|
@@ -126,13 +126,13 @@ function Ee() {
|
|
|
126
126
|
configurable: !0
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
var e =
|
|
129
|
+
function T() {
|
|
130
|
+
var e = s(this.type);
|
|
131
131
|
return Y[e] || (Y[e] = !0, console.error(
|
|
132
132
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
133
133
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
134
134
|
}
|
|
135
|
-
function _(e, r, t, o,
|
|
135
|
+
function _(e, r, t, o, C, w) {
|
|
136
136
|
var n = t.ref;
|
|
137
137
|
return e = {
|
|
138
138
|
$$typeof: M,
|
|
@@ -142,7 +142,7 @@ function Ee() {
|
|
|
142
142
|
_owner: o
|
|
143
143
|
}, (n !== void 0 ? n : null) !== null ? Object.defineProperty(e, "ref", {
|
|
144
144
|
enumerable: !1,
|
|
145
|
-
get:
|
|
145
|
+
get: T
|
|
146
146
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
147
147
|
configurable: !1,
|
|
148
148
|
enumerable: !1,
|
|
@@ -157,7 +157,7 @@ function Ee() {
|
|
|
157
157
|
configurable: !1,
|
|
158
158
|
enumerable: !1,
|
|
159
159
|
writable: !0,
|
|
160
|
-
value:
|
|
160
|
+
value: C
|
|
161
161
|
}), Object.defineProperty(e, "_debugTask", {
|
|
162
162
|
configurable: !1,
|
|
163
163
|
enumerable: !1,
|
|
@@ -165,25 +165,25 @@ function Ee() {
|
|
|
165
165
|
value: w
|
|
166
166
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
167
167
|
}
|
|
168
|
-
function
|
|
168
|
+
function N(e, r, t, o, C, w) {
|
|
169
169
|
var n = r.children;
|
|
170
170
|
if (n !== void 0)
|
|
171
171
|
if (o)
|
|
172
|
-
if (
|
|
172
|
+
if (K(n)) {
|
|
173
173
|
for (o = 0; o < n.length; o++)
|
|
174
|
-
|
|
174
|
+
P(n[o]);
|
|
175
175
|
Object.freeze && Object.freeze(n);
|
|
176
176
|
} else
|
|
177
177
|
console.error(
|
|
178
178
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
179
179
|
);
|
|
180
|
-
else
|
|
181
|
-
if (
|
|
182
|
-
n =
|
|
183
|
-
var
|
|
184
|
-
return
|
|
180
|
+
else P(n);
|
|
181
|
+
if (W.call(r, "key")) {
|
|
182
|
+
n = s(e);
|
|
183
|
+
var i = Object.keys(r).filter(function(Q) {
|
|
184
|
+
return Q !== "key";
|
|
185
185
|
});
|
|
186
|
-
o = 0 <
|
|
186
|
+
o = 0 < i.length ? "{key: someKey, " + i.join(": ..., ") + ": ...}" : "{key: someKey}", L[n + o] || (i = 0 < i.length ? "{" + i.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
187
187
|
`A props object containing a "key" prop is being spread into JSX:
|
|
188
188
|
let props = %s;
|
|
189
189
|
<%s {...props} />
|
|
@@ -192,14 +192,14 @@ React keys must be passed directly to JSX without using spread:
|
|
|
192
192
|
<%s key={someKey} {...props} />`,
|
|
193
193
|
o,
|
|
194
194
|
n,
|
|
195
|
-
|
|
195
|
+
i,
|
|
196
196
|
n
|
|
197
197
|
), L[n + o] = !0);
|
|
198
198
|
}
|
|
199
|
-
if (n = null, t !== void 0 && (
|
|
199
|
+
if (n = null, t !== void 0 && (l(t), n = "" + t), d(r) && (l(r.key), n = "" + r.key), "key" in r) {
|
|
200
200
|
t = {};
|
|
201
|
-
for (var
|
|
202
|
-
|
|
201
|
+
for (var k in r)
|
|
202
|
+
k !== "key" && (t[k] = r[k]);
|
|
203
203
|
} else t = r;
|
|
204
204
|
return n && b(
|
|
205
205
|
t,
|
|
@@ -208,58 +208,58 @@ React keys must be passed directly to JSX without using spread:
|
|
|
208
208
|
e,
|
|
209
209
|
n,
|
|
210
210
|
t,
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
c(),
|
|
212
|
+
C,
|
|
213
213
|
w
|
|
214
214
|
);
|
|
215
215
|
}
|
|
216
|
-
function
|
|
217
|
-
|
|
216
|
+
function P(e) {
|
|
217
|
+
j(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === m && (e._payload.status === "fulfilled" ? j(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function j(e) {
|
|
220
220
|
return typeof e == "object" && e !== null && e.$$typeof === M;
|
|
221
221
|
}
|
|
222
|
-
var
|
|
222
|
+
var E = Ee, M = /* @__PURE__ */ Symbol.for("react.transitional.element"), q = /* @__PURE__ */ Symbol.for("react.portal"), h = /* @__PURE__ */ Symbol.for("react.fragment"), J = /* @__PURE__ */ Symbol.for("react.strict_mode"), X = /* @__PURE__ */ Symbol.for("react.profiler"), z = /* @__PURE__ */ Symbol.for("react.consumer"), G = /* @__PURE__ */ Symbol.for("react.context"), A = /* @__PURE__ */ Symbol.for("react.forward_ref"), H = /* @__PURE__ */ Symbol.for("react.suspense"), $ = /* @__PURE__ */ Symbol.for("react.suspense_list"), Z = /* @__PURE__ */ Symbol.for("react.memo"), m = /* @__PURE__ */ Symbol.for("react.lazy"), I = /* @__PURE__ */ Symbol.for("react.activity"), v = /* @__PURE__ */ Symbol.for("react.client.reference"), R = E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, W = Object.prototype.hasOwnProperty, K = Array.isArray, g = console.createTask ? console.createTask : function() {
|
|
223
223
|
return null;
|
|
224
224
|
};
|
|
225
|
-
|
|
225
|
+
E = {
|
|
226
226
|
react_stack_bottom_frame: function(e) {
|
|
227
227
|
return e();
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
|
-
var
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
)(), F =
|
|
234
|
-
|
|
235
|
-
var o = 1e4 >
|
|
236
|
-
return
|
|
230
|
+
var p, Y = {}, D = E.react_stack_bottom_frame.bind(
|
|
231
|
+
E,
|
|
232
|
+
u
|
|
233
|
+
)(), F = g(f(u)), L = {};
|
|
234
|
+
S.Fragment = h, S.jsx = function(e, r, t) {
|
|
235
|
+
var o = 1e4 > R.recentlyCreatedOwnerStacks++;
|
|
236
|
+
return N(
|
|
237
237
|
e,
|
|
238
238
|
r,
|
|
239
239
|
t,
|
|
240
240
|
!1,
|
|
241
241
|
o ? Error("react-stack-top-frame") : D,
|
|
242
|
-
o ?
|
|
242
|
+
o ? g(f(e)) : F
|
|
243
243
|
);
|
|
244
|
-
},
|
|
245
|
-
var o = 1e4 >
|
|
246
|
-
return
|
|
244
|
+
}, S.jsxs = function(e, r, t) {
|
|
245
|
+
var o = 1e4 > R.recentlyCreatedOwnerStacks++;
|
|
246
|
+
return N(
|
|
247
247
|
e,
|
|
248
248
|
r,
|
|
249
249
|
t,
|
|
250
250
|
!0,
|
|
251
251
|
o ? Error("react-stack-top-frame") : D,
|
|
252
|
-
o ?
|
|
252
|
+
o ? g(f(e)) : F
|
|
253
253
|
);
|
|
254
254
|
};
|
|
255
|
-
})()),
|
|
255
|
+
})()), S;
|
|
256
256
|
}
|
|
257
|
-
var
|
|
258
|
-
function
|
|
259
|
-
return
|
|
257
|
+
var le;
|
|
258
|
+
function xe() {
|
|
259
|
+
return le || (le = 1, process.env.NODE_ENV === "production" ? U.exports = Re() : U.exports = Ce()), U.exports;
|
|
260
260
|
}
|
|
261
|
-
var V =
|
|
262
|
-
const
|
|
261
|
+
var V = xe();
|
|
262
|
+
const ce = {
|
|
263
263
|
solid: {
|
|
264
264
|
surfaceColor: "#3b82f6",
|
|
265
265
|
sideColor: "#1d4ed8",
|
|
@@ -341,84 +341,99 @@ const le = {
|
|
|
341
341
|
borderWidth: 4
|
|
342
342
|
}
|
|
343
343
|
};
|
|
344
|
-
function B(
|
|
345
|
-
return Math.max(
|
|
344
|
+
function B(s, a, l) {
|
|
345
|
+
return Math.max(a, Math.min(l, s));
|
|
346
346
|
}
|
|
347
|
-
function
|
|
348
|
-
children:
|
|
349
|
-
onClick:
|
|
350
|
-
disabled:
|
|
351
|
-
variant:
|
|
352
|
-
elevation:
|
|
353
|
-
pressInset:
|
|
347
|
+
function we({
|
|
348
|
+
children: s,
|
|
349
|
+
onClick: a,
|
|
350
|
+
disabled: l = !1,
|
|
351
|
+
variant: f = "solid",
|
|
352
|
+
elevation: c = 14,
|
|
353
|
+
pressInset: u = 5,
|
|
354
354
|
tilt: d = 2,
|
|
355
355
|
motion: b = 160,
|
|
356
|
-
width:
|
|
356
|
+
width: T = 260,
|
|
357
357
|
height: _ = 64,
|
|
358
|
-
radius:
|
|
359
|
-
surfaceColor:
|
|
360
|
-
sideColor:
|
|
361
|
-
textColor:
|
|
358
|
+
radius: N = 14,
|
|
359
|
+
surfaceColor: P,
|
|
360
|
+
sideColor: j,
|
|
361
|
+
textColor: E,
|
|
362
362
|
bordered: M,
|
|
363
363
|
borderColor: q,
|
|
364
|
-
borderWidth:
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
364
|
+
borderWidth: h,
|
|
365
|
+
glareColor: J = "#ffffff",
|
|
366
|
+
glareOpacity: X = 0,
|
|
367
|
+
glareWidth: z = 0,
|
|
368
|
+
className: G = "",
|
|
369
|
+
style: A,
|
|
370
|
+
...H
|
|
368
371
|
}) {
|
|
369
|
-
const $ =
|
|
370
|
-
if (
|
|
371
|
-
const
|
|
372
|
-
if (!
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
},
|
|
376
|
-
|
|
377
|
-
},
|
|
378
|
-
|
|
379
|
-
},
|
|
380
|
-
|
|
381
|
-
},
|
|
372
|
+
const $ = ve(null), [Z, m] = ne(!1), [I, v] = ne(null), R = Math.max(0, Number(_) || 0), W = Math.max(0, Number(c) || 0), g = R * 0.3, p = B(W, 0, g), Y = Math.max(0, Number(u) || 0), D = B(Y, 0, p), F = Math.max(0, Number(d) || 0), L = Number((p / 9).toFixed(2)), e = B(F, 0, L), r = R - p, t = Math.max(0, Math.floor(r / 4)), o = Math.max(0, Number(N) || 0), C = B(o, 0, t), w = Math.max(0, Number(b) || 0), n = (O) => {
|
|
373
|
+
if (l) return;
|
|
374
|
+
const ee = $.current;
|
|
375
|
+
if (!ee) return;
|
|
376
|
+
const re = ee.getBoundingClientRect(), te = O.clientX - re.left, oe = re.width || 1;
|
|
377
|
+
te < oe * 0.33 ? v("left") : te > oe * 0.66 ? v("right") : v("middle");
|
|
378
|
+
}, i = () => {
|
|
379
|
+
v(null), m(!1);
|
|
380
|
+
}, k = (O) => {
|
|
381
|
+
l || O.button === 0 && m(!0);
|
|
382
|
+
}, Q = (O) => {
|
|
383
|
+
l || (m(!1), a && a(O));
|
|
384
|
+
}, x = ce[f] || ce.solid, ue = P ?? x.surfaceColor, fe = j ?? x.sideColor, ie = E ?? x.textColor, de = M ?? x.bordered, be = q ?? x.borderColor, me = h ?? x.borderWidth, pe = {
|
|
382
385
|
...{
|
|
383
|
-
"--button-raise-level": `${
|
|
384
|
-
"--press-inset": `${
|
|
385
|
-
"--button-hover-pressure":
|
|
386
|
-
"--transform-speed": `${
|
|
387
|
-
"--radius": `${
|
|
388
|
-
"--surface-color":
|
|
389
|
-
"--side-color":
|
|
390
|
-
"--text-color":
|
|
391
|
-
"--border-color":
|
|
392
|
-
"--border-width": `${
|
|
393
|
-
|
|
386
|
+
"--button-raise-level": `${p}px`,
|
|
387
|
+
"--press-inset": `${D}px`,
|
|
388
|
+
"--button-hover-pressure": e,
|
|
389
|
+
"--transform-speed": `${w}ms`,
|
|
390
|
+
"--radius": `${C}px`,
|
|
391
|
+
"--surface-color": ue,
|
|
392
|
+
"--side-color": fe,
|
|
393
|
+
"--text-color": ie,
|
|
394
|
+
"--border-color": be,
|
|
395
|
+
"--border-width": `${me}px`,
|
|
396
|
+
"--glare-rgb": Te(J),
|
|
397
|
+
"--glare-alpha": X,
|
|
398
|
+
"--glare-width": z,
|
|
399
|
+
width: typeof T == "number" ? `${T}px` : T,
|
|
394
400
|
height: typeof _ == "number" ? `${_}px` : _
|
|
395
401
|
},
|
|
396
|
-
...
|
|
397
|
-
},
|
|
402
|
+
...A && typeof A == "object" ? A : {}
|
|
403
|
+
}, _e = [
|
|
398
404
|
"soft-btn",
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
405
|
+
Z && "soft-btn--active",
|
|
406
|
+
I && `soft-btn--${I}`,
|
|
407
|
+
l && "soft-btn--disabled",
|
|
408
|
+
de && "soft-btn--bordered",
|
|
409
|
+
G
|
|
404
410
|
].filter(Boolean).join(" ");
|
|
405
411
|
return /* @__PURE__ */ V.jsx(
|
|
406
412
|
"button",
|
|
407
413
|
{
|
|
408
|
-
...
|
|
414
|
+
...H,
|
|
409
415
|
ref: $,
|
|
410
|
-
className:
|
|
411
|
-
style:
|
|
412
|
-
onMouseMove:
|
|
413
|
-
onMouseLeave:
|
|
414
|
-
onMouseDown:
|
|
415
|
-
onMouseUp:
|
|
416
|
-
disabled:
|
|
417
|
-
children: /* @__PURE__ */ V.jsx("span", { className: "soft-btn__wrapper", children: /* @__PURE__ */ V.jsx("span", { className: "soft-btn__content", children: /* @__PURE__ */ V.jsx("span", { className: "soft-btn__inner", children:
|
|
416
|
+
className: _e,
|
|
417
|
+
style: pe,
|
|
418
|
+
onMouseMove: n,
|
|
419
|
+
onMouseLeave: i,
|
|
420
|
+
onMouseDown: k,
|
|
421
|
+
onMouseUp: Q,
|
|
422
|
+
disabled: l,
|
|
423
|
+
children: /* @__PURE__ */ V.jsx("span", { className: "soft-btn__wrapper", children: /* @__PURE__ */ V.jsx("span", { className: "soft-btn__content", children: /* @__PURE__ */ V.jsx("span", { className: "soft-btn__inner", children: s }) }) })
|
|
418
424
|
}
|
|
419
425
|
);
|
|
420
426
|
}
|
|
427
|
+
function Te(s) {
|
|
428
|
+
if (!s || typeof s != "string")
|
|
429
|
+
return "255,255,255";
|
|
430
|
+
let a = s.replace("#", "");
|
|
431
|
+
if (a.length === 3 && (a = a.split("").map((u) => u + u).join("")), a.length !== 6)
|
|
432
|
+
return "255,255,255";
|
|
433
|
+
const l = parseInt(a.slice(0, 2), 16), f = parseInt(a.slice(2, 4), 16), c = parseInt(a.slice(4, 6), 16);
|
|
434
|
+
return `${l},${f},${c}`;
|
|
435
|
+
}
|
|
421
436
|
export {
|
|
422
|
-
|
|
423
|
-
|
|
437
|
+
we as TiltButton,
|
|
438
|
+
ce as TiltButtonVariants
|
|
424
439
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(i,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],d):(i=typeof globalThis<"u"?globalThis:i||self,d(i["react-tilt-button"]={},i.React))})(this,(function(i,d){"use strict";var
|
|
1
|
+
(function(i,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],d):(i=typeof globalThis<"u"?globalThis:i||self,d(i["react-tilt-button"]={},i.React))})(this,(function(i,d){"use strict";var P={exports:{}},g={};var te;function fe(){if(te)return g;te=1;var s=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function l(f,c,u){var m=null;if(u!==void 0&&(m=""+u),c.key!==void 0&&(m=""+c.key),"key"in c){u={};for(var p in c)p!=="key"&&(u[p]=c[p])}else u=c;return c=u.ref,{$$typeof:s,type:f,key:m,ref:c!==void 0?c:null,props:u}}return g.Fragment=a,g.jsx=l,g.jsxs=l,g}var y={};var oe;function ie(){return oe||(oe=1,process.env.NODE_ENV!=="production"&&(function(){function s(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===T?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case w:return"Fragment";case H:return"Profiler";case q:return"StrictMode";case K:return"Suspense";case F:return"SuspenseList";case L:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case G:return"Portal";case Q:return e.displayName||"Context";case Z:return(e._context.displayName||"Context")+".Consumer";case O:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ee:return r=e.displayName||null,r!==null?r:s(e.type)||"Memo";case _:r=e._payload,e=e._init;try{return s(e(r))}catch{}}return null}function a(e){return""+e}function l(e){try{a(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,o=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",o),a(e)}}function f(e){if(e===w)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===_)return"<...>";try{var r=s(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function c(){var e=C.A;return e===null?null:e.getOwner()}function u(){return Error("react-stack-top-frame")}function m(e){if(U.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function p(e,r){function t(){v||(v=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function A(){var e=s(this.type);return V[e]||(V[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function E(e,r,t,o,x,k){var n=t.ref;return e={$$typeof:D,type:e,key:r,props:t,_owner:o},(n!==void 0?n:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:A}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:x}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:k}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function W(e,r,t,o,x,k){var n=r.children;if(n!==void 0)if(o)if(ae(n)){for(o=0;o<n.length;o++)Y(n[o]);Object.freeze&&Object.freeze(n)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Y(n);if(U.call(r,"key")){n=s(e);var b=Object.keys(r).filter(function(re){return re!=="key"});o=0<b.length?"{key: someKey, "+b.join(": ..., ")+": ...}":"{key: someKey}",X[n+o]||(b=0<b.length?"{"+b.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,o,n,
|
|
6
|
+
<%s key={someKey} {...props} />`,o,n,b,n),X[n+o]=!0)}if(n=null,t!==void 0&&(l(t),n=""+t),m(r)&&(l(r.key),n=""+r.key),"key"in r){t={};for(var j in r)j!=="key"&&(t[j]=r[j])}else t=r;return n&&p(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),E(e,n,t,c(),x,k)}function Y(e){$(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===_&&(e._payload.status==="fulfilled"?$(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function $(e){return typeof e=="object"&&e!==null&&e.$$typeof===D}var R=d,D=Symbol.for("react.transitional.element"),G=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),H=Symbol.for("react.profiler"),Z=Symbol.for("react.consumer"),Q=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),K=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),ee=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),L=Symbol.for("react.activity"),T=Symbol.for("react.client.reference"),C=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=Object.prototype.hasOwnProperty,ae=Array.isArray,S=console.createTask?console.createTask:function(){return null};R={react_stack_bottom_frame:function(e){return e()}};var v,V={},B=R.react_stack_bottom_frame.bind(R,u)(),J=S(f(u)),X={};y.Fragment=w,y.jsx=function(e,r,t){var o=1e4>C.recentlyCreatedOwnerStacks++;return W(e,r,t,!1,o?Error("react-stack-top-frame"):B,o?S(f(e)):J)},y.jsxs=function(e,r,t){var o=1e4>C.recentlyCreatedOwnerStacks++;return W(e,r,t,!0,o?Error("react-stack-top-frame"):B,o?S(f(e)):J)}})()),y}var ne;function de(){return ne||(ne=1,process.env.NODE_ENV==="production"?P.exports=fe():P.exports=ie()),P.exports}var M=de();const z={solid:{surfaceColor:"#3b82f6",sideColor:"#1d4ed8",textColor:"#ffffff",bordered:!1,borderColor:"transparent",borderWidth:0},outline:{surfaceColor:"#ffffff",sideColor:"#2563eb",textColor:"#2563eb",bordered:!0,borderColor:"#2563eb",borderWidth:3},dark:{surfaceColor:"#181818",sideColor:"#494949",textColor:"#e5e7eb",bordered:!0,borderColor:"#5e5e5e",borderWidth:3},arcade:{surfaceColor:"#22b8c7",sideColor:"#e5dd4a",textColor:"#fef08a",bordered:!0,borderColor:"#fef08a",borderWidth:3},gum:{surfaceColor:"#f472b6",sideColor:"#db2777",textColor:"#ffffff",bordered:!1,borderColor:"transparent",borderWidth:0},carbon:{surfaceColor:"#2a2a37",sideColor:"#8b5e3c",textColor:"#c4a484",bordered:!0,borderColor:"#8b5f39",borderWidth:4},warning:{surfaceColor:"#2c2c39",sideColor:"#b22b3b",textColor:"#fff7ed",bordered:!0,borderColor:"#d9445b",borderWidth:4},steel:{surfaceColor:"#cbd5e1",sideColor:"#64748b",textColor:"#020617",bordered:!0,borderColor:"#475569",borderWidth:2},gold:{surfaceColor:"#ffcf10",sideColor:"#d29000",textColor:"#422006",bordered:!0,borderColor:"#fff0a8",borderWidth:2},lavender:{surfaceColor:"#cec3fd",sideColor:"#b489ff",textColor:"#2e1065",bordered:!1,borderColor:"#a36eff",borderWidth:4}};function I(s,a,l){return Math.max(a,Math.min(l,s))}function be({children:s,onClick:a,disabled:l=!1,variant:f="solid",elevation:c=14,pressInset:u=5,tilt:m=2,motion:p=160,width:A=260,height:E=64,radius:W=14,surfaceColor:Y,sideColor:$,textColor:R,bordered:D,borderColor:G,borderWidth:w,glareColor:q="#ffffff",glareOpacity:H=0,glareWidth:Z=0,className:Q="",style:O,...K}){const F=d.useRef(null),[ee,_]=d.useState(!1),[L,T]=d.useState(null),C=Math.max(0,Number(E)||0),U=Math.max(0,Number(c)||0),S=C*.3,v=I(U,0,S),V=Math.max(0,Number(u)||0),B=I(V,0,v),J=Math.max(0,Number(m)||0),X=Number((v/9).toFixed(2)),e=I(J,0,X),r=C-v,t=Math.max(0,Math.floor(r/4)),o=Math.max(0,Number(W)||0),x=I(o,0,t),k=Math.max(0,Number(p)||0),n=N=>{if(l)return;const se=F.current;if(!se)return;const le=se.getBoundingClientRect(),ce=N.clientX-le.left,ue=le.width||1;ce<ue*.33?T("left"):ce>ue*.66?T("right"):T("middle")},b=()=>{T(null),_(!1)},j=N=>{l||N.button===0&&_(!0)},re=N=>{l||(_(!1),a&&a(N))},h=z[f]||z.solid,pe=Y??h.surfaceColor,_e=$??h.sideColor,ve=R??h.textColor,Ee=D??h.bordered,Re=G??h.borderColor,Te=w??h.borderWidth,Ce={...{"--button-raise-level":`${v}px`,"--press-inset":`${B}px`,"--button-hover-pressure":e,"--transform-speed":`${k}ms`,"--radius":`${x}px`,"--surface-color":pe,"--side-color":_e,"--text-color":ve,"--border-color":Re,"--border-width":`${Te}px`,"--glare-rgb":me(q),"--glare-alpha":H,"--glare-width":Z,width:typeof A=="number"?`${A}px`:A,height:typeof E=="number"?`${E}px`:E},...O&&typeof O=="object"?O:{}},xe=["soft-btn",ee&&"soft-btn--active",L&&`soft-btn--${L}`,l&&"soft-btn--disabled",Ee&&"soft-btn--bordered",Q].filter(Boolean).join(" ");return M.jsx("button",{...K,ref:F,className:xe,style:Ce,onMouseMove:n,onMouseLeave:b,onMouseDown:j,onMouseUp:re,disabled:l,children:M.jsx("span",{className:"soft-btn__wrapper",children:M.jsx("span",{className:"soft-btn__content",children:M.jsx("span",{className:"soft-btn__inner",children:s})})})})}function me(s){if(!s||typeof s!="string")return"255,255,255";let a=s.replace("#","");if(a.length===3&&(a=a.split("").map(u=>u+u).join("")),a.length!==6)return"255,255,255";const l=parseInt(a.slice(0,2),16),f=parseInt(a.slice(2,4),16),c=parseInt(a.slice(4,6),16);return`${l},${f},${c}`}i.TiltButton=be,i.TiltButtonVariants=z,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|