@cantileva/icons 0.1.0 → 0.1.1

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 (3) hide show
  1. package/README.md +9 -0
  2. package/package.json +1 -1
  3. package/sync.js +8 -2
package/README.md CHANGED
@@ -53,6 +53,15 @@ fetch, key never ships to the browser).
53
53
 
54
54
  This is the same shape as `prisma generate`: a local codegen step, scoped to you.
55
55
 
56
+ ## Uninstall
57
+
58
+ ```bash
59
+ npm uninstall @cantileva/icons
60
+ ```
61
+
62
+ That's all — the synced components live inside the package, so removing it leaves
63
+ nothing behind in your project.
64
+
56
65
  ## Notes
57
66
 
58
67
  - **No key yet?** Install still succeeds; the sync just skips. Set the key and run
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cantileva/icons",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Your Cantileva icon library, as React components.",
5
5
  "type": "module",
6
6
  "bin": {
package/sync.js CHANGED
@@ -26,15 +26,21 @@ const animName = (slug) => pascal(slug) + "Animated";
26
26
  const viewBoxOf = (svg) => (svg.match(/viewBox="([^"]+)"/) || [, "0 0 1024 1024"])[1];
27
27
  const innerOf = (svg) => svg.replace(/^[\s\S]*?<svg[^>]*>/, "").replace(/<\/svg>\s*$/, "").trim();
28
28
  const fillHost = (svg) => svg.replace(/\swidth="[^"]*"/, ' width="100%"').replace(/\sheight="[^"]*"/, ' height="100%"');
29
+ // Shrink path markup: drop whitespace between tags and round coordinates to 1
30
+ // decimal (sub-pixel on a 1024 grid, visually identical) — typically 10-20% off.
31
+ const minify = (s) => s
32
+ .replace(/>\s+</g, "><")
33
+ .replace(/\s{2,}/g, " ")
34
+ .replace(/-?\d+\.\d+/g, (m) => String(Math.round(parseFloat(m) * 10) / 10));
29
35
 
30
36
  const iconModule = (svg) => `import { createElement as h } from "react";
31
- const __html = ${JSON.stringify(innerOf(svg))};
37
+ const __html = ${JSON.stringify(minify(innerOf(svg)))};
32
38
  export default function Icon(props) {
33
39
  return h("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: ${JSON.stringify(viewBoxOf(svg))}, width: "1em", height: "1em", fill: "currentColor", dangerouslySetInnerHTML: { __html } }, props));
34
40
  }
35
41
  `;
36
42
  const animModule = (frames, fps) => `import { createElement as h, useState, useEffect } from "react";
37
- const FRAMES = ${JSON.stringify(frames.map(fillHost))};
43
+ const FRAMES = ${JSON.stringify(frames.map((f) => minify(fillHost(f))))};
38
44
  export default function Animated({ fps = ${fps}, ...props }) {
39
45
  const [i, setI] = useState(0);
40
46
  useEffect(() => {