@stacksjs/iconify-generator 0.2.198 → 0.2.200
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/cli.js +101 -355
- package/dist/cli.js.map +3 -3
- package/dist/index.js +96 -309
- package/dist/index.js.map +3 -3
- package/package.json +2 -2
- package/src/index.ts +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,72 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
// src/index.ts
|
|
6
|
-
import { mkdir, writeFile } from "fs/promises";
|
|
7
|
-
import { join } from "path";
|
|
8
|
-
var ICONIFY_API = "https://api.iconify.design";
|
|
9
|
-
async function fetchCollections() {
|
|
10
|
-
const response = await fetch(`${ICONIFY_API}/collections`);
|
|
11
|
-
if (!response.ok) {
|
|
12
|
-
throw new Error(`Failed to fetch collections: ${response.statusText}`);
|
|
13
|
-
}
|
|
14
|
-
return await response.json();
|
|
15
|
-
}
|
|
16
|
-
async function fetchCollectionIcons(prefix, icons) {
|
|
17
|
-
try {
|
|
18
|
-
const iconifyJsonPath = __require.resolve("/home/runner/work/stx/stx/node_modules/@iconify/json/dist/index.cjs");
|
|
19
|
-
const basePath = `${iconifyJsonPath.substring(0, iconifyJsonPath.lastIndexOf("/node_modules/@iconify/json/"))}/node_modules/@iconify/json`;
|
|
20
|
-
const jsonPath = `${basePath}/json/${prefix}.json`;
|
|
21
|
-
const file = Bun.file(jsonPath);
|
|
22
|
-
if (await file.exists()) {
|
|
23
|
-
const data = await file.json();
|
|
24
|
-
if (icons && icons.length > 0) {
|
|
25
|
-
const filteredIcons = {};
|
|
26
|
-
for (const iconName of icons) {
|
|
27
|
-
if (data.icons[iconName]) {
|
|
28
|
-
filteredIcons[iconName] = data.icons[iconName];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
...data,
|
|
33
|
-
icons: filteredIcons
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return data;
|
|
37
|
-
}
|
|
38
|
-
} catch {}
|
|
39
|
-
const url = icons && icons.length > 0 ? `${ICONIFY_API}/${prefix}.json?icons=${icons.join(",")}` : `${ICONIFY_API}/${prefix}.json`;
|
|
40
|
-
const response = await fetch(url);
|
|
41
|
-
if (!response.ok) {
|
|
42
|
-
throw new Error(`Failed to fetch icons for ${prefix}: ${response.statusText}`);
|
|
43
|
-
}
|
|
44
|
-
return await response.json();
|
|
45
|
-
}
|
|
46
|
-
function convertIconData(data, defaultWidth = 24, defaultHeight = 24) {
|
|
47
|
-
return {
|
|
48
|
-
body: data.body,
|
|
49
|
-
width: data.width || defaultWidth,
|
|
50
|
-
height: data.height || defaultHeight,
|
|
51
|
-
viewBox: `0 0 ${data.width || defaultWidth} ${data.height || defaultHeight}`
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function generateIconData(name, iconData) {
|
|
55
|
-
const camelCaseName = toCamelCase(name);
|
|
56
|
-
return `import type { IconData } from '@stacksjs/iconify-core'
|
|
3
|
+
var X=import.meta.require;import{mkdir as Z,writeFile as z}from"fs/promises";import{join as S}from"path";var Q="https://api.iconify.design";async function R(){let y=await fetch(`${Q}/collections`);if(!y.ok)throw Error(`Failed to fetch collections: ${y.statusText}`);return await y.json()}async function P(y,g){try{let E=X.resolve("/home/runner/work/stx/stx/node_modules/@iconify/json/dist/index.cjs"),h=`${`${E.substring(0,E.lastIndexOf("/node_modules/@iconify/json/"))}/node_modules/@iconify/json`}/json/${y}.json`,G=Bun.file(h);if(await G.exists()){let k=await G.json();if(g&&g.length>0){let T={};for(let M of g)if(k.icons[M])T[M]=k.icons[M];return{...k,icons:T}}return k}}catch{}let u=g&&g.length>0?`${Q}/${y}.json?icons=${g.join(",")}`:`${Q}/${y}.json`,$=await fetch(u);if(!$.ok)throw Error(`Failed to fetch icons for ${y}: ${$.statusText}`);return await $.json()}function j(y,g=24,u=24){return{body:y.body,width:y.width||g,height:y.height||u,viewBox:`0 0 ${y.width||g} ${y.height||u}`}}function F(y,g){let u=K(y);return`import type { IconData } from '@stacksjs/iconify-core'
|
|
57
4
|
|
|
58
|
-
export const ${
|
|
5
|
+
export const ${u}: IconData = ${JSON.stringify(g,null,2)}
|
|
59
6
|
|
|
60
|
-
export default ${
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
function generateIconComponent(_name, iconData) {
|
|
64
|
-
return `<script>
|
|
7
|
+
export default ${u}
|
|
8
|
+
`}function s(y,g){return`<script>
|
|
65
9
|
// Get props with defaults (handle undefined)
|
|
66
|
-
const iconWidth = (typeof width !== 'undefined' ? width : null) || (typeof size !== 'undefined' ? size : null) || ${
|
|
67
|
-
const iconHeight = (typeof height !== 'undefined' ? height : null) || (typeof size !== 'undefined' ? size : null) || ${
|
|
10
|
+
const iconWidth = (typeof width !== 'undefined' ? width : null) || (typeof size !== 'undefined' ? size : null) || ${g.width||24}
|
|
11
|
+
const iconHeight = (typeof height !== 'undefined' ? height : null) || (typeof size !== 'undefined' ? size : null) || ${g.height||24}
|
|
68
12
|
const iconColor = typeof color !== 'undefined' ? color : 'currentColor'
|
|
69
|
-
const viewBox = "${
|
|
13
|
+
const viewBox = "${g.viewBox||`0 0 ${g.width||24} ${g.height||24}`}"
|
|
70
14
|
|
|
71
15
|
// Build transform
|
|
72
16
|
const transforms = []
|
|
@@ -90,7 +34,7 @@ const styleAttr = styles.length > 0 ? \` style="\${styles.join(' ')}"\` : ''
|
|
|
90
34
|
const classAttr = typeof className !== 'undefined' && className ? \` class="\${className}"\` : ''
|
|
91
35
|
|
|
92
36
|
// Icon body
|
|
93
|
-
let body = ${JSON.stringify(
|
|
37
|
+
let body = ${JSON.stringify(g.body)}
|
|
94
38
|
if (iconColor && iconColor !== 'currentColor') {
|
|
95
39
|
body = body.replace(/currentColor/g, iconColor)
|
|
96
40
|
}
|
|
@@ -100,89 +44,17 @@ const svg = \`<svg xmlns="http://www.w3.org/2000/svg" width="\${iconWidth}" heig
|
|
|
100
44
|
</script>
|
|
101
45
|
|
|
102
46
|
{!! svg !!}
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const used = new Set;
|
|
107
|
-
const dataExports = iconNames.map((name) => {
|
|
108
|
-
const primary = toCamelCase(name);
|
|
109
|
-
let id = primary;
|
|
110
|
-
if (used.has(id)) {
|
|
111
|
-
let candidate = name.replace(/[^a-zA-Z0-9]/g, "_");
|
|
112
|
-
if (/^[0-9]/.test(candidate))
|
|
113
|
-
candidate = `_${candidate}`;
|
|
114
|
-
id = candidate;
|
|
115
|
-
let n = 2;
|
|
116
|
-
while (used.has(id)) {
|
|
117
|
-
id = `${candidate}_${n}`;
|
|
118
|
-
n++;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
used.add(id);
|
|
122
|
-
return `export { default as ${id} } from './${name}.js'`;
|
|
123
|
-
}).join(`
|
|
124
|
-
`);
|
|
125
|
-
return `// Icon data exports
|
|
126
|
-
${dataExports}
|
|
47
|
+
`}function N(y){let g=new Set;return`// Icon data exports
|
|
48
|
+
${y.map(($)=>{let b=K($);if(g.has(b)){let h=$.replace(/[^a-zA-Z0-9]/g,"_");if(/^[0-9]/.test(h))h=`_${h}`;b=h;let G=2;while(g.has(b))b=`${h}_${G}`,G++}return g.add(b),`export { default as ${b} } from './${$}.js'`}).join(`
|
|
49
|
+
`)}
|
|
127
50
|
|
|
128
51
|
export * from './types.js'
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
function generateTypesFile(prefix) {
|
|
132
|
-
return `import type { IconData, IconProps } from '@stacksjs/iconify-core'
|
|
52
|
+
`}function d(y){return`import type { IconData, IconProps } from '@stacksjs/iconify-core'
|
|
133
53
|
|
|
134
54
|
export type { IconData, IconProps }
|
|
135
55
|
|
|
136
|
-
export type ${
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
function generatePackageJson(prefix, collectionInfo, _iconCount) {
|
|
140
|
-
const packageJson = {
|
|
141
|
-
name: `@stacksjs/iconify-${prefix}`,
|
|
142
|
-
type: "module",
|
|
143
|
-
version: "0.0.1",
|
|
144
|
-
description: `${collectionInfo.name} icons for stx from Iconify`,
|
|
145
|
-
author: collectionInfo.author?.name || "Iconify",
|
|
146
|
-
license: collectionInfo.license?.spdx || "MIT",
|
|
147
|
-
repository: {
|
|
148
|
-
type: "git",
|
|
149
|
-
url: "https://github.com/stacksjs/stx.git",
|
|
150
|
-
directory: `packages/iconify-${prefix}`
|
|
151
|
-
},
|
|
152
|
-
keywords: [
|
|
153
|
-
"iconify",
|
|
154
|
-
"icons",
|
|
155
|
-
"svg",
|
|
156
|
-
prefix,
|
|
157
|
-
collectionInfo.name,
|
|
158
|
-
"stx"
|
|
159
|
-
],
|
|
160
|
-
sideEffects: false,
|
|
161
|
-
exports: {
|
|
162
|
-
".": {
|
|
163
|
-
types: "./dist/index.d.ts",
|
|
164
|
-
import: "./dist/index.js"
|
|
165
|
-
},
|
|
166
|
-
"./*": "./dist/*"
|
|
167
|
-
},
|
|
168
|
-
main: "./dist/index.js",
|
|
169
|
-
module: "./dist/index.js",
|
|
170
|
-
types: "./dist/index.d.ts",
|
|
171
|
-
files: [
|
|
172
|
-
"dist"
|
|
173
|
-
],
|
|
174
|
-
scripts: {
|
|
175
|
-
build: "bun build.ts",
|
|
176
|
-
prepublishOnly: "bun build.ts"
|
|
177
|
-
},
|
|
178
|
-
dependencies: {
|
|
179
|
-
"@stacksjs/iconify-core": "workspace:*"
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
return JSON.stringify(packageJson, null, 2);
|
|
183
|
-
}
|
|
184
|
-
function generateBuildFile(prefix) {
|
|
185
|
-
return `import { existsSync, readdirSync, statSync } from 'node:fs'
|
|
56
|
+
export type ${I(y)}Icon = IconData
|
|
57
|
+
`}function D(y,g,u){let $={name:`@stacksjs/iconify-${y}`,type:"module",version:"0.0.1",description:`${g.name} icons for stx from Iconify`,author:g.author?.name||"Iconify",license:g.license?.spdx||"MIT",repository:{type:"git",url:"https://github.com/stacksjs/stx.git",directory:`packages/iconify-${y}`},keywords:["iconify","icons","svg",y,g.name,"stx"],sideEffects:!1,exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./*":"./dist/*"},main:"./dist/index.js",module:"./dist/index.js",types:"./dist/index.d.ts",files:["dist"],scripts:{build:"bun build.ts",prepublishOnly:"bun build.ts"},dependencies:{"@stacksjs/iconify-core":"workspace:*"}};return JSON.stringify($,null,2)}function r(y){return`import { existsSync, readdirSync, statSync } from 'node:fs'
|
|
186
58
|
import { dirname, join } from 'node:path'
|
|
187
59
|
import { fileURLToPath } from 'node:url'
|
|
188
60
|
import dts from 'bun-plugin-dtsx'
|
|
@@ -217,7 +89,7 @@ function isDistFresh() {
|
|
|
217
89
|
}
|
|
218
90
|
|
|
219
91
|
if (isDistFresh()) {
|
|
220
|
-
console.log('\u2713 @stacksjs/iconify-${
|
|
92
|
+
console.log('\u2713 @stacksjs/iconify-${y} dist is fresh, skipping rebuild')
|
|
221
93
|
} else {
|
|
222
94
|
await Bun.build({
|
|
223
95
|
entrypoints: [join(srcDir, 'index.ts')],
|
|
@@ -225,23 +97,20 @@ if (isDistFresh()) {
|
|
|
225
97
|
target: 'bun',
|
|
226
98
|
format: 'esm',
|
|
227
99
|
plugins: [dts()],
|
|
228
|
-
minify:
|
|
100
|
+
minify: true,
|
|
229
101
|
sourcemap: 'external',
|
|
230
102
|
splitting: true,
|
|
231
103
|
})
|
|
232
|
-
console.log('\u2713 Built @stacksjs/iconify-${
|
|
104
|
+
console.log('\u2713 Built @stacksjs/iconify-${y}')
|
|
233
105
|
}
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
function generateReadme(prefix, collectionInfo, iconCount) {
|
|
237
|
-
return `# @stacksjs/iconify-${prefix}
|
|
106
|
+
`}function C(y,g,u){return`# @stacksjs/iconify-${y}
|
|
238
107
|
|
|
239
|
-
${
|
|
108
|
+
${g.name} icons for stx from Iconify.
|
|
240
109
|
|
|
241
110
|
## Installation
|
|
242
111
|
|
|
243
112
|
\`\`\`bash
|
|
244
|
-
bun add @stacksjs/iconify-${
|
|
113
|
+
bun add @stacksjs/iconify-${y}
|
|
245
114
|
\`\`\`
|
|
246
115
|
|
|
247
116
|
## Usage
|
|
@@ -250,7 +119,7 @@ bun add @stacksjs/iconify-${prefix}
|
|
|
250
119
|
|
|
251
120
|
\`\`\`html
|
|
252
121
|
<script>
|
|
253
|
-
import { home } from '@stacksjs/iconify-${
|
|
122
|
+
import { home } from '@stacksjs/iconify-${y}'
|
|
254
123
|
import { renderIcon } from '@stacksjs/iconify-core'
|
|
255
124
|
|
|
256
125
|
export const homeIcon = renderIcon(home, { size: 24, color: 'currentColor' })
|
|
@@ -264,7 +133,7 @@ bun add @stacksjs/iconify-${prefix}
|
|
|
264
133
|
### In TypeScript/JavaScript
|
|
265
134
|
|
|
266
135
|
\`\`\`typescript
|
|
267
|
-
import { home, account, settings } from '@stacksjs/iconify-${
|
|
136
|
+
import { home, account, settings } from '@stacksjs/iconify-${y}'
|
|
268
137
|
import { renderIcon } from '@stacksjs/iconify-core'
|
|
269
138
|
|
|
270
139
|
const svg = renderIcon(home, {
|
|
@@ -275,48 +144,38 @@ const svg = renderIcon(home, {
|
|
|
275
144
|
|
|
276
145
|
## Available Icons
|
|
277
146
|
|
|
278
|
-
This package contains ${
|
|
147
|
+
This package contains ${u} icons from ${g.name}.
|
|
279
148
|
|
|
280
149
|
## License
|
|
281
150
|
|
|
282
|
-
${
|
|
151
|
+
${g.license?.title||"MIT"}
|
|
283
152
|
|
|
284
|
-
${
|
|
153
|
+
${g.license?.url?`License: ${g.license.url}`:""}
|
|
285
154
|
|
|
286
155
|
## Credits
|
|
287
156
|
|
|
288
|
-
- Icons: ${
|
|
157
|
+
- Icons: ${g.author?.name||"Iconify"}${g.author?.url?` (${g.author.url})`:""}
|
|
289
158
|
- Iconify: https://iconify.design/
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
const exampleIcons = iconNames.slice(0, 5).map(toCamelCase);
|
|
295
|
-
const exampleComponents = exampleIcons.map((name) => `${name.charAt(0).toUpperCase()}${name.slice(1)}Icon`);
|
|
296
|
-
const allIconsList = iconNames.map((name) => {
|
|
297
|
-
const camelName = toCamelCase(name);
|
|
298
|
-
return `- \`${camelName}\``;
|
|
299
|
-
}).join(`
|
|
300
|
-
`);
|
|
301
|
-
return `# ${collectionInfo.name}
|
|
302
|
-
|
|
303
|
-
> ${collectionInfo.name} icons for stx from Iconify
|
|
159
|
+
`}function x(y,g,u){let $=u.length,E=u.slice(0,5).map(K),b=E.map((G)=>`${G.charAt(0).toUpperCase()}${G.slice(1)}Icon`),h=u.map((G)=>{return`- \`${K(G)}\``}).join(`
|
|
160
|
+
`);return`# ${g.name}
|
|
161
|
+
|
|
162
|
+
> ${g.name} icons for stx from Iconify
|
|
304
163
|
|
|
305
164
|
## Overview
|
|
306
165
|
|
|
307
|
-
This package provides access to ${
|
|
166
|
+
This package provides access to ${$} icons from the ${g.name} collection through the stx iconify integration.
|
|
308
167
|
|
|
309
|
-
**Collection ID:** \`${
|
|
310
|
-
**Total Icons:** ${
|
|
311
|
-
${
|
|
312
|
-
${
|
|
313
|
-
${
|
|
314
|
-
${
|
|
168
|
+
**Collection ID:** \`${y}\`
|
|
169
|
+
**Total Icons:** ${$}
|
|
170
|
+
${g.author?.name?`**Author:** ${g.author.name}${g.author.url?` ([Website](${g.author.url}))`:""}`:""}
|
|
171
|
+
${g.license?.title?`**License:** ${g.license.title}${g.license.url?` ([Details](${g.license.url}))`:""}`:""}
|
|
172
|
+
${g.category?`**Category:** ${g.category}`:""}
|
|
173
|
+
${g.palette!==void 0?`**Palette:** ${g.palette?"Yes (color icons)":"No (monotone icons)"}`:""}
|
|
315
174
|
|
|
316
175
|
## Installation
|
|
317
176
|
|
|
318
177
|
\`\`\`bash
|
|
319
|
-
bun add @stacksjs/iconify-${
|
|
178
|
+
bun add @stacksjs/iconify-${y}
|
|
320
179
|
\`\`\`
|
|
321
180
|
|
|
322
181
|
## Quick Start
|
|
@@ -326,30 +185,30 @@ bun add @stacksjs/iconify-${prefix}
|
|
|
326
185
|
Icons are available as .stx components that can be used directly in templates:
|
|
327
186
|
|
|
328
187
|
\`\`\`html
|
|
329
|
-
<${
|
|
330
|
-
<${
|
|
331
|
-
<${
|
|
188
|
+
<${b[0]||"Icon"} height="1em" />
|
|
189
|
+
<${b[0]||"Icon"} width="1em" height="1em" />
|
|
190
|
+
<${b[0]||"Icon"} height="24" />
|
|
332
191
|
\`\`\`
|
|
333
192
|
|
|
334
193
|
### With Properties
|
|
335
194
|
|
|
336
195
|
\`\`\`html
|
|
337
196
|
<!-- Using size property -->
|
|
338
|
-
<${
|
|
339
|
-
<${
|
|
197
|
+
<${b[0]||"Icon"} size="24" />
|
|
198
|
+
<${b[0]||"Icon"} size="1em" />
|
|
340
199
|
|
|
341
200
|
<!-- Using width and height -->
|
|
342
|
-
<${
|
|
201
|
+
<${b[0]||"Icon"} width="24" height="32" />
|
|
343
202
|
|
|
344
203
|
<!-- With color -->
|
|
345
|
-
<${
|
|
346
|
-
<${
|
|
204
|
+
<${b[0]||"Icon"} size="24" color="red" />
|
|
205
|
+
<${b[0]||"Icon"} size="24" color="#4a90e2" />
|
|
347
206
|
|
|
348
207
|
<!-- With CSS class -->
|
|
349
|
-
<${
|
|
208
|
+
<${b[0]||"Icon"} size="24" class="icon-primary" />
|
|
350
209
|
|
|
351
210
|
<!-- With all properties -->
|
|
352
|
-
<${
|
|
211
|
+
<${b[0]||"Icon"}
|
|
353
212
|
size="32"
|
|
354
213
|
color="#4a90e2"
|
|
355
214
|
class="my-icon"
|
|
@@ -374,9 +233,9 @@ Icons are available as .stx components that can be used directly in templates:
|
|
|
374
233
|
</head>
|
|
375
234
|
<body>
|
|
376
235
|
<div class="icon-grid">
|
|
377
|
-
<${
|
|
378
|
-
<${
|
|
379
|
-
<${
|
|
236
|
+
<${b[0]||"Icon"} size="24" />
|
|
237
|
+
<${b[1]||"Icon"} size="24" color="#4a90e2" />
|
|
238
|
+
<${b[2]||"Icon"} size="32" class="my-icon" />
|
|
380
239
|
</div>
|
|
381
240
|
</body>
|
|
382
241
|
</html>
|
|
@@ -387,10 +246,10 @@ Icons are available as .stx components that can be used directly in templates:
|
|
|
387
246
|
You can also import icon data and use the \`renderIcon\` function directly:
|
|
388
247
|
|
|
389
248
|
\`\`\`typescript
|
|
390
|
-
import { ${
|
|
249
|
+
import { ${E.slice(0,3).join(", ")} } from '@stacksjs/iconify-${y}'
|
|
391
250
|
import { renderIcon } from '@stacksjs/iconify-core'
|
|
392
251
|
|
|
393
|
-
const svg = renderIcon(${
|
|
252
|
+
const svg = renderIcon(${E[0]||"icon"}, { size: 24 })
|
|
394
253
|
\`\`\`
|
|
395
254
|
|
|
396
255
|
## Icon Properties
|
|
@@ -411,23 +270,23 @@ All icon component functions and \`renderIcon\` accept the following properties:
|
|
|
411
270
|
|
|
412
271
|
## Color
|
|
413
272
|
|
|
414
|
-
${
|
|
273
|
+
${g.palette?`### Color Icons
|
|
415
274
|
|
|
416
|
-
This collection contains color icons. While you can still set a color property, it may override the original colors
|
|
275
|
+
This collection contains color icons. While you can still set a color property, it may override the original colors.`:"### Monotone Icons\n\nMonotone icons use `currentColor` by default, allowing you to change icon color via the `color` property or CSS:"}
|
|
417
276
|
|
|
418
277
|
\`\`\`html
|
|
419
278
|
<!-- Via color property -->
|
|
420
|
-
<${
|
|
421
|
-
<${
|
|
279
|
+
<${b[0]||"Icon"} size="24" color="red" />
|
|
280
|
+
<${b[0]||"Icon"} size="24" color="#4a90e2" />
|
|
422
281
|
|
|
423
282
|
<!-- Via inline style -->
|
|
424
|
-
<${
|
|
283
|
+
<${b[0]||"Icon"} size="24" style="color: green;" />
|
|
425
284
|
|
|
426
285
|
<!-- Via CSS class -->
|
|
427
|
-
<${
|
|
286
|
+
<${b[0]||"Icon"} size="24" class="text-primary" />
|
|
428
287
|
\`\`\`
|
|
429
288
|
|
|
430
|
-
${!
|
|
289
|
+
${!g.palette?`\`\`\`css
|
|
431
290
|
/* In your CSS */
|
|
432
291
|
.text-primary {
|
|
433
292
|
color: #4a90e2;
|
|
@@ -436,7 +295,7 @@ ${!collectionInfo.palette ? `\`\`\`css
|
|
|
436
295
|
.icon:hover {
|
|
437
296
|
color: #357abd;
|
|
438
297
|
}
|
|
439
|
-
|
|
298
|
+
\`\`\``:""}
|
|
440
299
|
|
|
441
300
|
## Size
|
|
442
301
|
|
|
@@ -463,16 +322,16 @@ You do not need to set both properties. If you set one property, the other prope
|
|
|
463
322
|
**Examples:**
|
|
464
323
|
|
|
465
324
|
\`\`\`html
|
|
466
|
-
<${
|
|
467
|
-
<${
|
|
468
|
-
<${
|
|
325
|
+
<${b[0]||"DraftsIcon"} height="1em" />
|
|
326
|
+
<${b[0]||"DraftsIcon"} width="1em" height="1em" />
|
|
327
|
+
<${b[0]||"DraftsIcon"} height="24" />
|
|
469
328
|
\`\`\`
|
|
470
329
|
|
|
471
330
|
You can also use the \`size\` property as a shorthand for setting both width and height:
|
|
472
331
|
|
|
473
332
|
\`\`\`html
|
|
474
|
-
<${
|
|
475
|
-
<${
|
|
333
|
+
<${b[0]||"DraftsIcon"} size="24" />
|
|
334
|
+
<${b[0]||"DraftsIcon"} size="1em" />
|
|
476
335
|
\`\`\`
|
|
477
336
|
|
|
478
337
|
### CSS Sizing
|
|
@@ -480,21 +339,21 @@ You can also use the \`size\` property as a shorthand for setting both width and
|
|
|
480
339
|
You can also control icon size via CSS:
|
|
481
340
|
|
|
482
341
|
\`\`\`css
|
|
483
|
-
.${
|
|
342
|
+
.${K(y)}-icon {
|
|
484
343
|
width: 1em;
|
|
485
344
|
height: 1em;
|
|
486
345
|
}
|
|
487
346
|
\`\`\`
|
|
488
347
|
|
|
489
348
|
\`\`\`html
|
|
490
|
-
<${
|
|
349
|
+
<${b[0]||"DraftsIcon"} class="${K(y)}-icon" />
|
|
491
350
|
\`\`\`
|
|
492
351
|
|
|
493
352
|
## Available Icons
|
|
494
353
|
|
|
495
|
-
This package contains **${
|
|
354
|
+
This package contains **${$}** icons:
|
|
496
355
|
|
|
497
|
-
${
|
|
356
|
+
${h}
|
|
498
357
|
|
|
499
358
|
## Usage Examples
|
|
500
359
|
|
|
@@ -502,10 +361,10 @@ ${allIconsList}
|
|
|
502
361
|
|
|
503
362
|
\`\`\`html
|
|
504
363
|
<nav>
|
|
505
|
-
<a href="/"><${
|
|
506
|
-
<a href="/about"><${
|
|
507
|
-
<a href="/contact"><${
|
|
508
|
-
<a href="/settings"><${
|
|
364
|
+
<a href="/"><${b[0]||"Icon"} size="20" class="nav-icon" /> Home</a>
|
|
365
|
+
<a href="/about"><${b[1]||"Icon"} size="20" class="nav-icon" /> About</a>
|
|
366
|
+
<a href="/contact"><${b[2]||"Icon"} size="20" class="nav-icon" /> Contact</a>
|
|
367
|
+
<a href="/settings"><${b[3]||"Icon"} size="20" class="nav-icon" /> Settings</a>
|
|
509
368
|
</nav>
|
|
510
369
|
|
|
511
370
|
<style>
|
|
@@ -527,7 +386,7 @@ ${allIconsList}
|
|
|
527
386
|
### Custom Styling
|
|
528
387
|
|
|
529
388
|
\`\`\`html
|
|
530
|
-
<${
|
|
389
|
+
<${b[0]||"Icon"}
|
|
531
390
|
size="24"
|
|
532
391
|
class="icon icon-primary"
|
|
533
392
|
style="opacity: 0.8; transition: opacity 0.2s;"
|
|
@@ -548,15 +407,15 @@ ${allIconsList}
|
|
|
548
407
|
\`\`\`html
|
|
549
408
|
<div class="status-grid">
|
|
550
409
|
<div class="status-item">
|
|
551
|
-
<${
|
|
410
|
+
<${b[0]||"Icon"} size="16" color="#22c55e" />
|
|
552
411
|
<span>Success</span>
|
|
553
412
|
</div>
|
|
554
413
|
<div class="status-item">
|
|
555
|
-
<${
|
|
414
|
+
<${b[1]||"Icon"} size="16" color="#f59e0b" />
|
|
556
415
|
<span>Warning</span>
|
|
557
416
|
</div>
|
|
558
417
|
<div class="status-item">
|
|
559
|
-
<${
|
|
418
|
+
<${b[2]||"Icon"} size="16" color="#ef4444" />
|
|
560
419
|
<span>Error</span>
|
|
561
420
|
</div>
|
|
562
421
|
</div>
|
|
@@ -567,8 +426,8 @@ ${allIconsList}
|
|
|
567
426
|
1. **Use Components Directly**: Import and use icon components in your templates
|
|
568
427
|
\`\`\`html
|
|
569
428
|
<!-- Recommended -->
|
|
570
|
-
<${
|
|
571
|
-
<${
|
|
429
|
+
<${b[0]||"Icon"} size="24" />
|
|
430
|
+
<${b[1]||"Icon"} size="24" color="#4a90e2" />
|
|
572
431
|
\`\`\`
|
|
573
432
|
|
|
574
433
|
2. **Use CSS for Theming**: Apply consistent styling through CSS classes
|
|
@@ -585,24 +444,24 @@ ${allIconsList}
|
|
|
585
444
|
\`\`\`
|
|
586
445
|
|
|
587
446
|
\`\`\`html
|
|
588
|
-
<${
|
|
447
|
+
<${b[0]||"Icon"} size="24" class="icon" />
|
|
589
448
|
\`\`\`
|
|
590
449
|
|
|
591
450
|
3. **Set Appropriate Sizes**: Use \`1em\` for inline icons, fixed pixel sizes for standalone icons
|
|
592
451
|
\`\`\`html
|
|
593
452
|
<!-- Inline with text -->
|
|
594
|
-
<p>Click the <${
|
|
453
|
+
<p>Click the <${b[0]||"Icon"} height="1em" /> icon to continue</p>
|
|
595
454
|
|
|
596
455
|
<!-- Standalone -->
|
|
597
|
-
<${
|
|
456
|
+
<${b[0]||"Icon"} size="24" />
|
|
598
457
|
\`\`\`
|
|
599
458
|
|
|
600
459
|
4. **Use Data Import for Advanced Use Cases**: When you need more control
|
|
601
460
|
\`\`\`html
|
|
602
461
|
@js
|
|
603
|
-
import { ${
|
|
462
|
+
import { ${E[0]||"icon"} } from '@stacksjs/iconify-${y}'
|
|
604
463
|
import { renderIcon } from '@stacksjs/iconify-core'
|
|
605
|
-
global.customIcon = renderIcon(${
|
|
464
|
+
global.customIcon = renderIcon(${E[0]||"icon"}, { size: 24 })
|
|
606
465
|
@endjs
|
|
607
466
|
|
|
608
467
|
{!! customIcon !!}
|
|
@@ -614,10 +473,10 @@ This package includes full TypeScript support with type definitions for all icon
|
|
|
614
473
|
|
|
615
474
|
\`\`\`typescript
|
|
616
475
|
import type { IconData } from '@stacksjs/iconify-core'
|
|
617
|
-
import { ${
|
|
476
|
+
import { ${E[0]||"icon"} } from '@stacksjs/iconify-${y}'
|
|
618
477
|
|
|
619
478
|
// Icons are typed as IconData
|
|
620
|
-
const myIcon: IconData = ${
|
|
479
|
+
const myIcon: IconData = ${E[0]||"icon"}
|
|
621
480
|
\`\`\`
|
|
622
481
|
|
|
623
482
|
## Related Packages
|
|
@@ -628,87 +487,23 @@ const myIcon: IconData = ${exampleIcons[0] || "icon"}
|
|
|
628
487
|
|
|
629
488
|
## License
|
|
630
489
|
|
|
631
|
-
${
|
|
490
|
+
${g.license?.title||"MIT"}
|
|
632
491
|
|
|
633
|
-
${
|
|
492
|
+
${g.license?.url?`See [license details](${g.license.url}) for more information.`:""}
|
|
634
493
|
|
|
635
494
|
## Credits
|
|
636
495
|
|
|
637
|
-
- **Icons**: ${
|
|
496
|
+
- **Icons**: ${g.author?.name||"Iconify"}${g.author?.url?` ([Website](${g.author.url}))`:""}
|
|
638
497
|
- **Iconify**: [https://iconify.design/](https://iconify.design/)
|
|
639
|
-
- **Icon Set**: [View on Iconify](https://icon-sets.iconify.design/${
|
|
498
|
+
- **Icon Set**: [View on Iconify](https://icon-sets.iconify.design/${y}/)
|
|
640
499
|
|
|
641
500
|
## Resources
|
|
642
501
|
|
|
643
|
-
- [Browse all icons in this collection](https://icon-sets.iconify.design/${
|
|
502
|
+
- [Browse all icons in this collection](https://icon-sets.iconify.design/${y}/)
|
|
644
503
|
- [Iconify documentation](https://iconify.design/docs/)
|
|
645
504
|
- [stx iconify integration guide](../../docs/iconify.md)
|
|
646
|
-
|
|
647
|
-
}
|
|
648
|
-
async function generatePackage(prefix, outputDir, icons, docsDir) {
|
|
649
|
-
console.log(`
|
|
650
|
-
\uD83D\uDCE6 Generating package for ${prefix}...`);
|
|
651
|
-
const collections = await fetchCollections();
|
|
652
|
-
const collectionInfo = collections[prefix];
|
|
653
|
-
if (!collectionInfo) {
|
|
654
|
-
throw new Error(`Collection ${prefix} not found`);
|
|
655
|
-
}
|
|
656
|
-
console.log(` Collection: ${collectionInfo.name}`);
|
|
657
|
-
console.log(` Total icons: ${collectionInfo.total}`);
|
|
658
|
-
const collectionData = await fetchCollectionIcons(prefix, icons);
|
|
659
|
-
const iconNames = Object.keys(collectionData.icons);
|
|
660
|
-
console.log(` Generating ${iconNames.length} icons...`);
|
|
661
|
-
const packageDir = join(outputDir, `iconify-${prefix}`);
|
|
662
|
-
const srcDir = join(packageDir, "src");
|
|
663
|
-
await mkdir(srcDir, { recursive: true });
|
|
664
|
-
const defaultWidth = collectionData.width || 24;
|
|
665
|
-
const defaultHeight = collectionData.height || 24;
|
|
666
|
-
for (const iconName of iconNames) {
|
|
667
|
-
const iconData = collectionData.icons[iconName];
|
|
668
|
-
const converted = convertIconData(iconData, defaultWidth, defaultHeight);
|
|
669
|
-
const dataFile = generateIconData(iconName, converted);
|
|
670
|
-
await writeFile(join(srcDir, `${iconName}.ts`), dataFile);
|
|
671
|
-
const componentFile = generateIconComponent(iconName, converted);
|
|
672
|
-
await writeFile(join(srcDir, `${iconName}-icon.stx`), componentFile);
|
|
673
|
-
}
|
|
674
|
-
const indexContent = generateIndexFile(iconNames);
|
|
675
|
-
await writeFile(join(srcDir, "index.ts"), indexContent);
|
|
676
|
-
const typesContent = generateTypesFile(prefix);
|
|
677
|
-
await writeFile(join(srcDir, "types.ts"), typesContent);
|
|
678
|
-
const packageJsonContent = generatePackageJson(prefix, collectionInfo, iconNames.length);
|
|
679
|
-
await writeFile(join(packageDir, "package.json"), packageJsonContent);
|
|
680
|
-
const buildContent = generateBuildFile(prefix);
|
|
681
|
-
await writeFile(join(packageDir, "build.ts"), buildContent);
|
|
682
|
-
const readmeContent = generateReadme(prefix, collectionInfo, iconNames.length);
|
|
683
|
-
await writeFile(join(packageDir, "README.md"), readmeContent);
|
|
684
|
-
if (docsDir) {
|
|
685
|
-
const docsPath = join(docsDir, `iconify-${prefix}.md`);
|
|
686
|
-
const docContent = generateDocumentation(prefix, collectionInfo, iconNames);
|
|
687
|
-
await mkdir(docsDir, { recursive: true });
|
|
688
|
-
await writeFile(docsPath, docContent);
|
|
689
|
-
console.log(` \u2713 Generated documentation in ${docsPath}`);
|
|
690
|
-
}
|
|
691
|
-
console.log(` \u2713 Generated ${iconNames.length} icons in ${packageDir}`);
|
|
692
|
-
}
|
|
693
|
-
function toCamelCase(str) {
|
|
694
|
-
let camel = str.replace(/-([a-z0-9])/g, (g) => g[1].toUpperCase());
|
|
695
|
-
camel = camel.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
696
|
-
if (/^[0-9]/.test(camel))
|
|
697
|
-
camel = `_${camel}`;
|
|
698
|
-
return camel;
|
|
699
|
-
}
|
|
700
|
-
function toPascalCase(str) {
|
|
701
|
-
const camel = toCamelCase(str);
|
|
702
|
-
return camel.charAt(0).toUpperCase() + camel.slice(1);
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
// src/cli.ts
|
|
706
|
-
import { join as join2 } from "path";
|
|
707
|
-
import process from "process";
|
|
708
|
-
var args = process.argv.slice(2);
|
|
709
|
-
async function main() {
|
|
710
|
-
if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
|
|
711
|
-
console.log(`
|
|
505
|
+
`}async function q(y,g,u,$){console.log(`
|
|
506
|
+
\uD83D\uDCE6 Generating package for ${y}...`);let b=(await R())[y];if(!b)throw Error(`Collection ${y} not found`);console.log(` Collection: ${b.name}`),console.log(` Total icons: ${b.total}`);let h=await P(y,u),G=Object.keys(h.icons);console.log(` Generating ${G.length} icons...`);let k=S(g,`iconify-${y}`),T=S(k,"src");await Z(T,{recursive:!0});let M=h.width||24,B=h.height||24;for(let v of G){let O=h.icons[v],V=j(O,M,B),J=F(v,V);await z(S(T,`${v}.ts`),J);let _=s(v,V);await z(S(T,`${v}-icon.stx`),_)}let A=N(G);await z(S(T,"index.ts"),A);let W=d(y);await z(S(T,"types.ts"),W);let Y=D(y,b,G.length);await z(S(k,"package.json"),Y);let w=r(y);await z(S(k,"build.ts"),w);let H=C(y,b,G.length);if(await z(S(k,"README.md"),H),$){let v=S($,`iconify-${y}.md`),O=x(y,b,G);await Z($,{recursive:!0}),await z(v,O),console.log(` \u2713 Generated documentation in ${v}`)}console.log(` \u2713 Generated ${G.length} icons in ${k}`)}function K(y){let g=y.replace(/-([a-z0-9])/g,(u)=>u[1].toUpperCase());if(g=g.replace(/[^a-zA-Z0-9_$]/g,"_"),/^[0-9]/.test(g))g=`_${g}`;return g}function I(y){let g=K(y);return g.charAt(0).toUpperCase()+g.slice(1)}import{join as m}from"path";import L from"process";var U=L.argv.slice(2);async function f(){if(U.length===0||U.includes("--help")||U.includes("-h"))console.log(`
|
|
712
507
|
stx-iconify - Generate Iconify icon packages for stx
|
|
713
508
|
|
|
714
509
|
Usage:
|
|
@@ -731,61 +526,12 @@ Examples:
|
|
|
731
526
|
stx-iconify generate tabler --output ./packages
|
|
732
527
|
stx-iconify generate lucide --docs ./docs/collections
|
|
733
528
|
stx-iconify generate mdi --output ./packages --docs ./docs/collections
|
|
734
|
-
`);
|
|
735
|
-
process.exit(0);
|
|
736
|
-
}
|
|
737
|
-
const command = args[0];
|
|
738
|
-
if (command === "list") {
|
|
739
|
-
console.log(`
|
|
529
|
+
`),L.exit(0);let y=U[0];if(y==="list"){console.log(`
|
|
740
530
|
\uD83D\uDCDA Fetching available icon collections...
|
|
741
|
-
`);
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
`);
|
|
746
|
-
for (const [prefix, info] of sortedCollections) {
|
|
747
|
-
console.log(` ${prefix.padEnd(30)} ${info.name} (${info.total} icons)`);
|
|
748
|
-
}
|
|
749
|
-
console.log(`
|
|
750
|
-
Total: ${sortedCollections.length} collections`);
|
|
751
|
-
} else if (command === "generate") {
|
|
752
|
-
const prefix = args[1];
|
|
753
|
-
if (!prefix) {
|
|
754
|
-
console.error("Error: Please specify a collection prefix");
|
|
755
|
-
console.error("Usage: stx-iconify generate <prefix> [icons...]");
|
|
756
|
-
process.exit(1);
|
|
757
|
-
}
|
|
758
|
-
let outputDir = join2(process.cwd(), "packages");
|
|
759
|
-
let docsDir;
|
|
760
|
-
const icons = [];
|
|
761
|
-
for (let i = 2;i < args.length; i++) {
|
|
762
|
-
if (args[i] === "--output" || args[i] === "-o") {
|
|
763
|
-
outputDir = args[i + 1];
|
|
764
|
-
i++;
|
|
765
|
-
} else if (args[i] === "--docs" || args[i] === "-d") {
|
|
766
|
-
docsDir = args[i + 1];
|
|
767
|
-
i++;
|
|
768
|
-
} else if (!args[i].startsWith("--") && !args[i].startsWith("-")) {
|
|
769
|
-
icons.push(args[i]);
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
await generatePackage(prefix, outputDir, icons.length > 0 ? icons : undefined, docsDir);
|
|
773
|
-
console.log(`
|
|
774
|
-
\u2713 Package generated successfully!`);
|
|
775
|
-
console.log(`
|
|
776
|
-
To use the package:`);
|
|
777
|
-
console.log(` 1. cd packages/iconify-${prefix}`);
|
|
778
|
-
console.log(` 2. bun install`);
|
|
779
|
-
console.log(` 3. bun run build`);
|
|
780
|
-
} else {
|
|
781
|
-
console.error(`Unknown command: ${command}`);
|
|
782
|
-
console.error('Run "stx-iconify --help" for usage information');
|
|
783
|
-
process.exit(1);
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
main().catch((error) => {
|
|
787
|
-
console.error("Error:", error.message);
|
|
788
|
-
process.exit(1);
|
|
789
|
-
});
|
|
531
|
+
`);let g=await R(),u=Object.entries(g).sort(($,E)=>E[1].total-$[1].total);console.log(`Available collections:
|
|
532
|
+
`);for(let[$,E]of u)console.log(` ${$.padEnd(30)} ${E.name} (${E.total} icons)`);console.log(`
|
|
533
|
+
Total: ${u.length} collections`)}else if(y==="generate"){let g=U[1];if(!g)console.error("Error: Please specify a collection prefix"),console.error("Usage: stx-iconify generate <prefix> [icons...]"),L.exit(1);let u=m(L.cwd(),"packages"),$,E=[];for(let b=2;b<U.length;b++)if(U[b]==="--output"||U[b]==="-o")u=U[b+1],b++;else if(U[b]==="--docs"||U[b]==="-d")$=U[b+1],b++;else if(!U[b].startsWith("--")&&!U[b].startsWith("-"))E.push(U[b]);await q(g,u,E.length>0?E:void 0,$),console.log(`
|
|
534
|
+
\u2713 Package generated successfully!`),console.log(`
|
|
535
|
+
To use the package:`),console.log(` 1. cd packages/iconify-${g}`),console.log(" 2. bun install"),console.log(" 3. bun run build")}else console.error(`Unknown command: ${y}`),console.error('Run "stx-iconify --help" for usage information'),L.exit(1)}f().catch((y)=>{console.error("Error:",y.message),L.exit(1)});
|
|
790
536
|
|
|
791
|
-
//# debugId=
|
|
537
|
+
//# debugId=69283D7D8171FA5C64756E2164756E21
|