@nice2dev/icons 1.3.16 → 1.3.17

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -1
  3. package/dist/cjs/animationSpeed.js +69 -0
  4. package/dist/cjs/createIcon.js +45 -21
  5. package/dist/cjs/iconStyles.js +1137 -1081
  6. package/dist/cjs/icons/actions.js +2 -2
  7. package/dist/cjs/icons/brand.js +4 -747
  8. package/dist/cjs/icons/business.js +59 -23
  9. package/dist/cjs/icons/files.js +54 -54
  10. package/dist/cjs/icons/food.js +75 -557
  11. package/dist/cjs/icons/fun.js +51 -33
  12. package/dist/cjs/icons/index.js +0 -7
  13. package/dist/cjs/icons/navigation.js +26 -7
  14. package/dist/cjs/icons/omniverk.js +17 -244
  15. package/dist/cjs/icons/science.js +63 -170
  16. package/dist/cjs/icons/sports.js +45 -137
  17. package/dist/cjs/index.js +0 -7
  18. package/dist/cjs/nicetodev-icons.css +1 -1
  19. package/dist/cjs/smilAnimations.js +11 -2
  20. package/dist/esm/animationSpeed.js +69 -0
  21. package/dist/esm/createIcon.js +45 -21
  22. package/dist/esm/iconStyles.js +1137 -1081
  23. package/dist/esm/icons/actions.js +2 -2
  24. package/dist/esm/icons/brand.js +5 -748
  25. package/dist/esm/icons/business.js +59 -23
  26. package/dist/esm/icons/files.js +54 -54
  27. package/dist/esm/icons/food.js +74 -556
  28. package/dist/esm/icons/fun.js +51 -33
  29. package/dist/esm/icons/index.js +3 -10
  30. package/dist/esm/icons/navigation.js +26 -7
  31. package/dist/esm/icons/omniverk.js +17 -244
  32. package/dist/esm/icons/science.js +63 -170
  33. package/dist/esm/icons/sports.js +45 -137
  34. package/dist/esm/index.js +3 -10
  35. package/dist/esm/nicetodev-icons.css +1 -1
  36. package/dist/esm/smilAnimations.js +11 -2
  37. package/dist/types/animationSpeed.d.ts +19 -0
  38. package/dist/types/createIcon.d.ts +6 -0
  39. package/dist/types/iconStyles.d.ts +6 -1
  40. package/dist/types/icons/brand.d.ts +0 -4
  41. package/dist/types/icons/food.d.ts +0 -3
  42. package/dist/types/icons/index.d.ts +3 -3
  43. package/dist/types/icons/omniverk.d.ts +0 -3
  44. package/dist/types/icons/science.d.ts +1 -1
  45. package/dist/types/smilAnimations.d.ts +4 -2
  46. package/dist/types/types.d.ts +7 -0
  47. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @nice2dev/icons — Changelog
2
2
 
3
+ ## 1.3.17
4
+
5
+ ### Patch Changes
6
+
7
+ - 59a1a84: Icons, showcase feedback round 41:
8
+
9
+ - **Removed** (breaking): NtdGym (use NtdDumbbell), NtdPizzaFood (NtdPizza), NtdDelivery (NtdTruck),
10
+ NtdOmniVerkBadge, NtdOmniVerkLogo, NtdOmniVerkSpinner (`<NtdOmniVerk animation="spin" />` or NiceSpinner) and
11
+ NtdOmniVerkWatermark (NiceLogo).
12
+ - **`animationSpeed`** on every icon, the style decorators and SmilAnimationWrapper — and every animation now runs
13
+ at half its earlier pace by default: CSS animations, `smilAnimation`, gradient animations and the icons' own
14
+ (NtdOmniVerk, NtdOmniVerkAnimated). `animationSpeed={2}` is the old pace; an explicit duration keeps its length.
15
+ createIcon's new `animated` option scales an icon's own SVG animation times.
16
+ - **Redrawn**: NtdNuke, NtdRunning, NtdDumbbell, NtdBeer, NtdCrown, NtdTarget, NtdMolecule, NtdPlate, NtdFood,
17
+ NtdCoffeeFood, NtdTruck, NtdRefresh, NtdLayers, NtdTrash, NtdCoins; NtdPlanet's ring is primary with a thin
18
+ accent rim.
19
+
3
20
  ## 1.3.16
