artode-icons 0.1.3 → 0.1.4
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.js +32 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -142,7 +142,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
142
142
|
var InteractiveArtodeIcon = ({
|
|
143
143
|
path,
|
|
144
144
|
size = 32,
|
|
145
|
-
color = "
|
|
145
|
+
color = "currentColor",
|
|
146
146
|
className,
|
|
147
147
|
forceHover = false,
|
|
148
148
|
globalMouse = false,
|
|
@@ -152,9 +152,20 @@ var InteractiveArtodeIcon = ({
|
|
|
152
152
|
var _a, _b;
|
|
153
153
|
const canvasRef = (0, import_react.useRef)(null);
|
|
154
154
|
const [internalHover, setInternalHover] = (0, import_react.useState)(false);
|
|
155
|
+
const [resolvedColor, setResolvedColor] = (0, import_react.useState)(color === "currentColor" ? "#D80018" : color);
|
|
155
156
|
const isHovered = forceHover || internalHover || globalMouse;
|
|
156
157
|
const width = (_a = customCanvasSize == null ? void 0 : customCanvasSize.width) != null ? _a : size;
|
|
157
158
|
const height = (_b = customCanvasSize == null ? void 0 : customCanvasSize.height) != null ? _b : size;
|
|
159
|
+
(0, import_react.useEffect)(() => {
|
|
160
|
+
if (color !== "currentColor") {
|
|
161
|
+
setResolvedColor(color);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const canvas = canvasRef.current;
|
|
165
|
+
if (!canvas) return;
|
|
166
|
+
const computedColor = window.getComputedStyle(canvas).color;
|
|
167
|
+
setResolvedColor(computedColor || "#D80018");
|
|
168
|
+
}, [color, className]);
|
|
158
169
|
const isHoveredRef = (0, import_react.useRef)(isHovered);
|
|
159
170
|
(0, import_react.useEffect)(() => {
|
|
160
171
|
isHoveredRef.current = isHovered;
|
|
@@ -237,7 +248,7 @@ var InteractiveArtodeIcon = ({
|
|
|
237
248
|
let animId;
|
|
238
249
|
const render = () => {
|
|
239
250
|
ctx.clearRect(0, 0, width, height);
|
|
240
|
-
ctx.fillStyle =
|
|
251
|
+
ctx.fillStyle = resolvedColor;
|
|
241
252
|
if (isHoveredRef.current) {
|
|
242
253
|
particles.forEach((p) => {
|
|
243
254
|
const tx = mouseRef.current.x + p.swarmOffset.x;
|
|
@@ -266,7 +277,7 @@ var InteractiveArtodeIcon = ({
|
|
|
266
277
|
return () => {
|
|
267
278
|
if (animId) cancelAnimationFrame(animId);
|
|
268
279
|
};
|
|
269
|
-
}, [path, size,
|
|
280
|
+
}, [path, size, resolvedColor, width, height]);
|
|
270
281
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
271
282
|
"canvas",
|
|
272
283
|
{
|
|
@@ -285,7 +296,7 @@ var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
|
285
296
|
var ArtodeIcon = ({
|
|
286
297
|
path: pathString,
|
|
287
298
|
size = 32,
|
|
288
|
-
color = "
|
|
299
|
+
color = "currentColor",
|
|
289
300
|
className,
|
|
290
301
|
forceHover = false,
|
|
291
302
|
drawType = "fill",
|
|
@@ -294,13 +305,27 @@ var ArtodeIcon = ({
|
|
|
294
305
|
customCanvasSize,
|
|
295
306
|
viewBoxSize = 24
|
|
296
307
|
}) => {
|
|
308
|
+
const canvasRef = (0, import_react2.useRef)(null);
|
|
309
|
+
const [internalHover, setInternalHover] = import_react2.default.useState(false);
|
|
310
|
+
const [resolvedColor, setResolvedColor] = import_react2.default.useState(color === "currentColor" ? "#D80018" : color);
|
|
311
|
+
const isHovered = forceHover || internalHover;
|
|
312
|
+
(0, import_react2.useEffect)(() => {
|
|
313
|
+
if (color !== "currentColor") {
|
|
314
|
+
setResolvedColor(color);
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
const canvas = canvasRef.current;
|
|
318
|
+
if (!canvas) return;
|
|
319
|
+
const computedColor = window.getComputedStyle(canvas).color;
|
|
320
|
+
setResolvedColor(computedColor || "#D80018");
|
|
321
|
+
}, [color, className]);
|
|
297
322
|
if (interactive) {
|
|
298
323
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
299
324
|
InteractiveArtodeIcon,
|
|
300
325
|
{
|
|
301
326
|
path: pathString,
|
|
302
327
|
size,
|
|
303
|
-
color,
|
|
328
|
+
color: resolvedColor,
|
|
304
329
|
className,
|
|
305
330
|
forceHover,
|
|
306
331
|
globalMouse,
|
|
@@ -309,9 +334,6 @@ var ArtodeIcon = ({
|
|
|
309
334
|
}
|
|
310
335
|
);
|
|
311
336
|
}
|
|
312
|
-
const canvasRef = (0, import_react2.useRef)(null);
|
|
313
|
-
const [internalHover, setInternalHover] = import_react2.default.useState(false);
|
|
314
|
-
const isHovered = forceHover || internalHover;
|
|
315
337
|
(0, import_react2.useEffect)(() => {
|
|
316
338
|
const canvas = canvasRef.current;
|
|
317
339
|
if (!canvas) return;
|
|
@@ -356,7 +378,7 @@ var ArtodeIcon = ({
|
|
|
356
378
|
time = 1;
|
|
357
379
|
}
|
|
358
380
|
ctx.clearRect(0, 0, size, size);
|
|
359
|
-
ctx.fillStyle =
|
|
381
|
+
ctx.fillStyle = resolvedColor;
|
|
360
382
|
for (let y = 0; y < size; y++) {
|
|
361
383
|
for (let x = 0; x < size; x++) {
|
|
362
384
|
const index = (y * size + x) * 4;
|
|
@@ -390,7 +412,7 @@ var ArtodeIcon = ({
|
|
|
390
412
|
return () => {
|
|
391
413
|
if (animId) cancelAnimationFrame(animId);
|
|
392
414
|
};
|
|
393
|
-
}, [pathString, size,
|
|
415
|
+
}, [pathString, size, resolvedColor, isHovered, drawType, viewBoxSize]);
|
|
394
416
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
395
417
|
"canvas",
|
|
396
418
|
{
|