react-tilt-button 0.1.2 → 0.1.3
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 +10 -9
- package/dist/react-tilt-button.es.js +150 -141
- package/dist/react-tilt-button.umd.js +3 -3
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -135,15 +135,16 @@ So the button:
|
|
|
135
135
|
|
|
136
136
|
### Geometry
|
|
137
137
|
|
|
138
|
-
| Prop | Type | Default | Notes
|
|
139
|
-
| ------------ | ---------------- | ------- |
|
|
140
|
-
| `width` | number \| string | `260` | No max
|
|
141
|
-
| `height` | number \| string | `64` | No max
|
|
142
|
-
| `elevation` | number | `14` | Clamped to `height * 0.3`
|
|
143
|
-
| `pressInset` | number | `5` | Clamped to `<= elevation`
|
|
144
|
-
| `tilt` | number | `2` | Clamped to `<= elevation / 9`
|
|
145
|
-
| `
|
|
146
|
-
| `
|
|
138
|
+
| Prop | Type | Default | Notes |
|
|
139
|
+
| ------------ | ---------------- | ------- | ----------------------------------------------------- |
|
|
140
|
+
| `width` | number \| string | `260` | No max |
|
|
141
|
+
| `height` | number \| string | `64` | No max |
|
|
142
|
+
| `elevation` | number | `14` | Clamped to `height * 0.3` |
|
|
143
|
+
| `pressInset` | number | `5` | Clamped to `<= elevation` |
|
|
144
|
+
| `tilt` | number | `2` | Clamped to `<= elevation / 9` |
|
|
145
|
+
| `pressTilt` | boolean | `true` | When `true`, the button keeps its skew while pressing |
|
|
146
|
+
| `radius` | number | `14` | Clamped to `<= faceHeight / 4` |
|
|
147
|
+
| `motion` | number (ms) | `160` | Animation speed |
|
|
147
148
|
|
|
148
149
|
---
|
|
149
150
|
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.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;--edge-aa: 0px;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-radius:var(--radius);z-index:1}.soft-btn--active .soft-btn__wrapper:before{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;z-index:2;box-shadow:inset 0 0 0 var(--border-width) var(--border-color),0 0 var(--edge-aa) #00000073}.soft-btn__inner{display:inline-flex;align-items:center;justify-content:center;gap:10px;z-index:4;width:100%;height:100%}.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--left,.soft-btn--right{--edge-aa: 1px}.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__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:after{opacity:1;background:rgba(var(--glare-rgb),var(--glare-alpha));background-position:50% 50%}@supports (-moz-appearance: none){.soft-btn--left,.soft-btn--right{--edge-aa: 1.25px}}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
-
import
|
|
3
|
-
var X = { exports: {} },
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
if (
|
|
7
|
-
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.soft-btn{--button-raise-level: 14px;--press-inset: 5px;--press-compensated: 0px;--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;--edge-aa: 0px;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-radius:var(--radius);z-index:1}.soft-btn--active .soft-btn__wrapper:before{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;z-index:2;box-shadow:inset 0 0 0 var(--border-width) var(--border-color),0 0 var(--edge-aa) #00000073}.soft-btn__inner{display:inline-flex;align-items:center;justify-content:center;gap:10px;z-index:4;width:100%;height:100%}.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--left,.soft-btn--right{--edge-aa: 1px}.soft-btn--active .soft-btn__content{transform:translateY(var(--press-inset));transition:transform calc(var(--transform-speed) * .8) ease-out}.soft-btn--press-tilt.soft-btn--active.soft-btn--left .soft-btn__content{transform:skewY(calc(-1deg * var(--button-hover-pressure))) translateY(var(--press-compensated))}.soft-btn--press-tilt.soft-btn--active.soft-btn--right .soft-btn__content{transform:skewY(calc(1deg * var(--button-hover-pressure))) translateY(var(--press-compensated))}.soft-btn--disabled{opacity:.6;pointer-events:none}.soft-btn--disabled .soft-btn__content:after{opacity:0}.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:after{opacity:1;background:rgba(var(--glare-rgb),var(--glare-alpha));background-position:50% 50%}@supports (-moz-appearance: none){.soft-btn--left,.soft-btn--right{--edge-aa: 1.25px}}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
+
import Pe, { useRef as ge, useState as se } from "react";
|
|
3
|
+
var X = { exports: {} }, M = {};
|
|
4
|
+
var le;
|
|
5
|
+
function ye() {
|
|
6
|
+
if (le) return M;
|
|
7
|
+
le = 1;
|
|
8
8
|
var c = /* @__PURE__ */ Symbol.for("react.transitional.element"), s = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
9
9
|
function l(d, i, u) {
|
|
10
|
-
var
|
|
11
|
-
if (u !== void 0 && (
|
|
10
|
+
var _ = null;
|
|
11
|
+
if (u !== void 0 && (_ = "" + u), i.key !== void 0 && (_ = "" + i.key), "key" in i) {
|
|
12
12
|
u = {};
|
|
13
|
-
for (var
|
|
14
|
-
|
|
13
|
+
for (var E in i)
|
|
14
|
+
E !== "key" && (u[E] = i[E]);
|
|
15
15
|
} else u = i;
|
|
16
16
|
return i = u.ref, {
|
|
17
17
|
$$typeof: c,
|
|
18
18
|
type: d,
|
|
19
|
-
key:
|
|
19
|
+
key: _,
|
|
20
20
|
ref: i !== void 0 ? i : null,
|
|
21
21
|
props: u
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
return
|
|
24
|
+
return M.Fragment = s, M.jsx = l, M.jsxs = l, M;
|
|
25
25
|
}
|
|
26
26
|
var $ = {};
|
|
27
|
-
var
|
|
28
|
-
function
|
|
29
|
-
return
|
|
27
|
+
var ce;
|
|
28
|
+
function Ae() {
|
|
29
|
+
return ce || (ce = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
30
30
|
function c(e) {
|
|
31
31
|
if (e == null) return null;
|
|
32
32
|
if (typeof e == "function")
|
|
33
|
-
return e.$$typeof ===
|
|
33
|
+
return e.$$typeof === k ? null : e.displayName || e.name || null;
|
|
34
34
|
if (typeof e == "string") return e;
|
|
35
35
|
switch (e) {
|
|
36
|
-
case
|
|
36
|
+
case R:
|
|
37
37
|
return "Fragment";
|
|
38
|
-
case
|
|
38
|
+
case Q:
|
|
39
39
|
return "Profiler";
|
|
40
|
-
case
|
|
40
|
+
case Z:
|
|
41
41
|
return "StrictMode";
|
|
42
|
-
case
|
|
42
|
+
case re:
|
|
43
43
|
return "Suspense";
|
|
44
|
-
case
|
|
44
|
+
case C:
|
|
45
45
|
return "SuspenseList";
|
|
46
|
-
case
|
|
46
|
+
case L:
|
|
47
47
|
return "Activity";
|
|
48
48
|
}
|
|
49
49
|
if (typeof e == "object")
|
|
50
50
|
switch (typeof e.tag == "number" && console.error(
|
|
51
51
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
52
52
|
), e.$$typeof) {
|
|
53
|
-
case
|
|
53
|
+
case A:
|
|
54
54
|
return "Portal";
|
|
55
|
-
case
|
|
55
|
+
case ee:
|
|
56
56
|
return e.displayName || "Context";
|
|
57
|
-
case Q:
|
|
58
|
-
return (e._context.displayName || "Context") + ".Consumer";
|
|
59
57
|
case K:
|
|
58
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
59
|
+
case w:
|
|
60
60
|
var r = e.render;
|
|
61
61
|
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
62
62
|
case F:
|
|
@@ -91,7 +91,7 @@ function xe() {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
function d(e) {
|
|
94
|
-
if (e ===
|
|
94
|
+
if (e === R) return "<>";
|
|
95
95
|
if (typeof e == "object" && e !== null && e.$$typeof === P)
|
|
96
96
|
return "<...>";
|
|
97
97
|
try {
|
|
@@ -102,22 +102,22 @@ function xe() {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
function i() {
|
|
105
|
-
var e =
|
|
105
|
+
var e = g.A;
|
|
106
106
|
return e === null ? null : e.getOwner();
|
|
107
107
|
}
|
|
108
108
|
function u() {
|
|
109
109
|
return Error("react-stack-top-frame");
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
if (
|
|
111
|
+
function _(e) {
|
|
112
|
+
if (U.call(e, "key")) {
|
|
113
113
|
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
114
114
|
if (r && r.isReactWarning) return !1;
|
|
115
115
|
}
|
|
116
116
|
return e.key !== void 0;
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function E(e, r) {
|
|
119
119
|
function t() {
|
|
120
|
-
|
|
120
|
+
x || (x = !0, console.error(
|
|
121
121
|
"%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)",
|
|
122
122
|
r
|
|
123
123
|
));
|
|
@@ -127,23 +127,23 @@ function xe() {
|
|
|
127
127
|
configurable: !0
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function H() {
|
|
131
131
|
var e = c(this.type);
|
|
132
132
|
return V[e] || (V[e] = !0, console.error(
|
|
133
133
|
"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."
|
|
134
134
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function T(e, r, t, o, y, N) {
|
|
137
137
|
var n = t.ref;
|
|
138
138
|
return e = {
|
|
139
|
-
$$typeof:
|
|
139
|
+
$$typeof: D,
|
|
140
140
|
type: e,
|
|
141
141
|
key: r,
|
|
142
142
|
props: t,
|
|
143
143
|
_owner: o
|
|
144
144
|
}, (n !== void 0 ? n : null) !== null ? Object.defineProperty(e, "ref", {
|
|
145
145
|
enumerable: !1,
|
|
146
|
-
get:
|
|
146
|
+
get: H
|
|
147
147
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
148
148
|
configurable: !1,
|
|
149
149
|
enumerable: !1,
|
|
@@ -158,19 +158,19 @@ function xe() {
|
|
|
158
158
|
configurable: !1,
|
|
159
159
|
enumerable: !1,
|
|
160
160
|
writable: !0,
|
|
161
|
-
value:
|
|
161
|
+
value: y
|
|
162
162
|
}), Object.defineProperty(e, "_debugTask", {
|
|
163
163
|
configurable: !1,
|
|
164
164
|
enumerable: !1,
|
|
165
165
|
writable: !0,
|
|
166
|
-
value:
|
|
166
|
+
value: N
|
|
167
167
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
168
168
|
}
|
|
169
|
-
function
|
|
169
|
+
function v(e, r, t, o, y, N) {
|
|
170
170
|
var n = r.children;
|
|
171
171
|
if (n !== void 0)
|
|
172
172
|
if (o)
|
|
173
|
-
if (
|
|
173
|
+
if (oe(n)) {
|
|
174
174
|
for (o = 0; o < n.length; o++)
|
|
175
175
|
W(n[o]);
|
|
176
176
|
Object.freeze && Object.freeze(n);
|
|
@@ -179,12 +179,12 @@ function xe() {
|
|
|
179
179
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
180
180
|
);
|
|
181
181
|
else W(n);
|
|
182
|
-
if (
|
|
182
|
+
if (U.call(r, "key")) {
|
|
183
183
|
n = c(e);
|
|
184
|
-
var
|
|
184
|
+
var b = Object.keys(r).filter(function(te) {
|
|
185
185
|
return te !== "key";
|
|
186
186
|
});
|
|
187
|
-
o = 0 <
|
|
187
|
+
o = 0 < b.length ? "{key: someKey, " + b.join(": ..., ") + ": ...}" : "{key: someKey}", q[n + o] || (b = 0 < b.length ? "{" + b.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
188
188
|
`A props object containing a "key" prop is being spread into JSX:
|
|
189
189
|
let props = %s;
|
|
190
190
|
<%s {...props} />
|
|
@@ -193,74 +193,74 @@ React keys must be passed directly to JSX without using spread:
|
|
|
193
193
|
<%s key={someKey} {...props} />`,
|
|
194
194
|
o,
|
|
195
195
|
n,
|
|
196
|
-
|
|
196
|
+
b,
|
|
197
197
|
n
|
|
198
|
-
),
|
|
198
|
+
), q[n + o] = !0);
|
|
199
199
|
}
|
|
200
|
-
if (n = null, t !== void 0 && (l(t), n = "" + t),
|
|
200
|
+
if (n = null, t !== void 0 && (l(t), n = "" + t), _(r) && (l(r.key), n = "" + r.key), "key" in r) {
|
|
201
201
|
t = {};
|
|
202
|
-
for (var
|
|
203
|
-
|
|
202
|
+
for (var j in r)
|
|
203
|
+
j !== "key" && (t[j] = r[j]);
|
|
204
204
|
} else t = r;
|
|
205
|
-
return n &&
|
|
205
|
+
return n && E(
|
|
206
206
|
t,
|
|
207
207
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
208
|
-
),
|
|
208
|
+
), T(
|
|
209
209
|
e,
|
|
210
210
|
n,
|
|
211
211
|
t,
|
|
212
212
|
i(),
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
y,
|
|
214
|
+
N
|
|
215
215
|
);
|
|
216
216
|
}
|
|
217
217
|
function W(e) {
|
|
218
218
|
Y(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === P && (e._payload.status === "fulfilled" ? Y(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
219
219
|
}
|
|
220
220
|
function Y(e) {
|
|
221
|
-
return typeof e == "object" && e !== null && e.$$typeof ===
|
|
221
|
+
return typeof e == "object" && e !== null && e.$$typeof === D;
|
|
222
222
|
}
|
|
223
|
-
var
|
|
223
|
+
var h = Pe, D = /* @__PURE__ */ Symbol.for("react.transitional.element"), A = /* @__PURE__ */ Symbol.for("react.portal"), R = /* @__PURE__ */ Symbol.for("react.fragment"), Z = /* @__PURE__ */ Symbol.for("react.strict_mode"), Q = /* @__PURE__ */ Symbol.for("react.profiler"), K = /* @__PURE__ */ Symbol.for("react.consumer"), ee = /* @__PURE__ */ Symbol.for("react.context"), w = /* @__PURE__ */ Symbol.for("react.forward_ref"), re = /* @__PURE__ */ Symbol.for("react.suspense"), C = /* @__PURE__ */ Symbol.for("react.suspense_list"), F = /* @__PURE__ */ Symbol.for("react.memo"), P = /* @__PURE__ */ Symbol.for("react.lazy"), L = /* @__PURE__ */ Symbol.for("react.activity"), k = /* @__PURE__ */ Symbol.for("react.client.reference"), g = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, U = Object.prototype.hasOwnProperty, oe = Array.isArray, O = console.createTask ? console.createTask : function() {
|
|
224
224
|
return null;
|
|
225
225
|
};
|
|
226
|
-
|
|
226
|
+
h = {
|
|
227
227
|
react_stack_bottom_frame: function(e) {
|
|
228
228
|
return e();
|
|
229
229
|
}
|
|
230
230
|
};
|
|
231
|
-
var
|
|
232
|
-
|
|
231
|
+
var x, V = {}, S = h.react_stack_bottom_frame.bind(
|
|
232
|
+
h,
|
|
233
233
|
u
|
|
234
|
-
)(), B =
|
|
235
|
-
$.Fragment =
|
|
236
|
-
var o = 1e4 >
|
|
237
|
-
return
|
|
234
|
+
)(), B = O(d(u)), q = {};
|
|
235
|
+
$.Fragment = R, $.jsx = function(e, r, t) {
|
|
236
|
+
var o = 1e4 > g.recentlyCreatedOwnerStacks++;
|
|
237
|
+
return v(
|
|
238
238
|
e,
|
|
239
239
|
r,
|
|
240
240
|
t,
|
|
241
241
|
!1,
|
|
242
|
-
o ? Error("react-stack-top-frame") :
|
|
243
|
-
o ?
|
|
242
|
+
o ? Error("react-stack-top-frame") : S,
|
|
243
|
+
o ? O(d(e)) : B
|
|
244
244
|
);
|
|
245
245
|
}, $.jsxs = function(e, r, t) {
|
|
246
|
-
var o = 1e4 >
|
|
247
|
-
return
|
|
246
|
+
var o = 1e4 > g.recentlyCreatedOwnerStacks++;
|
|
247
|
+
return v(
|
|
248
248
|
e,
|
|
249
249
|
r,
|
|
250
250
|
t,
|
|
251
251
|
!0,
|
|
252
|
-
o ? Error("react-stack-top-frame") :
|
|
253
|
-
o ?
|
|
252
|
+
o ? Error("react-stack-top-frame") : S,
|
|
253
|
+
o ? O(d(e)) : B
|
|
254
254
|
);
|
|
255
255
|
};
|
|
256
256
|
})()), $;
|
|
257
257
|
}
|
|
258
|
-
var
|
|
259
|
-
function
|
|
260
|
-
return
|
|
258
|
+
var ie;
|
|
259
|
+
function we() {
|
|
260
|
+
return ie || (ie = 1, process.env.NODE_ENV === "production" ? X.exports = ye() : X.exports = Ae()), X.exports;
|
|
261
261
|
}
|
|
262
|
-
var z =
|
|
263
|
-
const
|
|
262
|
+
var z = we();
|
|
263
|
+
const ue = {
|
|
264
264
|
solid: {
|
|
265
265
|
surfaceColor: "#3b82f6",
|
|
266
266
|
sideColor: "#1d4ed8",
|
|
@@ -335,99 +335,108 @@ const ce = {
|
|
|
335
335
|
function G(c, s, l) {
|
|
336
336
|
return Math.max(s, Math.min(l, c));
|
|
337
337
|
}
|
|
338
|
-
function
|
|
338
|
+
function je({
|
|
339
339
|
children: c,
|
|
340
340
|
onClick: s,
|
|
341
341
|
disabled: l = !1,
|
|
342
342
|
variant: d = "solid",
|
|
343
343
|
elevation: i = 14,
|
|
344
344
|
pressInset: u = 5,
|
|
345
|
-
tilt:
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
345
|
+
tilt: _ = 2,
|
|
346
|
+
pressTilt: E = !0,
|
|
347
|
+
motion: H = 160,
|
|
348
|
+
width: T = 260,
|
|
349
|
+
height: v = 64,
|
|
350
|
+
radius: W = 14,
|
|
351
|
+
surfaceColor: Y,
|
|
352
|
+
sideColor: h,
|
|
353
|
+
textColor: D,
|
|
354
|
+
borderColor: A,
|
|
355
|
+
borderWidth: R,
|
|
356
|
+
glareColor: Z = "#ffffff",
|
|
357
|
+
glareOpacity: Q = 0,
|
|
358
|
+
glareWidth: K = 0,
|
|
359
|
+
className: ee = "",
|
|
360
|
+
style: w,
|
|
361
|
+
...re
|
|
361
362
|
}) {
|
|
362
|
-
const
|
|
363
|
-
function
|
|
364
|
-
const
|
|
365
|
-
return
|
|
363
|
+
const C = ge(null), [F, P] = se(!1), [L, k] = se(null), g = Math.max(0, Number(v) || 0), U = Math.max(0, Number(i) || 0), O = g * 0.3, x = G(U, 0, O), V = Math.max(0, Number(u) || 0), S = G(V, 0, x), B = Math.max(0, Number(_) || 0), q = Number((x / 9).toFixed(2)), e = G(B, 0, q), t = C.current?.getBoundingClientRect()?.width || Number(T) || 0, o = e * Math.PI / 180, y = t / 2 * Math.tan(o), N = Math.max(0, S - y), n = g - x, b = Math.max(0, Math.floor(n / 4)), j = Math.max(0, Number(W) || 0), te = G(j, 0, b), fe = Math.max(0, Number(H) || 0);
|
|
364
|
+
function ne(a, f) {
|
|
365
|
+
const m = f.getBoundingClientRect(), p = a.clientX - m.left, ae = m.width || 1;
|
|
366
|
+
return p < ae * 0.33 ? "left" : p > ae * 0.66 ? "right" : "middle";
|
|
366
367
|
}
|
|
367
|
-
const
|
|
368
|
+
const de = (a) => {
|
|
368
369
|
if (l || a.button !== 0 && a.pointerType === "mouse") return;
|
|
369
|
-
const f =
|
|
370
|
+
const f = C.current;
|
|
370
371
|
if (!f) return;
|
|
371
372
|
f.setPointerCapture(a.pointerId);
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
},
|
|
373
|
+
const m = ne(a, f);
|
|
374
|
+
k((p) => p === m ? p : m), P(!0);
|
|
375
|
+
}, be = (a) => {
|
|
375
376
|
if (l || a.pointerType !== "mouse") return;
|
|
376
|
-
const f =
|
|
377
|
+
const f = C.current;
|
|
377
378
|
if (!f) return;
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
},
|
|
381
|
-
const f =
|
|
379
|
+
const m = ne(a, f);
|
|
380
|
+
k((p) => p === m ? p : m);
|
|
381
|
+
}, J = (a) => {
|
|
382
|
+
const f = C.current;
|
|
382
383
|
try {
|
|
383
384
|
f?.hasPointerCapture(a.pointerId) && f.releasePointerCapture(a.pointerId);
|
|
384
385
|
} catch {
|
|
385
386
|
}
|
|
386
|
-
|
|
387
|
-
},
|
|
388
|
-
l || (
|
|
389
|
-
},
|
|
390
|
-
l ||
|
|
391
|
-
},
|
|
392
|
-
|
|
393
|
-
},
|
|
387
|
+
P(!1), k(null), l && F && J(a);
|
|
388
|
+
}, me = (a) => {
|
|
389
|
+
l || (J(a), s && s(a));
|
|
390
|
+
}, pe = (a) => {
|
|
391
|
+
l || J(a);
|
|
392
|
+
}, _e = (a) => {
|
|
393
|
+
J(a);
|
|
394
|
+
}, I = ue[d] || ue.solid, Ee = Y ?? I.surfaceColor, ve = h ?? I.sideColor, Re = D ?? I.textColor, Ce = typeof A == "string" && A.trim() !== "" ? A : I.borderColor || "transparent", xe = typeof R == "number" && R >= 0 ? R : I.borderWidth ?? 0, Te = {
|
|
394
395
|
...{
|
|
395
|
-
"--button-raise-level": `${
|
|
396
|
-
"--press-inset": `${
|
|
397
|
-
"--
|
|
398
|
-
"--
|
|
399
|
-
"--
|
|
400
|
-
"--
|
|
401
|
-
"--
|
|
402
|
-
"--
|
|
403
|
-
"--
|
|
404
|
-
"--border-
|
|
405
|
-
"--
|
|
406
|
-
"--glare-
|
|
407
|
-
"--glare-
|
|
408
|
-
width
|
|
409
|
-
|
|
396
|
+
"--button-raise-level": `${x}px`,
|
|
397
|
+
"--press-inset": `${S}px`,
|
|
398
|
+
"--press-compensated": `${N}px`,
|
|
399
|
+
"--button-hover-pressure": e,
|
|
400
|
+
"--transform-speed": `${fe}ms`,
|
|
401
|
+
"--radius": `${te}px`,
|
|
402
|
+
"--surface-color": Ee,
|
|
403
|
+
"--side-color": ve,
|
|
404
|
+
"--text-color": Re,
|
|
405
|
+
"--border-color": Ce,
|
|
406
|
+
"--border-width": `${xe}px`,
|
|
407
|
+
"--glare-rgb": ke(Z),
|
|
408
|
+
"--glare-alpha": Q,
|
|
409
|
+
"--glare-width": K,
|
|
410
|
+
width: typeof T == "number" ? `${T}px` : T,
|
|
411
|
+
height: typeof v == "number" ? `${v}px` : v
|
|
410
412
|
},
|
|
411
|
-
...
|
|
412
|
-
},
|
|
413
|
+
...w && typeof w == "object" ? w : {}
|
|
414
|
+
}, he = [
|
|
415
|
+
"soft-btn",
|
|
416
|
+
F && "soft-btn--active",
|
|
417
|
+
L && `soft-btn--${L}`,
|
|
418
|
+
l && "soft-btn--disabled",
|
|
419
|
+
E && "soft-btn--press-tilt",
|
|
420
|
+
ee
|
|
421
|
+
].filter(Boolean).join(" ");
|
|
413
422
|
return /* @__PURE__ */ z.jsx(
|
|
414
423
|
"button",
|
|
415
424
|
{
|
|
416
|
-
...
|
|
417
|
-
ref:
|
|
418
|
-
className:
|
|
419
|
-
style:
|
|
420
|
-
onPointerDown:
|
|
421
|
-
onPointerMove:
|
|
422
|
-
onPointerUp:
|
|
423
|
-
onPointerLeave:
|
|
424
|
-
onPointerCancel:
|
|
425
|
+
...re,
|
|
426
|
+
ref: C,
|
|
427
|
+
className: he,
|
|
428
|
+
style: Te,
|
|
429
|
+
onPointerDown: de,
|
|
430
|
+
onPointerMove: be,
|
|
431
|
+
onPointerUp: me,
|
|
432
|
+
onPointerLeave: pe,
|
|
433
|
+
onPointerCancel: _e,
|
|
425
434
|
disabled: l,
|
|
426
435
|
children: /* @__PURE__ */ z.jsx("span", { className: "soft-btn__wrapper", children: /* @__PURE__ */ z.jsx("span", { className: "soft-btn__content", children: /* @__PURE__ */ z.jsx("span", { className: "soft-btn__inner", children: c }) }) })
|
|
427
436
|
}
|
|
428
437
|
);
|
|
429
438
|
}
|
|
430
|
-
function
|
|
439
|
+
function ke(c) {
|
|
431
440
|
if (!c || typeof c != "string")
|
|
432
441
|
return "255,255,255";
|
|
433
442
|
let s = c.replace("#", "");
|
|
@@ -437,6 +446,6 @@ function he(c) {
|
|
|
437
446
|
return `${l},${d},${i}`;
|
|
438
447
|
}
|
|
439
448
|
export {
|
|
440
|
-
|
|
441
|
-
|
|
449
|
+
je as TiltButton,
|
|
450
|
+
ue as TiltButtonVariants
|
|
442
451
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.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;--edge-aa: 0px;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-radius:var(--radius);z-index:1}.soft-btn--active .soft-btn__wrapper:before{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;z-index:2;box-shadow:inset 0 0 0 var(--border-width) var(--border-color),0 0 var(--edge-aa) #00000073}.soft-btn__inner{display:inline-flex;align-items:center;justify-content:center;gap:10px;z-index:4;width:100%;height:100%}.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--left,.soft-btn--right{--edge-aa: 1px}.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__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:after{opacity:1;background:rgba(var(--glare-rgb),var(--glare-alpha));background-position:50% 50%}@supports (-moz-appearance: none){.soft-btn--left,.soft-btn--right{--edge-aa: 1.25px}}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
-
(function(b,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],m):(b=typeof globalThis<"u"?globalThis:b||self,m(b["react-tilt-button"]={},b.React))})(this,(function(b,m){"use strict";var
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.soft-btn{--button-raise-level: 14px;--press-inset: 5px;--press-compensated: 0px;--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;--edge-aa: 0px;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-radius:var(--radius);z-index:1}.soft-btn--active .soft-btn__wrapper:before{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;z-index:2;box-shadow:inset 0 0 0 var(--border-width) var(--border-color),0 0 var(--edge-aa) #00000073}.soft-btn__inner{display:inline-flex;align-items:center;justify-content:center;gap:10px;z-index:4;width:100%;height:100%}.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--left,.soft-btn--right{--edge-aa: 1px}.soft-btn--active .soft-btn__content{transform:translateY(var(--press-inset));transition:transform calc(var(--transform-speed) * .8) ease-out}.soft-btn--press-tilt.soft-btn--active.soft-btn--left .soft-btn__content{transform:skewY(calc(-1deg * var(--button-hover-pressure))) translateY(var(--press-compensated))}.soft-btn--press-tilt.soft-btn--active.soft-btn--right .soft-btn__content{transform:skewY(calc(1deg * var(--button-hover-pressure))) translateY(var(--press-compensated))}.soft-btn--disabled{opacity:.6;pointer-events:none}.soft-btn--disabled .soft-btn__content:after{opacity:0}.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:after{opacity:1;background:rgba(var(--glare-rgb),var(--glare-alpha));background-position:50% 50%}@supports (-moz-appearance: none){.soft-btn--left,.soft-btn--right{--edge-aa: 1.25px}}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
+
(function(b,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],m):(b=typeof globalThis<"u"?globalThis:b||self,m(b["react-tilt-button"]={},b.React))})(this,(function(b,m){"use strict";var D={exports:{}},w={};var se;function de(){if(se)return w;se=1;var c=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function l(d,i,u){var E=null;if(u!==void 0&&(E=""+u),i.key!==void 0&&(E=""+i.key),"key"in i){u={};for(var R in i)R!=="key"&&(u[R]=i[R])}else u=i;return i=u.ref,{$$typeof:c,type:d,key:E,ref:i!==void 0?i:null,props:u}}return w.Fragment=s,w.jsx=l,w.jsxs=l,w}var O={};var le;function be(){return le||(le=1,process.env.NODE_ENV!=="production"&&(function(){function c(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case C:return"Fragment";case re:return"Profiler";case ee:return"StrictMode";case ne:return"Suspense";case x:return"SuspenseList";case X: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 k:return"Portal";case oe:return e.displayName||"Context";case te:return(e._context.displayName||"Context")+".Consumer";case N:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case J:return r=e.displayName||null,r!==null?r:c(e.type)||"Memo";case y:r=e._payload,e=e._init;try{return c(e(r))}catch{}}return null}function s(e){return""+e}function l(e){try{s(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),s(e)}}function d(e){if(e===C)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===y)return"<...>";try{var r=c(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function i(){var e=A.A;return e===null?null:e.getOwner()}function u(){return Error("react-stack-top-frame")}function E(e){if(z.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function R(e,r){function t(){h||(h=!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 K(){var e=c(this.type);return G[e]||(G[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 P(e,r,t,o,S,W){var n=t.ref;return e={$$typeof:B,type:e,key:r,props:t,_owner:o},(n!==void 0?n:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:K}):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:S}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:W}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function T(e,r,t,o,S,W){var n=r.children;if(n!==void 0)if(o)if(ie(n)){for(o=0;o<n.length;o++)U(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 U(n);if(z.call(r,"key")){n=c(e);var p=Object.keys(r).filter(function(ae){return ae!=="key"});o=0<p.length?"{key: someKey, "+p.join(": ..., ")+": ...}":"{key: someKey}",H[n+o]||(p=0<p.length?"{"+p.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
3
3
|
let props = %s;
|
|
4
4
|
<%s {...props} />
|
|
5
5
|
React keys must be passed directly to JSX without using spread:
|
|
6
6
|
let props = %s;
|
|
7
|
-
<%s key={someKey} {...props} />`,o,n,
|
|
7
|
+
<%s key={someKey} {...props} />`,o,n,p,n),H[n+o]=!0)}if(n=null,t!==void 0&&(l(t),n=""+t),E(r)&&(l(r.key),n=""+r.key),"key"in r){t={};for(var $ in r)$!=="key"&&(t[$]=r[$])}else t=r;return n&&R(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),P(e,n,t,i(),S,W)}function U(e){V(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===y&&(e._payload.status==="fulfilled"?V(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function V(e){return typeof e=="object"&&e!==null&&e.$$typeof===B}var g=m,B=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),ee=Symbol.for("react.strict_mode"),re=Symbol.for("react.profiler"),te=Symbol.for("react.consumer"),oe=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),ne=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),J=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),j=Symbol.for("react.client.reference"),A=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=Object.prototype.hasOwnProperty,ie=Array.isArray,M=console.createTask?console.createTask:function(){return null};g={react_stack_bottom_frame:function(e){return e()}};var h,G={},I=g.react_stack_bottom_frame.bind(g,u)(),q=M(d(u)),H={};O.Fragment=C,O.jsx=function(e,r,t){var o=1e4>A.recentlyCreatedOwnerStacks++;return T(e,r,t,!1,o?Error("react-stack-top-frame"):I,o?M(d(e)):q)},O.jsxs=function(e,r,t){var o=1e4>A.recentlyCreatedOwnerStacks++;return T(e,r,t,!0,o?Error("react-stack-top-frame"):I,o?M(d(e)):q)}})()),O}var ce;function me(){return ce||(ce=1,process.env.NODE_ENV==="production"?D.exports=de():D.exports=be()),D.exports}var F=me();const Q={solid:{surfaceColor:"#3b82f6",sideColor:"#1d4ed8",textColor:"#ffffff",borderColor:"transparent",borderWidth:0},outline:{surfaceColor:"#ffffff",sideColor:"#2563eb",textColor:"#2563eb",borderColor:"#2563eb",borderWidth:3},dark:{surfaceColor:"#181818",sideColor:"#494949",textColor:"#e5e7eb",borderColor:"#5e5e5e",borderWidth:3},arcade:{surfaceColor:"#22b8c7",sideColor:"#e5dd4a",textColor:"#fef08a",borderColor:"#fef08a",borderWidth:3},gum:{surfaceColor:"#f472b6",sideColor:"#db2777",textColor:"#ffffff",borderColor:"transparent",borderWidth:0},carbon:{surfaceColor:"#2a2a37",sideColor:"#8b5e3c",textColor:"#c4a484",borderColor:"#8b5f39",borderWidth:4},warning:{surfaceColor:"#2c2c39",sideColor:"#b22b3b",textColor:"#fff7ed",borderColor:"#d9445b",borderWidth:4},steel:{surfaceColor:"#cbd5e1",sideColor:"#64748b",textColor:"#020617",borderColor:"#475569",borderWidth:2},gold:{surfaceColor:"#ffcf10",sideColor:"#d29000",textColor:"#422006",borderColor:"#fff0a8",borderWidth:2},lavender:{surfaceColor:"#cec3fd",sideColor:"#b489ff",textColor:"#2e1065",borderColor:"#a36eff",borderWidth:4}};function L(c,s,l){return Math.max(s,Math.min(l,c))}function pe({children:c,onClick:s,disabled:l=!1,variant:d="solid",elevation:i=14,pressInset:u=5,tilt:E=2,pressTilt:R=!0,motion:K=160,width:P=260,height:T=64,radius:U=14,surfaceColor:V,sideColor:g,textColor:B,borderColor:k,borderWidth:C,glareColor:ee="#ffffff",glareOpacity:re=0,glareWidth:te=0,className:oe="",style:N,...ne}){const x=m.useRef(null),[J,y]=m.useState(!1),[X,j]=m.useState(null),A=Math.max(0,Number(T)||0),z=Math.max(0,Number(i)||0),M=A*.3,h=L(z,0,M),G=Math.max(0,Number(u)||0),I=L(G,0,h),q=Math.max(0,Number(E)||0),H=Number((h/9).toFixed(2)),e=L(q,0,H),t=x.current?.getBoundingClientRect()?.width||Number(P)||0,o=e*Math.PI/180,S=t/2*Math.tan(o),W=Math.max(0,I-S),n=A-h,p=Math.max(0,Math.floor(n/4)),$=Math.max(0,Number(U)||0),ae=L($,0,p),ve=Math.max(0,Number(K)||0);function ue(a,f){const _=f.getBoundingClientRect(),v=a.clientX-_.left,fe=_.width||1;return v<fe*.33?"left":v>fe*.66?"right":"middle"}const Ee=a=>{if(l||a.button!==0&&a.pointerType==="mouse")return;const f=x.current;if(!f)return;f.setPointerCapture(a.pointerId);const _=ue(a,f);j(v=>v===_?v:_),y(!0)},Re=a=>{if(l||a.pointerType!=="mouse")return;const f=x.current;if(!f)return;const _=ue(a,f);j(v=>v===_?v:_)},Z=a=>{const f=x.current;try{f?.hasPointerCapture(a.pointerId)&&f.releasePointerCapture(a.pointerId)}catch{}y(!1),j(null),l&&J&&Z(a)},Te=a=>{l||(Z(a),s&&s(a))},Ce=a=>{l||Z(a)},xe=a=>{Z(a)},Y=Q[d]||Q.solid,he=V??Y.surfaceColor,Pe=g??Y.sideColor,ge=B??Y.textColor,ye=typeof k=="string"&&k.trim()!==""?k:Y.borderColor||"transparent",Ae=typeof C=="number"&&C>=0?C:Y.borderWidth??0,Se={...{"--button-raise-level":`${h}px`,"--press-inset":`${I}px`,"--press-compensated":`${W}px`,"--button-hover-pressure":e,"--transform-speed":`${ve}ms`,"--radius":`${ae}px`,"--surface-color":he,"--side-color":Pe,"--text-color":ge,"--border-color":ye,"--border-width":`${Ae}px`,"--glare-rgb":_e(ee),"--glare-alpha":re,"--glare-width":te,width:typeof P=="number"?`${P}px`:P,height:typeof T=="number"?`${T}px`:T},...N&&typeof N=="object"?N:{}},we=["soft-btn",J&&"soft-btn--active",X&&`soft-btn--${X}`,l&&"soft-btn--disabled",R&&"soft-btn--press-tilt",oe].filter(Boolean).join(" ");return F.jsx("button",{...ne,ref:x,className:we,style:Se,onPointerDown:Ee,onPointerMove:Re,onPointerUp:Te,onPointerLeave:Ce,onPointerCancel:xe,disabled:l,children:F.jsx("span",{className:"soft-btn__wrapper",children:F.jsx("span",{className:"soft-btn__content",children:F.jsx("span",{className:"soft-btn__inner",children:c})})})})}function _e(c){if(!c||typeof c!="string")return"255,255,255";let s=c.replace("#","");if(s.length===3&&(s=s.split("").map(u=>u+u).join("")),s.length!==6)return"255,255,255";const l=parseInt(s.slice(0,2),16),d=parseInt(s.slice(2,4),16),i=parseInt(s.slice(4,6),16);return`${l},${d},${i}`}b.TiltButton=pe,b.TiltButtonVariants=Q,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-tilt-button",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "archisvaze",
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
],
|
|
12
12
|
"main": "./dist/react-tilt-button.umd.js",
|
|
13
13
|
"module": "./dist/react-tilt-button.es.js",
|
|
14
|
-
"style": "./dist/react-tilt-button.css",
|
|
15
14
|
"exports": {
|
|
16
15
|
".": {
|
|
17
16
|
"import": "./dist/react-tilt-button.es.js",
|