4
21
 
5
22
  ### Patch Changes
package/README.md CHANGED
@@ -524,7 +524,7 @@ Properties passed to every path renderer (pre-resolved from user props):
524
524
 
525
525
  ### Brand & Logo (14 icons)
526
526
 
527
- `NtdNiceToDev` · `NtdNiceMonogram` · `NtdNiceOrbit` · `NtdNiceSpark` · `NtdNiceShield` · `NtdNiceBadge` · `NtdNiceCore` · `NtdNiceCrest` · `NtdNiceHelix` · `NtdNicePortal` · `NtdNicePulseMark` · `NtdNiceFlagship` · `NtdOmniVerk` · `NtdOmniVerkLogo`
527
+ `NtdNiceToDev` · `NtdNiceMonogram` · `NtdNiceOrbit` · `NtdNiceSpark` · `NtdNiceShield` · `NtdNiceBadge` · `NtdNiceCore` · `NtdNiceCrest` · `NtdNiceHelix` · `NtdNicePortal` · `NtdNicePulseMark` · `NtdNiceFlagship` · `NtdOmniVerk` · `NtdOmniVerkAnimated`
528
528
 
529
529
  ### Brand Studio (25 icons)
530
530
 
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const React = require("react");
4
+ const ANIMATION_SLOWDOWN = 2;
5
+ function animationScale(speed) {
6
+ const s = typeof speed === "number" && speed > 0 && Number.isFinite(speed) ? speed : 1;
7
+ return ANIMATION_SLOWDOWN / s;
8
+ }
9
+ function durationScale(durationGiven, speed) {
10
+ return durationGiven ? animationScale(speed) / ANIMATION_SLOWDOWN : animationScale(speed);
11
+ }
12
+ const SMIL_ELEMENTS = /* @__PURE__ */ new Set([
13
+ "animate",
14
+ "animateTransform",
15
+ "animateMotion",
16
+ "animateColor",
17
+ "set"
18
+ ]);
19
+ const TIME_PROPS = ["dur", "begin", "end"];
20
+ const CLOCK = /^(\d*\.?\d+)(ms|s|min|h)?$/;
21
+ function scaleTime(value, scale) {
22
+ if (typeof value === "number") {
23
+ return Number((value * scale).toFixed(4));
24
+ }
25
+ return value.split(";").map((part) => {
26
+ const m = CLOCK.exec(part.trim());
27
+ if (!m) {
28
+ return part;
29
+ }
30
+ return `${Number((Number(m[1]) * scale).toFixed(4))}${m[2] ?? "s"}`;
31
+ }).join(";");
32
+ }
33
+ function retimeTree(node, scale) {
34
+ if (scale === 1) {
35
+ return node;
36
+ }
37
+ const walk = (n) => {
38
+ if (Array.isArray(n)) {
39
+ return n.map(walk);
40
+ }
41
+ if (!React.isValidElement(n)) {
42
+ return n;
43
+ }
44
+ const props = n.props;
45
+ const isHost = typeof n.type === "string";
46
+ const isFragment = n.type === React.Fragment;
47
+ if (!isHost && !isFragment) {
48
+ return n;
49
+ }
50
+ const next = {};
51
+ if (isHost && SMIL_ELEMENTS.has(n.type)) {
52
+ for (const key of TIME_PROPS) {
53
+ const v = props[key];
54
+ if (typeof v === "string" || typeof v === "number") {
55
+ next[key] = scaleTime(v, scale);
56
+ }
57
+ }
58
+ }
59
+ if (props.children !== void 0) {
60
+ next.children = React.Children.map(props.children, walk);
61
+ }
62
+ return Object.keys(next).length > 0 ? React.cloneElement(n, next) : n;
63
+ };
64
+ return walk(node);
65
+ }
66
+ exports.ANIMATION_SLOWDOWN = ANIMATION_SLOWDOWN;
67
+ exports.animationScale = animationScale;
68
+ exports.durationScale = durationScale;
69
+ exports.retimeTree = retimeTree;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
+ const animationSpeed = require("./animationSpeed.js");
5
6
  const sharpen = require("./sharpen.js");
6
7
  const smilAnimations = require("./smilAnimations.js");
7
8
  const stacking = require("./stacking.js");
