@hugeicons/svelte 1.0.1 → 1.0.2
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.
|
@@ -5,13 +5,18 @@ const defaultAttributes = {
|
|
|
5
5
|
viewBox: '0 0 24 24',
|
|
6
6
|
fill: 'none',
|
|
7
7
|
};
|
|
8
|
+
const camelToKebab = (str) => {
|
|
9
|
+
return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
10
|
+
};
|
|
8
11
|
export function createHugeiconSingleton(iconName, svgElements) {
|
|
9
12
|
const renderIcon = (node, props) => {
|
|
10
13
|
const { color = 'currentColor', size = 24, strokeWidth, absoluteStrokeWidth = false, class: className = '', altIcon, showAlt = false, ...rest } = props;
|
|
11
14
|
const elementProps = {
|
|
12
|
-
|
|
15
|
+
xmlns: 'http://www.w3.org/2000/svg',
|
|
13
16
|
width: size,
|
|
14
17
|
height: size,
|
|
18
|
+
viewBox: '0 0 24 24',
|
|
19
|
+
fill: 'none',
|
|
15
20
|
color,
|
|
16
21
|
class: className,
|
|
17
22
|
...rest
|
|
@@ -23,7 +28,7 @@ export function createHugeiconSingleton(iconName, svgElements) {
|
|
|
23
28
|
: undefined;
|
|
24
29
|
// Set SVG attributes
|
|
25
30
|
Object.entries(elementProps).forEach(([key, value]) => {
|
|
26
|
-
node.setAttribute(key, String(value));
|
|
31
|
+
node.setAttribute(camelToKebab(key), String(value));
|
|
27
32
|
});
|
|
28
33
|
// Clear existing content
|
|
29
34
|
node.innerHTML = '';
|
|
@@ -36,7 +41,7 @@ export function createHugeiconSingleton(iconName, svgElements) {
|
|
|
36
41
|
updatedAttrs['stroke'] = 'currentColor';
|
|
37
42
|
}
|
|
38
43
|
Object.entries(updatedAttrs).forEach(([key, value]) => {
|
|
39
|
-
element.setAttribute(key, String(value));
|
|
44
|
+
element.setAttribute(camelToKebab(key), String(value));
|
|
40
45
|
});
|
|
41
46
|
node.appendChild(element);
|
|
42
47
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hugeicons/svelte",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Hugeicons component library for Svelte",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.umd.js",
|
|
@@ -18,6 +18,12 @@
|
|
|
18
18
|
"files": [
|
|
19
19
|
"dist"
|
|
20
20
|
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "vite build && pnpm run package",
|
|
23
|
+
"package": "svelte-kit sync && svelte-package",
|
|
24
|
+
"check": "svelte-check --tsconfig ./tsconfig.json",
|
|
25
|
+
"prepublishOnly": "pnpm run build"
|
|
26
|
+
},
|
|
21
27
|
"peerDependencies": {
|
|
22
28
|
"svelte": "^5.0.0"
|
|
23
29
|
},
|
|
@@ -41,10 +47,5 @@
|
|
|
41
47
|
"components"
|
|
42
48
|
],
|
|
43
49
|
"author": "Hugeicons",
|
|
44
|
-
"license": "MIT"
|
|
45
|
-
"scripts": {
|
|
46
|
-
"build": "vite build && pnpm run package",
|
|
47
|
-
"package": "svelte-kit sync && svelte-package",
|
|
48
|
-
"check": "svelte-check --tsconfig ./tsconfig.json"
|
|
49
|
-
}
|
|
50
|
+
"license": "MIT"
|
|
50
51
|
}
|