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