@@ -26,11 +27,12 @@ function useColorScheme() {
26
27
  return React.useSyncExternalStore(subscribeColorScheme, getColorScheme, () => "light");
27
28
  }
28
29
  const BOX_CENTER = [12, 12];
29
- function renderGradientDef(id, preset, type, angle, animation) {
30
+ function renderGradientDef(id, preset, type, angle, animation, timeScale = 1) {
30
31
  const stops = types.GRADIENT_PRESETS[preset];
31
32
  if (!stops) {
32
33
  return null;
33
34
  }
35
+ const loop = `${Number((3 * timeScale).toFixed(4))}s`;
34
36
  const stopEls = stops.map((color, i) => {
35
37
  const offset = `${Math.round(i / (stops.length - 1) * 100)}%`;
36
38
  const nextColor = stops[(i + 1) % stops.length];
@@ -40,7 +42,7 @@ function renderGradientDef(id, preset, type, angle, animation) {
40
42
  {
41
43
  attributeName: "stop-color",
42
44
  values: `${color};${nextColor};${color}`,
43
- dur: "3s",
45
+ dur: loop,
44
46
  repeatCount: "indefinite"
45
47
  }
46
48
  ) }, i);
@@ -60,7 +62,7 @@ function renderGradientDef(id, preset, type, angle, animation) {
60
62
  type: "rotate",
61
63
  from: "0 12 12",
62
64
  to: "360 12 12",
63
- dur: "3s",
65
+ dur: loop,
64
66
  repeatCount: "indefinite"
65
67
  },
66
68
  "spin"
@@ -74,7 +76,7 @@ function renderGradientDef(id, preset, type, angle, animation) {
74
76
  {
75
77
  attributeName: "x1",
76
78
  values: "-24;24;-24",
77
- dur: "3s",
79
+ dur: loop,
78
80
  repeatCount: "indefinite"
79
81
  },
80
82
  "shift-x1"
@@ -84,7 +86,7 @@ function renderGradientDef(id, preset, type, angle, animation) {
84
86
  {
85
87
  attributeName: "x2",
86
88
  values: "0;48;0",
87
- dur: "3s",
89
+ dur: loop,
88
90
  repeatCount: "indefinite"
89
91
  },
90
92
  "shift-x2"
@@ -167,7 +169,13 @@ function renderCutoutShape(shape, fill, maskId) {
167
169
  }
168
170
  }
169
171
  function createIcon(options) {
170
- const { displayName, viewBox = "0 0 24 24", paths, textCenter = BOX_CENTER } = options;
172
+ const {
173
+ displayName,
174
+ viewBox = "0 0 24 24",
175
+ paths,
176
+ textCenter = BOX_CENTER,
177
+ animated = false
178
+ } = options;
171
179
  const solidDuotone = (props) => paths.solid({ ...props, accentColor: props.secondaryColor, accentOpacity: 1 });
172
180
  const perfect = {
173
181
  x: options.perfectStackX ?? textCenter[0],
@@ -194,8 +202,9 @@ function createIcon(options) {
194
202
  strokeLinejoin: propLinejoin,
195
203
  animation,
196
204
  animationDuration,
205
+ animationSpeed: animationSpeed$1,
197
206
  smilAnimation,
198
- smilDuration = 1,
207
+ smilDuration,
199
208
  smilRepeatCount = "indefinite",
200
209
  smilEasing = "ease-in-out",
201
210
  smilDelay = 0,
@@ -271,9 +280,12 @@ function createIcon(options) {
271
280
  }
272
281
  const transformString = transforms.length > 0 ? transforms.join(" ") : void 0;
273
282
  const transitionValue = transition === true ? "transform 0.3s ease" : typeof transition === "string" ? `transform ${transition}` : void 0;
283
+ const timeScale = animationSpeed.animationScale(animationSpeed$1);
274
284
  const animStyle = {
275
285
  // the variable carries the duration to the parts an icon animates inside itself
276
286
  ...animationDuration ? { animationDuration, "--ntd-anim-duration": animationDuration } : {},
287
+ // animations.css multiplies its times by it (default 2 there, the slowdown)
288
+ ...animationSpeed$1 !== void 0 ? { "--ntd-anim-scale": String(timeScale) } : {},
277
289
  ...transformString ? { transform: transformString } : {},
278
290
  ...transformString ? { transformOrigin } : {},
279
291
  ...transitionValue ? { transition: transitionValue } : {},
@@ -282,7 +294,8 @@ function createIcon(options) {
282
294
  const smilAnimationElements = smilAnimation ? smilAnimations.generateSmilAnimation(
283
295
  {
284
296
  type: smilAnimation,
285
- duration: smilDuration,
297
+ // 1 s before 1.3.17 by default; a given smilDuration keeps its length
298
+ duration: (smilDuration ?? 1) * animationSpeed.durationScale(smilDuration !== void 0, animationSpeed$1),
286
299
  repeatCount: smilRepeatCount,
287
300
  easing: smilEasing,
288
301
  delay: smilDelay
@@ -291,6 +304,7 @@ function createIcon(options) {
291
304
  ) : null;
292
305
  const needsSmilScaleWrapper = smilAnimation && ["heartbeat", "scale-pulse", "grow", "shrink", "rubber", "pop"].includes(smilAnimation);
293
306
  const rendered = isCutout ? renderCutoutShape(cutoutShape, gradient ? effectivePrimary : resolvedSecondary, maskId) : variant === "sharp" ? sharpen.sharpenTree(renderer(renderProps)) : variant === "rounded" ? sharpen.roundTree(renderer(renderProps)) : variant === "wireframe" ? sharpen.wireTree(renderer(renderProps), effectivePrimary) : renderer(renderProps);
307
+ const paced = animated ? animationSpeed.retimeTree(rendered, timeScale) : rendered;
294
308
  const stacked = stacking.renderStackChildren(children, {
295
309
  variant,
296
310
  primaryColor: effectivePrimary,
@@ -302,9 +316,9 @@ function createIcon(options) {
302
316
  textSize
303
317
  });
304
318
  const drawn = stacked ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
305
- rendered,
319
+ paced,
306
320
  stacked
307
- ] }) : rendered;
321
+ ] }) : paced;
308
322
  const iconContent = variant === "mini" ? /* @__PURE__ */ jsxRuntime.jsx(
309
323
  "g",
310
324
  {
@@ -331,20 +345,30 @@ function createIcon(options) {
331
345
  ...rest,
332
346
  children: [
333
347
  title && /* @__PURE__ */ jsxRuntime.jsx("title", { children: title }),
334
- gradient && /* @__PURE__ */ jsxRuntime.jsx("defs", { children: renderGradientDef(gradId, gradient, gradientType, gradientAngle, gradientAnimation) }),
348
+ gradient && /* @__PURE__ */ jsxRuntime.jsx("defs", { children: renderGradientDef(
349
+ gradId,
350
+ gradient,
351
+ gradientType,
352
+ gradientAngle,
353
+ gradientAnimation,
354
+ timeScale
355
+ ) }),
335
356
  is3d && /* @__PURE__ */ jsxRuntime.jsx("defs", { children: render3dFilterDef(filterId) }),
336
357
  isCutout && /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("mask", { id: maskId, children: [
337
358
  /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "0", y: "0", width: "24", height: "24", fill: "white" }),
338
- /* @__PURE__ */ jsxRuntime.jsx("g", { transform: "translate(12,12) scale(0.8) translate(-12,-12)", children: paths.solid({
339
- ...renderProps,
340
- primaryColor: "black",
341
- secondaryColor: "black",
342
- accentColor: "white",
343
- primaryOpacity: 1,
344
- secondaryOpacity: 1,
345
- accentOpacity: 1,
346
- uid: `${uid}m`
347
- }) })
359
+ /* @__PURE__ */ jsxRuntime.jsx("g", { transform: "translate(12,12) scale(0.8) translate(-12,-12)", children: (() => {
360
+ const mask = paths.solid({
361
+ ...renderProps,
362
+ primaryColor: "black",
363
+ secondaryColor: "black",
364
+ accentColor: "white",
365
+ primaryOpacity: 1,
366
+ secondaryOpacity: 1,
367
+ accentOpacity: 1,
368
+ uid: `${uid}m`
369
+ });
370
+ return animated ? animationSpeed.retimeTree(mask, timeScale) : mask;
371
+ })() })
348
372
  ] }) }),
349
373
  smilAnimation ? needsSmilScaleWrapper ? /* @__PURE__ */ jsxRuntime.jsxs(
350
374
  "g",