Skip to content

Commit 1355cf4

Browse files
committed
v0.1.2
1 parent 2d22cc1 commit 1355cf4

File tree

1,646 files changed

+234
-667
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,646 files changed

+234
-667
lines changed

icon-sprite/README.md

Lines changed: 199 additions & 0 deletions
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "@react-zero-ui/svg-sprite",
2+
"name": "@react-zero-ui/icon-sprite",
33
"description": "Lucide-React DX + zero-runtime SVG sprite for Next/Vite/ frontends",
4-
"version": "0.1.1",
4+
"version": "0.1.2",
55
"type": "module",
66
"main": "dist/index.js",
77
"module": "dist/index.js",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ function toKebab(s) {
2424
const needed = new Set(ICONS.map(toKebab));
2525
const store = svgstore({
2626
copyAttrs: ["viewBox", "fill", "stroke", "stroke-width", "stroke-linecap", "stroke-linejoin", "style", "size"],
27+
svgAttrs: {
28+
xmlns: "http://www.w3.org/2000/svg",
29+
"xmlns:xlink": "http://www.w3.org/1999/xlink",
30+
},
2731
});
2832
const found = new Set();
2933

@@ -44,6 +48,8 @@ if (fs.existsSync(customDir)) {
4448
const id = file.slice(0, -4); // "my-icon"
4549
const svg = fs.readFileSync(path.join(customDir, file), "utf8");
4650
store.add(id, svg); // <symbol id="my-icon">…
51+
// Mark custom icons as found so they don't appear as missing
52+
found.add(id);
4753
console.log(`🔧 Added custom icon: ${id}`);
4854
}
4955
}
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import { fileURLToPath } from "url";
55
import * as babel from "@babel/core";
66
import traverseImport from "@babel/traverse";
77
import * as t from "@babel/types";
8-
import { IMPORT_NAME, ROOT_DIR } from "../dist/config.js";
8+
import { IMPORT_NAME, ROOT_DIR, IGNORE_ICONS } from "../dist/config.js";
99

1010
// ESM __dirname shim
1111
const __dirname = path.dirname(fileURLToPath(import.meta.url));
1212
const ICONS = new Set();
1313

14-
// 1️⃣ Find the consuming apps root
15-
function findProjectRoot(dir = process.cwd()) {
14+
// 1️⃣ Find the consuming app's root
15+
export function findProjectRoot(dir = process.cwd()) {
1616
let current = dir;
1717
while (true) {
1818
if (fs.existsSync(path.join(current, "package.json"))) return current;
@@ -59,7 +59,8 @@ function collect(dir) {
5959
if (imported === "Icon") {
6060
// generic Component: track for JSX
6161
iconLocalNames.add(local);
62-
} else {
62+
// ignore CustomIcon imports
63+
} else if (!IGNORE_ICONS.includes(imported)) {
6364
// named icon import
6465
ICONS.add(imported);
6566
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import path from "path";
44
import { pathToFileURL } from "url";
55

66
const DEFAULT_CONFIG = {
7-
IMPORT_NAME: "@react-zero-ui/svg-sprite",
7+
IMPORT_NAME: "@react-zero-ui/icon-sprite",
88
SPRITE_PATH: "/icons.svg",
9-
ROOT_DIR: "app",
10-
CUSTOM_SVG_DIR: "custom-icons",
9+
ROOT_DIR: "",
10+
CUSTOM_SVG_DIR: "zero-ui-icons",
1111
OUTPUT_DIR: "public",
12+
IGNORE_ICONS: ["CustomIcon"],
1213
};
1314

1415
let userConfig = {};
@@ -31,3 +32,4 @@ export const SPRITE_PATH = merged.SPRITE_PATH;
3132
export const ROOT_DIR = merged.ROOT_DIR;
3233
export const CUSTOM_SVG_DIR = merged.CUSTOM_SVG_DIR;
3334
export const OUTPUT_DIR = merged.OUTPUT_DIR;
35+
export const IGNORE_ICONS = merged.IGNORE_ICONS;

0 commit comments

Comments
 (0)