@cruxkit/icon 0.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Maysara Elshewehy (https://github.com/maysara-elshewehy)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,185 @@
1
+ <!-- ╔══════════════════════════════ BEG ══════════════════════════════╗ -->
2
+
3
+ <br>
4
+ <div align="center">
5
+ <p>
6
+ <img src="./assets/img/logo.png" alt="logo" style="" height="60" />
7
+ </p>
8
+ </div>
9
+
10
+ <div align="center">
11
+ <img src="https://img.shields.io/badge/v-0.0.1-black"/>
12
+ <a href="https://github.com/cruxkit-org"><img src="https://img.shields.io/badge/🔥-@cruxkit-black"/></a>
13
+ <br>
14
+ <img src="https://img.shields.io/badge/coverage-99%25-brightgreen" alt="Test Coverage" />
15
+ <img src="https://img.shields.io/github/issues/cruxkit-orgx/icon?style=flat" alt="Github Repo Issues" />
16
+ <img src="https://img.shields.io/github/stars/cruxkit-orgx/icon?style=social" alt="GitHub Repo stars" />
17
+ </div>
18
+ <br>
19
+
20
+ <!-- ╚═════════════════════════════════════════════════════════════════╝ -->
21
+
22
+
23
+
24
+ <!-- ╔══════════════════════════════ DOC ══════════════════════════════╗ -->
25
+
26
+ - ## Overview 👀
27
+ - #### Why ?
28
+ > A lightweight, type-safe icon library offering full TypeScript support and effortless customization.
29
+
30
+ - #### When ?
31
+ > Whenever you need crisp, scalable SVG icons inside CruxJS (or any JSX) projects without pulling in thousands of unused glyphs or heavy CSS frameworks.
32
+
33
+ <br>
34
+ <br>
35
+
36
+ - ## Quick Start 🔥
37
+
38
+ > install [`hmm`](https://github.com/minejs-org/hmm) first.
39
+
40
+ ```bash
41
+ # in your terminal
42
+ hmm i @cruxkit/icon
43
+ ```
44
+
45
+ ```ts
46
+ // in your ts files
47
+ import { ... } from `@cruxkit/icon`;
48
+ ```
49
+
50
+ <div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> </div>
51
+ <br>
52
+
53
+
54
+ - ### Basic usage
55
+
56
+ ```typescript
57
+ import { Icon } from '@cruxkit/icon';
58
+
59
+ const ChevronDown = Icon('chevron-down');
60
+ ```
61
+
62
+ - ### With options
63
+
64
+ ```typescript
65
+ import { Icon } from '@cruxkit/icon';
66
+
67
+ const LargePrimaryChevron = Icon({
68
+ name : 'chevron-down',
69
+ size : 'xl',
70
+ color : '#111827',
71
+ });
72
+ ```
73
+
74
+ - ### Custom SVG
75
+
76
+ ```typescript
77
+ import { Icon } from '@cruxkit/icon';
78
+
79
+ const CustomCircle = Icon({
80
+ svg : `<circle cx="12" cy="12" r="10" />`,
81
+ viewBox : '0 0 24 24',
82
+ size : 24,
83
+ color : '#16a34a',
84
+ });
85
+ ```
86
+
87
+ <br>
88
+ <br>
89
+
90
+ - ## Documentation 📑
91
+
92
+
93
+ - ### API ⛓️
94
+
95
+ - #### Functions
96
+
97
+ ```typescript
98
+ /**
99
+ * Icon Component
100
+ * Renders inline SVG icons with various options
101
+ *
102
+ * @example
103
+ * Icon('check')
104
+ * Icon({ name: 'spinner', spin: true, size: 'lg' })
105
+ */
106
+ export function Icon(props: IconProps) : JSXElement | null
107
+ ```
108
+
109
+ - #### Types
110
+
111
+ ```typescript
112
+ export type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | number;
113
+
114
+ export type IconData = Record<string, unknown>;
115
+ export { iconCatalog };
116
+ export type IconName = CatalogIconName;
117
+
118
+ interface IconConfigBase {
119
+ size? : IconSize
120
+ color? : string
121
+ spin? : boolean
122
+ pulse? : boolean
123
+ rotate? : 0 | 90 | 180 | 270
124
+ flip? : 'horizontal' | 'vertical' | 'both'
125
+ [key: string] : unknown
126
+ }
127
+
128
+ export interface NamedIconConfig extends IconConfigBase {
129
+ name : IconName
130
+ svg? : never
131
+ viewBox? : never
132
+ }
133
+
134
+ export interface CustomIconConfig extends IconConfigBase {
135
+ name? : string
136
+ svg : string
137
+ viewBox? : string
138
+ }
139
+
140
+ export type IconConfig = NamedIconConfig | CustomIconConfig;
141
+
142
+ export type IconProps = IconConfig | IconName;
143
+ ```
144
+
145
+ - #### Constants
146
+
147
+ ```typescript
148
+ export const sizeMap: Record<string, string> = {
149
+ xs : '0.75rem',
150
+ sm : '1rem',
151
+ md : '1.25rem',
152
+ lg : '1.5rem',
153
+ xl : '2rem',
154
+ xxl : '2.5rem'
155
+ };
156
+ ```
157
+
158
+ <div align="center"> <img src="./assets/img/line.png" alt="line" style="display: block; margin-top:20px;margin-bottom:20px;width:500px;"/> </div>
159
+ <br>
160
+
161
+ - ### Related 🔗
162
+
163
+ - ##### [@minejs/jsx](https://github.com/minejs-org/jsx)
164
+
165
+ - ##### [@mineui/utils](https://github.com/mineui-org/utils)
166
+
167
+ - ##### [@cruxkit/..](https://github.com/cruxkit-org)
168
+
169
+
170
+ <!-- ╚═════════════════════════════════════════════════════════════════╝ -->
171
+
172
+
173
+
174
+ <!-- ╔══════════════════════════════ END ══════════════════════════════╗ -->
175
+
176
+ <br>
177
+ <br>
178
+
179
+ ---
180
+
181
+ <div align="center">
182
+ <a href="https://github.com/maysara-elshewehy"><img src="https://img.shields.io/badge/by-Maysara-black"/></a>
183
+ </div>
184
+
185
+ <!-- ╚═════════════════════════════════════════════════════════════════╝ -->
package/dist/index.cjs ADDED
@@ -0,0 +1,3 @@
1
+ 'use strict';var jsxRuntime=require('@minejs/jsx/jsx-runtime');var a={"chevron-down":{category:"chevron",viewBox:"0 0 24 24",svg:'<path d="M6 9L12 15L18 9" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>'}};var e={...a},i={chevron:["chevron-down"]};var g={xs:"0.75rem",sm:"1rem",md:"1.25rem",lg:"1.5rem",xl:"2rem",xxl:"2.5rem"};function d(n){let o=typeof n=="string"?{name:n}:n,t=null;if(o.name&&o.name in e?t=e[o.name]:o.svg&&(t={viewBox:o.viewBox||"0 0 24 24",svg:o.svg}),!t)return o.name?console.warn(`Icon "${o.name}" not found in catalog`):console.warn("Icon configuration is invalid"),null;let r=o.size,s=typeof r=="number"?`${r}px`:g[r||"md"],c={width:s,height:s,display:"inline-block",verticalAlign:"middle",lineHeight:"1",flexShrink:"0"};return o.color&&(c.color=o.color),jsxRuntime.jsx("svg",{style:c,viewBox:t.viewBox,fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",dangerouslySetInnerHTML:{__html:t.svg}})}function w(n){return n in e}function h(){return Object.keys(e)}function N(n){return i[n]||[]}function k(){return Object.keys(i)}
2
+ exports.Icon=d;exports.getIconCategories=k;exports.getIconNames=h;exports.getIconsByCategory=N;exports.iconCatalog=e;exports.iconExists=w;exports.sizeMap=g;//# sourceMappingURL=index.cjs.map
3
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/kit/categories/chevron.ts","../src/kit/categories/index.ts","../src/kit/icon.tsx"],"names":["chevronIcons","iconCatalog","iconsByCategory","sizeMap","Icon","props","cfg","iconData","sizeValue","size","style","jsx","iconExists","name","getIconNames","getIconsByCategory","category","getIconCategories"],"mappings":"+DAAO,IAAMA,CAAAA,CAAe,CAC1B,cAAA,CAAgB,CACd,SAAU,SAAA,CACV,OAAA,CAAS,YACT,GAAA,CAAK,8GACP,CACF,CAAA,CCJO,IAAMC,EAAc,CACzB,GAAGD,CACL,CAAA,CAIaE,CAAAA,CAAkB,CAC7B,OAAA,CAAW,CAAC,cAAc,CAC5B,MCQiBC,CAAAA,CAAkC,CAC3C,GAAU,SAAA,CACV,EAAA,CAAU,OACV,EAAA,CAAU,SAAA,CACV,GAAU,QAAA,CACV,EAAA,CAAU,OACV,GAAA,CAAU,QACd,EAgBO,SAASC,CAAAA,CAAKC,CAAAA,CAAsC,CAWvD,IAAMC,CAAAA,CADS,OAAOD,CAAAA,EAAU,QAAA,CAAW,CAAE,IAAA,CAAMA,CAAM,EAAIA,CAAAA,CAGzDE,CAAAA,CAAoD,KAWxD,GATID,CAAAA,CAAI,MAAQA,CAAAA,CAAI,IAAA,IAAQL,EACxBM,CAAAA,CAAWN,CAAAA,CAAYK,CAAAA,CAAI,IAAgB,CAAA,CACpCA,CAAAA,CAAI,MACXC,CAAAA,CAAW,CACP,QAAUD,CAAAA,CAAI,OAAA,EAAW,YACzB,GAAA,CAAUA,CAAAA,CAAI,GAClB,CAAA,CAAA,CAGA,CAACC,EACD,OAAID,CAAAA,CAAI,KACJ,OAAA,CAAQ,IAAA,CAAK,SAASA,CAAAA,CAAI,IAAI,CAAA,sBAAA,CAAwB,CAAA,CAEtD,OAAA,CAAQ,IAAA,CAAK,+BAA+B,CAAA,CAEzC,IAAA,CAGX,IAAME,CAAAA,CAAYF,CAAAA,CAAI,KAEhBG,CAAAA,CAAO,OAAOD,GAAc,QAAA,CAC5B,CAAA,EAAGA,CAAS,CAAA,EAAA,CAAA,CACZL,CAAAA,CAAQK,GAAa,IAAI,CAAA,CAEzBE,EAAgC,CAClC,KAAA,CAA0BD,CAAAA,CAC1B,MAAA,CAA0BA,CAAAA,CAC1B,OAAA,CAA0B,eAC1B,aAAA,CAA0B,QAAA,CAC1B,WAA0B,GAAA,CAC1B,UAAA,CAA0B,GAC9B,CAAA,CAEA,OAAIH,EAAI,KAAA,GAAOI,CAAAA,CAAM,MAAQJ,CAAAA,CAAI,KAAA,CAAA,CAG7BK,eAAC,KAAA,CAAA,CACG,KAAA,CAAuBD,EACvB,OAAA,CAAuBH,CAAAA,CAAS,OAAA,CAChC,IAAA,CAAsB,cAAA,CACtB,KAAA,CAAsB,6BACtB,aAAA,CAAsB,MAAA,CACtB,KAAsB,KAAA,CACtB,uBAAA,CAA2B,CACvB,MAAA,CAAkBA,CAAAA,CAAS,GAC/B,CAAA,CACJ,CAER,CAKO,SAASK,CAAAA,CAAWC,EAAgC,CACvD,OAAOA,KAAQZ,CACnB,CAKO,SAASa,CAAAA,EAA2B,CACvC,OAAO,OAAO,IAAA,CAAKb,CAAW,CAClC,CAKO,SAASc,EAAmBC,CAAAA,CAA8B,CAC7D,OAAQd,CAAAA,CAAgBc,CAAwC,GAAK,EACzE,CAKO,SAASC,CAAAA,EAA8B,CAC1C,OAAO,MAAA,CAAO,IAAA,CAAKf,CAAe,CACtC","file":"index.cjs","sourcesContent":["export const chevronIcons = {\n 'chevron-down': {\n category: 'chevron',\n viewBox: '0 0 24 24',\n svg: `<path d=\"M6 9L12 15L18 9\" stroke=\"#000000\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>`,\n },\n} as const;\n\nexport type ChevronIconName = keyof typeof chevronIcons;\n","import { chevronIcons } from './chevron';\n\nexport const iconCatalog = {\n ...chevronIcons,\n} as const;\n\nexport type IconName = keyof typeof iconCatalog;\n\nexport const iconsByCategory = {\n 'chevron': ['chevron-down'],\n} as const;\n","// src/kit/icon.tsx\r\n//\r\n// Made with ❤️ by Maysara.\r\n\r\n\r\n\r\n// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗\r\n\r\n import { JSXElement } from '@minejs/jsx';\r\n import { IconProps, iconCatalog, type IconName } from '../types';\r\n import { iconsByCategory } from './categories';\r\n\r\n// ╚══════════════════════════════════════════════════════════════════════════════════════╝\r\n\r\n\r\n\r\n// ╔════════════════════════════════════════ INIT ════════════════════════════════════════╗\r\n\r\n export const sizeMap: Record<string, string> = {\r\n xs : '0.75rem',\r\n sm : '1rem',\r\n md : '1.25rem',\r\n lg : '1.5rem',\r\n xl : '2rem',\r\n 'xxl' : '2.5rem'\r\n };\r\n\r\n// ╚══════════════════════════════════════════════════════════════════════════════════════╝\r\n\r\n\r\n\r\n// ╔════════════════════════════════════════ CORE ════════════════════════════════════════╗\r\n\r\n /**\r\n * Icon Component\r\n * Renders inline SVG icons with various options\r\n *\r\n * @example\r\n * Icon('check')\r\n * Icon({ name: 'spinner', spin: true, size: 'lg' })\r\n */\r\n export function Icon(props: IconProps) : JSXElement | null {\r\n\r\n interface IconLikeConfig {\r\n name? : string\r\n size? : number | string\r\n color? : string\r\n svg? : string\r\n viewBox? : string\r\n }\r\n\r\n const config = typeof props === 'string' ? { name: props } : props;\r\n const cfg = config as IconLikeConfig;\r\n\r\n let iconData: { viewBox: string; svg: string } | null = null;\r\n\r\n if (cfg.name && cfg.name in iconCatalog) {\r\n iconData = iconCatalog[cfg.name as IconName] as { viewBox: string; svg: string };\r\n } else if (cfg.svg) {\r\n iconData = {\r\n viewBox : cfg.viewBox || '0 0 24 24',\r\n svg : cfg.svg\r\n };\r\n }\r\n\r\n if (!iconData) {\r\n if (cfg.name) {\r\n console.warn(`Icon \"${cfg.name}\" not found in catalog`);\r\n } else {\r\n console.warn('Icon configuration is invalid');\r\n }\r\n return null;\r\n }\r\n\r\n const sizeValue = cfg.size;\r\n\r\n const size = typeof sizeValue === 'number'\r\n ? `${sizeValue}px`\r\n : sizeMap[sizeValue || 'md'];\r\n\r\n const style: Record<string, string> = {\r\n width : size,\r\n height : size,\r\n display : 'inline-block',\r\n verticalAlign : 'middle',\r\n lineHeight : '1',\r\n flexShrink : '0'\r\n };\r\n\r\n if (cfg.color) style.color = cfg.color;\r\n\r\n return (\r\n <svg\r\n style = {style}\r\n viewBox = {iconData.viewBox}\r\n fill = \"currentColor\"\r\n xmlns = \"http://www.w3.org/2000/svg\"\r\n aria-hidden = \"true\"\r\n role = \"img\"\r\n dangerouslySetInnerHTML = {{\r\n __html : iconData.svg\r\n }}\r\n />\r\n );\r\n }\r\n\r\n /**\r\n * Utility function to check if an icon exists\r\n */\r\n export function iconExists(name: string): name is IconName {\r\n return name in iconCatalog;\r\n }\r\n\r\n /**\r\n * Get all available icon names\r\n */\r\n export function getIconNames(): IconName[] {\r\n return Object.keys(iconCatalog) as IconName[];\r\n }\r\n\r\n /**\r\n * Get icons by category\r\n */\r\n export function getIconsByCategory(category: string): IconName[] {\r\n return (iconsByCategory[category as keyof typeof iconsByCategory] || []) as unknown as IconName[];\r\n }\r\n\r\n /**\r\n * Get all available categories\r\n */\r\n export function getIconCategories(): string[] {\r\n return Object.keys(iconsByCategory);\r\n }\r\n\r\n// ╚══════════════════════════════════════════════════════════════════════════════════════╝\r\n"]}
@@ -0,0 +1,65 @@
1
+ import { JSXElement } from '@minejs/jsx';
2
+
3
+ declare const iconCatalog: {
4
+ readonly 'chevron-down': {
5
+ readonly category: "chevron";
6
+ readonly viewBox: "0 0 24 24";
7
+ readonly svg: "<path d=\"M6 9L12 15L18 9\" stroke=\"#000000\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>";
8
+ };
9
+ };
10
+ type IconName$1 = keyof typeof iconCatalog;
11
+
12
+ type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | number;
13
+ type IconData = Record<string, unknown>;
14
+
15
+ type IconName = IconName$1;
16
+ interface IconConfigBase {
17
+ size?: IconSize;
18
+ color?: string;
19
+ spin?: boolean;
20
+ pulse?: boolean;
21
+ rotate?: 0 | 90 | 180 | 270;
22
+ flip?: 'horizontal' | 'vertical' | 'both';
23
+ [key: string]: unknown;
24
+ }
25
+ interface NamedIconConfig extends IconConfigBase {
26
+ name: IconName;
27
+ svg?: never;
28
+ viewBox?: never;
29
+ }
30
+ interface CustomIconConfig extends IconConfigBase {
31
+ name?: string;
32
+ svg: string;
33
+ viewBox?: string;
34
+ }
35
+ type IconConfig = NamedIconConfig | CustomIconConfig;
36
+ type IconProps = IconConfig | IconName;
37
+
38
+ declare const sizeMap: Record<string, string>;
39
+ /**
40
+ * Icon Component
41
+ * Renders inline SVG icons with various options
42
+ *
43
+ * @example
44
+ * Icon('check')
45
+ * Icon({ name: 'spinner', spin: true, size: 'lg' })
46
+ */
47
+ declare function Icon(props: IconProps): JSXElement | null;
48
+ /**
49
+ * Utility function to check if an icon exists
50
+ */
51
+ declare function iconExists(name: string): name is IconName;
52
+ /**
53
+ * Get all available icon names
54
+ */
55
+ declare function getIconNames(): IconName[];
56
+ /**
57
+ * Get icons by category
58
+ */
59
+ declare function getIconsByCategory(category: string): IconName[];
60
+ /**
61
+ * Get all available categories
62
+ */
63
+ declare function getIconCategories(): string[];
64
+
65
+ export { type CustomIconConfig, Icon, type IconConfig, type IconData, type IconName, type IconProps, type IconSize, type NamedIconConfig, getIconCategories, getIconNames, getIconsByCategory, iconCatalog, iconExists, sizeMap };
@@ -0,0 +1,65 @@
1
+ import { JSXElement } from '@minejs/jsx';
2
+
3
+ declare const iconCatalog: {
4
+ readonly 'chevron-down': {
5
+ readonly category: "chevron";
6
+ readonly viewBox: "0 0 24 24";
7
+ readonly svg: "<path d=\"M6 9L12 15L18 9\" stroke=\"#000000\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>";
8
+ };
9
+ };
10
+ type IconName$1 = keyof typeof iconCatalog;
11
+
12
+ type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | number;
13
+ type IconData = Record<string, unknown>;
14
+
15
+ type IconName = IconName$1;
16
+ interface IconConfigBase {
17
+ size?: IconSize;
18
+ color?: string;
19
+ spin?: boolean;
20
+ pulse?: boolean;
21
+ rotate?: 0 | 90 | 180 | 270;
22
+ flip?: 'horizontal' | 'vertical' | 'both';
23
+ [key: string]: unknown;
24
+ }
25
+ interface NamedIconConfig extends IconConfigBase {
26
+ name: IconName;
27
+ svg?: never;
28
+ viewBox?: never;
29
+ }
30
+ interface CustomIconConfig extends IconConfigBase {
31
+ name?: string;
32
+ svg: string;
33
+ viewBox?: string;
34
+ }
35
+ type IconConfig = NamedIconConfig | CustomIconConfig;
36
+ type IconProps = IconConfig | IconName;
37
+
38
+ declare const sizeMap: Record<string, string>;
39
+ /**
40
+ * Icon Component
41
+ * Renders inline SVG icons with various options
42
+ *
43
+ * @example
44
+ * Icon('check')
45
+ * Icon({ name: 'spinner', spin: true, size: 'lg' })
46
+ */
47
+ declare function Icon(props: IconProps): JSXElement | null;
48
+ /**
49
+ * Utility function to check if an icon exists
50
+ */
51
+ declare function iconExists(name: string): name is IconName;
52
+ /**
53
+ * Get all available icon names
54
+ */
55
+ declare function getIconNames(): IconName[];
56
+ /**
57
+ * Get icons by category
58
+ */
59
+ declare function getIconsByCategory(category: string): IconName[];
60
+ /**
61
+ * Get all available categories
62
+ */
63
+ declare function getIconCategories(): string[];
64
+
65
+ export { type CustomIconConfig, Icon, type IconConfig, type IconData, type IconName, type IconProps, type IconSize, type NamedIconConfig, getIconCategories, getIconNames, getIconsByCategory, iconCatalog, iconExists, sizeMap };
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import {jsx}from'@minejs/jsx/jsx-runtime';var a={"chevron-down":{category:"chevron",viewBox:"0 0 24 24",svg:'<path d="M6 9L12 15L18 9" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>'}};var e={...a},i={chevron:["chevron-down"]};var g={xs:"0.75rem",sm:"1rem",md:"1.25rem",lg:"1.5rem",xl:"2rem",xxl:"2.5rem"};function d(n){let o=typeof n=="string"?{name:n}:n,t=null;if(o.name&&o.name in e?t=e[o.name]:o.svg&&(t={viewBox:o.viewBox||"0 0 24 24",svg:o.svg}),!t)return o.name?console.warn(`Icon "${o.name}" not found in catalog`):console.warn("Icon configuration is invalid"),null;let r=o.size,s=typeof r=="number"?`${r}px`:g[r||"md"],c={width:s,height:s,display:"inline-block",verticalAlign:"middle",lineHeight:"1",flexShrink:"0"};return o.color&&(c.color=o.color),jsx("svg",{style:c,viewBox:t.viewBox,fill:"currentColor",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",dangerouslySetInnerHTML:{__html:t.svg}})}function w(n){return n in e}function h(){return Object.keys(e)}function N(n){return i[n]||[]}function k(){return Object.keys(i)}
2
+ export{d as Icon,k as getIconCategories,h as getIconNames,N as getIconsByCategory,e as iconCatalog,w as iconExists,g as sizeMap};//# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/kit/categories/chevron.ts","../src/kit/categories/index.ts","../src/kit/icon.tsx"],"names":["chevronIcons","iconCatalog","iconsByCategory","sizeMap","Icon","props","cfg","iconData","sizeValue","size","style","jsx","iconExists","name","getIconNames","getIconsByCategory","category","getIconCategories"],"mappings":"0CAAO,IAAMA,CAAAA,CAAe,CAC1B,cAAA,CAAgB,CACd,SAAU,SAAA,CACV,OAAA,CAAS,YACT,GAAA,CAAK,8GACP,CACF,CAAA,CCJO,IAAMC,EAAc,CACzB,GAAGD,CACL,CAAA,CAIaE,CAAAA,CAAkB,CAC7B,OAAA,CAAW,CAAC,cAAc,CAC5B,MCQiBC,CAAAA,CAAkC,CAC3C,GAAU,SAAA,CACV,EAAA,CAAU,OACV,EAAA,CAAU,SAAA,CACV,GAAU,QAAA,CACV,EAAA,CAAU,OACV,GAAA,CAAU,QACd,EAgBO,SAASC,CAAAA,CAAKC,CAAAA,CAAsC,CAWvD,IAAMC,CAAAA,CADS,OAAOD,CAAAA,EAAU,QAAA,CAAW,CAAE,IAAA,CAAMA,CAAM,EAAIA,CAAAA,CAGzDE,CAAAA,CAAoD,KAWxD,GATID,CAAAA,CAAI,MAAQA,CAAAA,CAAI,IAAA,IAAQL,EACxBM,CAAAA,CAAWN,CAAAA,CAAYK,CAAAA,CAAI,IAAgB,CAAA,CACpCA,CAAAA,CAAI,MACXC,CAAAA,CAAW,CACP,QAAUD,CAAAA,CAAI,OAAA,EAAW,YACzB,GAAA,CAAUA,CAAAA,CAAI,GAClB,CAAA,CAAA,CAGA,CAACC,EACD,OAAID,CAAAA,CAAI,KACJ,OAAA,CAAQ,IAAA,CAAK,SAASA,CAAAA,CAAI,IAAI,CAAA,sBAAA,CAAwB,CAAA,CAEtD,OAAA,CAAQ,IAAA,CAAK,+BAA+B,CAAA,CAEzC,IAAA,CAGX,IAAME,CAAAA,CAAYF,CAAAA,CAAI,KAEhBG,CAAAA,CAAO,OAAOD,GAAc,QAAA,CAC5B,CAAA,EAAGA,CAAS,CAAA,EAAA,CAAA,CACZL,CAAAA,CAAQK,GAAa,IAAI,CAAA,CAEzBE,EAAgC,CAClC,KAAA,CAA0BD,CAAAA,CAC1B,MAAA,CAA0BA,CAAAA,CAC1B,OAAA,CAA0B,eAC1B,aAAA,CAA0B,QAAA,CAC1B,WAA0B,GAAA,CAC1B,UAAA,CAA0B,GAC9B,CAAA,CAEA,OAAIH,EAAI,KAAA,GAAOI,CAAAA,CAAM,MAAQJ,CAAAA,CAAI,KAAA,CAAA,CAG7BK,IAAC,KAAA,CAAA,CACG,KAAA,CAAuBD,EACvB,OAAA,CAAuBH,CAAAA,CAAS,OAAA,CAChC,IAAA,CAAsB,cAAA,CACtB,KAAA,CAAsB,6BACtB,aAAA,CAAsB,MAAA,CACtB,KAAsB,KAAA,CACtB,uBAAA,CAA2B,CACvB,MAAA,CAAkBA,CAAAA,CAAS,GAC/B,CAAA,CACJ,CAER,CAKO,SAASK,CAAAA,CAAWC,EAAgC,CACvD,OAAOA,KAAQZ,CACnB,CAKO,SAASa,CAAAA,EAA2B,CACvC,OAAO,OAAO,IAAA,CAAKb,CAAW,CAClC,CAKO,SAASc,EAAmBC,CAAAA,CAA8B,CAC7D,OAAQd,CAAAA,CAAgBc,CAAwC,GAAK,EACzE,CAKO,SAASC,CAAAA,EAA8B,CAC1C,OAAO,MAAA,CAAO,IAAA,CAAKf,CAAe,CACtC","file":"index.js","sourcesContent":["export const chevronIcons = {\n 'chevron-down': {\n category: 'chevron',\n viewBox: '0 0 24 24',\n svg: `<path d=\"M6 9L12 15L18 9\" stroke=\"#000000\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>`,\n },\n} as const;\n\nexport type ChevronIconName = keyof typeof chevronIcons;\n","import { chevronIcons } from './chevron';\n\nexport const iconCatalog = {\n ...chevronIcons,\n} as const;\n\nexport type IconName = keyof typeof iconCatalog;\n\nexport const iconsByCategory = {\n 'chevron': ['chevron-down'],\n} as const;\n","// src/kit/icon.tsx\r\n//\r\n// Made with ❤️ by Maysara.\r\n\r\n\r\n\r\n// ╔════════════════════════════════════════ PACK ════════════════════════════════════════╗\r\n\r\n import { JSXElement } from '@minejs/jsx';\r\n import { IconProps, iconCatalog, type IconName } from '../types';\r\n import { iconsByCategory } from './categories';\r\n\r\n// ╚══════════════════════════════════════════════════════════════════════════════════════╝\r\n\r\n\r\n\r\n// ╔════════════════════════════════════════ INIT ════════════════════════════════════════╗\r\n\r\n export const sizeMap: Record<string, string> = {\r\n xs : '0.75rem',\r\n sm : '1rem',\r\n md : '1.25rem',\r\n lg : '1.5rem',\r\n xl : '2rem',\r\n 'xxl' : '2.5rem'\r\n };\r\n\r\n// ╚══════════════════════════════════════════════════════════════════════════════════════╝\r\n\r\n\r\n\r\n// ╔════════════════════════════════════════ CORE ════════════════════════════════════════╗\r\n\r\n /**\r\n * Icon Component\r\n * Renders inline SVG icons with various options\r\n *\r\n * @example\r\n * Icon('check')\r\n * Icon({ name: 'spinner', spin: true, size: 'lg' })\r\n */\r\n export function Icon(props: IconProps) : JSXElement | null {\r\n\r\n interface IconLikeConfig {\r\n name? : string\r\n size? : number | string\r\n color? : string\r\n svg? : string\r\n viewBox? : string\r\n }\r\n\r\n const config = typeof props === 'string' ? { name: props } : props;\r\n const cfg = config as IconLikeConfig;\r\n\r\n let iconData: { viewBox: string; svg: string } | null = null;\r\n\r\n if (cfg.name && cfg.name in iconCatalog) {\r\n iconData = iconCatalog[cfg.name as IconName] as { viewBox: string; svg: string };\r\n } else if (cfg.svg) {\r\n iconData = {\r\n viewBox : cfg.viewBox || '0 0 24 24',\r\n svg : cfg.svg\r\n };\r\n }\r\n\r\n if (!iconData) {\r\n if (cfg.name) {\r\n console.warn(`Icon \"${cfg.name}\" not found in catalog`);\r\n } else {\r\n console.warn('Icon configuration is invalid');\r\n }\r\n return null;\r\n }\r\n\r\n const sizeValue = cfg.size;\r\n\r\n const size = typeof sizeValue === 'number'\r\n ? `${sizeValue}px`\r\n : sizeMap[sizeValue || 'md'];\r\n\r\n const style: Record<string, string> = {\r\n width : size,\r\n height : size,\r\n display : 'inline-block',\r\n verticalAlign : 'middle',\r\n lineHeight : '1',\r\n flexShrink : '0'\r\n };\r\n\r\n if (cfg.color) style.color = cfg.color;\r\n\r\n return (\r\n <svg\r\n style = {style}\r\n viewBox = {iconData.viewBox}\r\n fill = \"currentColor\"\r\n xmlns = \"http://www.w3.org/2000/svg\"\r\n aria-hidden = \"true\"\r\n role = \"img\"\r\n dangerouslySetInnerHTML = {{\r\n __html : iconData.svg\r\n }}\r\n />\r\n );\r\n }\r\n\r\n /**\r\n * Utility function to check if an icon exists\r\n */\r\n export function iconExists(name: string): name is IconName {\r\n return name in iconCatalog;\r\n }\r\n\r\n /**\r\n * Get all available icon names\r\n */\r\n export function getIconNames(): IconName[] {\r\n return Object.keys(iconCatalog) as IconName[];\r\n }\r\n\r\n /**\r\n * Get icons by category\r\n */\r\n export function getIconsByCategory(category: string): IconName[] {\r\n return (iconsByCategory[category as keyof typeof iconsByCategory] || []) as unknown as IconName[];\r\n }\r\n\r\n /**\r\n * Get all available categories\r\n */\r\n export function getIconCategories(): string[] {\r\n return Object.keys(iconsByCategory);\r\n }\r\n\r\n// ╚══════════════════════════════════════════════════════════════════════════════════════╝\r\n"]}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@cruxkit/icon",
3
+ "version": "0.0.1",
4
+ "description": "A lightweight, type-safe icon library offering full TypeScript support and effortless customization.",
5
+ "keywords": ["crux", "kit", "icon"],
6
+ "license": "MIT",
7
+ "homepage": "https://github.com/cruxkit-org/icon#readme",
8
+ "bugs": {
9
+ "url": "https://github.com/cruxkit-org/icon/issues"
10
+ },
11
+ "author": {
12
+ "name": "Maysara",
13
+ "email": "maysara.elshewehy@gmail.com",
14
+ "url": "https://github.com/maysara-elshewehy"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/cruxkit-org/icon.git"
19
+ },
20
+ "type": "module",
21
+ "main": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "files": ["dist"],
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "import": "./dist/index.js",
28
+ "require": "./dist/index.js"
29
+ }
30
+ },
31
+ "scripts": {
32
+ "build": "bun builder/builder.ts && tsup",
33
+ "lint": "eslint src --ext .ts",
34
+ "test": "bun test"
35
+ },
36
+ "engines": {
37
+ "bun": ">=1.3.3"
38
+ },
39
+ "peerDependencies": {
40
+ "bun": "^1.3.3"
41
+ },
42
+ "dependencies": {
43
+ "@minejs/jsx": "^0.1.3"
44
+ },
45
+ "devDependencies": {
46
+ "@eslint/js": "^9.39.2",
47
+ "@stylistic/eslint-plugin": "^5.6.1",
48
+ "@types/bun": "^1.3.5",
49
+ "@types/node": "^20.19.27",
50
+ "@types/react": "^19.2.8",
51
+ "bun-plugin-dts": "^0.3.0",
52
+ "bun-types": "^1.3.5",
53
+ "ts-node": "^10.9.2",
54
+ "tsup": "^8.5.1",
55
+ "typescript": "^5.9.3",
56
+ "typescript-eslint": "^8.51.0"
57
+ }
58
+ }