@stacksjs/iconify-core 0.2.27 → 0.2.89
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/index.d.ts +28 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +10 -0
- package/package.json +11 -2
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate SVG string from icon data
|
|
3
|
+
*/
|
|
4
|
+
export declare function renderIcon(iconData: IconData, props?: IconProps): string;
|
|
5
|
+
/**
|
|
6
|
+
* Generate icon component CSS
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateIconCSS(prefix: string): string;
|
|
9
|
+
export declare interface IconProps {
|
|
10
|
+
name?: string
|
|
11
|
+
size?: string | number
|
|
12
|
+
width?: string | number
|
|
13
|
+
height?: string | number
|
|
14
|
+
color?: string
|
|
15
|
+
hFlip?: boolean
|
|
16
|
+
vFlip?: boolean
|
|
17
|
+
rotate?: 0 | 90 | 180 | 270 | 1 | 2 | 3
|
|
18
|
+
class?: string
|
|
19
|
+
style?: string
|
|
20
|
+
}
|
|
21
|
+
export declare interface IconData {
|
|
22
|
+
body: string
|
|
23
|
+
width?: number
|
|
24
|
+
height?: number
|
|
25
|
+
viewBox?: string
|
|
26
|
+
currentColor?: boolean
|
|
27
|
+
}
|
|
28
|
+
export { type IconData as Icon };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/index.ts
|
|
3
|
+
function renderIcon(iconData, props = {}) {
|
|
4
|
+
const {
|
|
5
|
+
size,
|
|
6
|
+
width: propWidth,
|
|
7
|
+
height: propHeight,
|
|
8
|
+
color = "currentColor",
|
|
9
|
+
hFlip = false,
|
|
10
|
+
vFlip = false,
|
|
11
|
+
rotate = 0,
|
|
12
|
+
class: className = "",
|
|
13
|
+
style: customStyle = ""
|
|
14
|
+
} = props;
|
|
15
|
+
const width = propWidth || size || iconData.width || 24;
|
|
16
|
+
const height = propHeight || size || iconData.height || 24;
|
|
17
|
+
const viewBox = iconData.viewBox || `0 0 ${iconData.width || 24} ${iconData.height || 24}`;
|
|
18
|
+
const transforms = [];
|
|
19
|
+
if (hFlip)
|
|
20
|
+
transforms.push("scaleX(-1)");
|
|
21
|
+
if (vFlip)
|
|
22
|
+
transforms.push("scaleY(-1)");
|
|
23
|
+
if (rotate) {
|
|
24
|
+
const deg = typeof rotate === "number" && rotate < 4 ? rotate * 90 : rotate;
|
|
25
|
+
transforms.push(`rotate(${deg}deg)`);
|
|
26
|
+
}
|
|
27
|
+
const transform = transforms.length > 0 ? transforms.join(" ") : "";
|
|
28
|
+
const transformStyle = transform ? `transform: ${transform};` : "";
|
|
29
|
+
const styles = [];
|
|
30
|
+
if (transformStyle)
|
|
31
|
+
styles.push(transformStyle);
|
|
32
|
+
if (customStyle)
|
|
33
|
+
styles.push(customStyle);
|
|
34
|
+
const style = styles.length > 0 ? ` style="${styles.join(" ")}"` : "";
|
|
35
|
+
const classAttr = className ? ` class="${className}"` : "";
|
|
36
|
+
let body = iconData.body;
|
|
37
|
+
if (color && color !== "currentColor") {
|
|
38
|
+
body = body.replace(/currentColor/g, color);
|
|
39
|
+
}
|
|
40
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="${viewBox}"${classAttr}${style}>${body}</svg>`;
|
|
41
|
+
}
|
|
42
|
+
function generateIconCSS(prefix) {
|
|
43
|
+
return `
|
|
44
|
+
.icon-${prefix} {
|
|
45
|
+
display: inline-block;
|
|
46
|
+
width: 1em;
|
|
47
|
+
height: 1em;
|
|
48
|
+
vertical-align: -0.125em;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.icon-${prefix} svg {
|
|
52
|
+
width: 100%;
|
|
53
|
+
height: 100%;
|
|
54
|
+
}
|
|
55
|
+
`.trim();
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
renderIcon,
|
|
59
|
+
generateIconCSS
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//# debugId=71DF486A723758B064756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"export interface IconProps {\n /**\n * Icon name\n */\n name?: string\n /**\n * Icon size (width and height)\n * @default \"1em\"\n */\n size?: string | number\n /**\n * Icon width\n */\n width?: string | number\n /**\n * Icon height\n */\n height?: string | number\n /**\n * Icon color\n * @default \"currentColor\"\n */\n color?: string\n /**\n * Horizontal flip\n */\n hFlip?: boolean\n /**\n * Vertical flip\n */\n vFlip?: boolean\n /**\n * Rotation in degrees\n */\n rotate?: 0 | 90 | 180 | 270 | 1 | 2 | 3\n /**\n * Additional CSS classes\n */\n class?: string\n /**\n * Additional inline styles\n */\n style?: string\n}\n\nexport interface IconData {\n /**\n * Icon body (SVG path data)\n */\n body: string\n /**\n * Icon width (default: 24)\n */\n width?: number\n /**\n * Icon height (default: 24)\n */\n height?: number\n /**\n * Icon viewBox\n */\n viewBox?: string\n /**\n * Whether the icon uses currentColor\n */\n currentColor?: boolean\n}\n\n/**\n * Generate SVG string from icon data\n */\nexport function renderIcon(iconData: IconData, props: IconProps = {}): string {\n const {\n size,\n width: propWidth,\n height: propHeight,\n color = 'currentColor',\n hFlip = false,\n vFlip = false,\n rotate = 0,\n class: className = '',\n style: customStyle = '',\n } = props\n\n const width = propWidth || size || iconData.width || 24\n const height = propHeight || size || iconData.height || 24\n const viewBox = iconData.viewBox || `0 0 ${iconData.width || 24} ${iconData.height || 24}`\n\n // Build transform\n const transforms: string[] = []\n if (hFlip)\n transforms.push('scaleX(-1)')\n if (vFlip)\n transforms.push('scaleY(-1)')\n if (rotate) {\n const deg = typeof rotate === 'number' && rotate < 4 ? rotate * 90 : rotate\n transforms.push(`rotate(${deg}deg)`)\n }\n\n const transform = transforms.length > 0 ? transforms.join(' ') : ''\n const transformStyle = transform ? `transform: ${transform};` : ''\n\n // Build style\n const styles: string[] = []\n if (transformStyle)\n styles.push(transformStyle)\n if (customStyle)\n styles.push(customStyle)\n\n const style = styles.length > 0 ? ` style=\"${styles.join(' ')}\"` : ''\n const classAttr = className ? ` class=\"${className}\"` : ''\n\n // Replace currentColor in body if color is specified\n let body = iconData.body\n if (color && color !== 'currentColor') {\n body = body.replace(/currentColor/g, color)\n }\n\n return `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${width}\" height=\"${height}\" viewBox=\"${viewBox}\"${classAttr}${style}>${body}</svg>`\n}\n\n/**\n * Generate icon component CSS\n */\nexport function generateIconCSS(prefix: string): string {\n return `\n.icon-${prefix} {\n display: inline-block;\n width: 1em;\n height: 1em;\n vertical-align: -0.125em;\n}\n\n.icon-${prefix} svg {\n width: 100%;\n height: 100%;\n}\n`.trim()\n}\n\nexport { type IconData as Icon }\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;AAuEO,SAAS,UAAU,CAAC,UAAoB,QAAmB,CAAC,GAAW;AAAA,EAC5E;AAAA,IACE;AAAA,IACA,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,OAAO,YAAY;AAAA,IACnB,OAAO,cAAc;AAAA,MACnB;AAAA,EAEJ,MAAM,QAAQ,aAAa,QAAQ,SAAS,SAAS;AAAA,EACrD,MAAM,SAAS,cAAc,QAAQ,SAAS,UAAU;AAAA,EACxD,MAAM,UAAU,SAAS,WAAW,OAAO,SAAS,SAAS,MAAM,SAAS,UAAU;AAAA,EAGtF,MAAM,aAAuB,CAAC;AAAA,EAC9B,IAAI;AAAA,IACF,WAAW,KAAK,YAAY;AAAA,EAC9B,IAAI;AAAA,IACF,WAAW,KAAK,YAAY;AAAA,EAC9B,IAAI,QAAQ;AAAA,IACV,MAAM,MAAM,OAAO,WAAW,YAAY,SAAS,IAAI,SAAS,KAAK;AAAA,IACrE,WAAW,KAAK,UAAU,SAAS;AAAA,EACrC;AAAA,EAEA,MAAM,YAAY,WAAW,SAAS,IAAI,WAAW,KAAK,GAAG,IAAI;AAAA,EACjE,MAAM,iBAAiB,YAAY,cAAc,eAAe;AAAA,EAGhE,MAAM,SAAmB,CAAC;AAAA,EAC1B,IAAI;AAAA,IACF,OAAO,KAAK,cAAc;AAAA,EAC5B,IAAI;AAAA,IACF,OAAO,KAAK,WAAW;AAAA,EAEzB,MAAM,QAAQ,OAAO,SAAS,IAAI,WAAW,OAAO,KAAK,GAAG,OAAO;AAAA,EACnE,MAAM,YAAY,YAAY,WAAW,eAAe;AAAA,EAGxD,IAAI,OAAO,SAAS;AAAA,EACpB,IAAI,SAAS,UAAU,gBAAgB;AAAA,IACrC,OAAO,KAAK,QAAQ,iBAAiB,KAAK;AAAA,EAC5C;AAAA,EAEA,OAAO,kDAAkD,kBAAkB,oBAAoB,WAAW,YAAY,SAAS;AAAA;AAM1H,SAAS,eAAe,CAAC,QAAwB;AAAA,EACtD,OAAO;AAAA,QACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAOA;AAAA;AAAA;AAAA;AAAA,EAIN,KAAK;AAAA;",
|
|
8
|
+
"debugId": "71DF486A723758B064756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/iconify-core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.89",
|
|
5
5
|
"description": "Core utilities for Iconify SVG icons in stx",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/stacksjs/stx#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/stacksjs/stx.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/stacksjs/stx/issues"
|
|
15
|
+
},
|
|
8
16
|
"keywords": [
|
|
9
17
|
"iconify",
|
|
10
18
|
"icons",
|
|
@@ -27,6 +35,7 @@
|
|
|
27
35
|
],
|
|
28
36
|
"scripts": {
|
|
29
37
|
"build": "bun build.ts",
|
|
30
|
-
"dev": "bun build.ts --watch"
|
|
38
|
+
"dev": "bun build.ts --watch",
|
|
39
|
+
"prepublishOnly": "bun run build"
|
|
31
40
|
}
|
|
32
41
|
}
|