@uniweb/kit 0.4.0 → 0.4.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.
- package/package.json +2 -2
- package/src/components/Icon/Icon.jsx +31 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/kit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Standard component library for Uniweb foundations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"fuse.js": "^7.0.0",
|
|
40
40
|
"shiki": "^3.0.0",
|
|
41
41
|
"tailwind-merge": "^2.6.0",
|
|
42
|
-
"@uniweb/core": "0.3.
|
|
42
|
+
"@uniweb/core": "0.3.2"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -52,10 +52,23 @@ function parseSvg(svgContent) {
|
|
|
52
52
|
const width = svg.getAttribute('width')
|
|
53
53
|
const height = svg.getAttribute('height')
|
|
54
54
|
|
|
55
|
+
// Preserve SVG presentation attributes from the source
|
|
56
|
+
// Different icon families use different rendering styles:
|
|
57
|
+
// - Lucide, Feather, Heroicons: stroke-based (fill="none", stroke="currentColor")
|
|
58
|
+
// - Font Awesome, Bootstrap: fill-based (fill="currentColor")
|
|
59
|
+
const fill = svg.getAttribute('fill')
|
|
60
|
+
const stroke = svg.getAttribute('stroke')
|
|
61
|
+
const strokeWidth = svg.getAttribute('stroke-width')
|
|
62
|
+
const strokeLinecap = svg.getAttribute('stroke-linecap')
|
|
63
|
+
const strokeLinejoin = svg.getAttribute('stroke-linejoin')
|
|
64
|
+
|
|
55
65
|
// Get inner content
|
|
56
66
|
const content = svg.innerHTML
|
|
57
67
|
|
|
58
|
-
return {
|
|
68
|
+
return {
|
|
69
|
+
viewBox, content, width, height,
|
|
70
|
+
fill, stroke, strokeWidth, strokeLinecap, strokeLinejoin
|
|
71
|
+
}
|
|
59
72
|
} catch (error) {
|
|
60
73
|
console.warn('[Icon] Error parsing SVG:', error)
|
|
61
74
|
return null
|
|
@@ -260,11 +273,26 @@ export function Icon({
|
|
|
260
273
|
...(color && !preserveColors ? { color } : {})
|
|
261
274
|
}
|
|
262
275
|
|
|
276
|
+
// Determine fill/stroke from source SVG, built-in defaults, or fallback
|
|
277
|
+
const svgFill = svgData.isBuiltIn
|
|
278
|
+
? 'none'
|
|
279
|
+
: preserveColors
|
|
280
|
+
? undefined
|
|
281
|
+
: svgData.fill ?? 'currentColor'
|
|
282
|
+
const svgStroke = svgData.isBuiltIn
|
|
283
|
+
? 'currentColor'
|
|
284
|
+
: preserveColors
|
|
285
|
+
? undefined
|
|
286
|
+
: svgData.stroke ?? undefined
|
|
287
|
+
|
|
263
288
|
return (
|
|
264
289
|
<svg
|
|
265
290
|
viewBox={svgData.viewBox}
|
|
266
|
-
fill={
|
|
267
|
-
stroke={
|
|
291
|
+
fill={svgFill}
|
|
292
|
+
stroke={svgStroke}
|
|
293
|
+
strokeWidth={svgData.strokeWidth ?? undefined}
|
|
294
|
+
strokeLinecap={svgData.strokeLinecap ?? undefined}
|
|
295
|
+
strokeLinejoin={svgData.strokeLinejoin ?? undefined}
|
|
268
296
|
className={cn('inline-block', className)}
|
|
269
297
|
style={style}
|
|
270
298
|
role="img"
|