@studiocms/ui 0.4.4 → 0.4.5
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.
|
@@ -4,12 +4,10 @@ import type { HTMLAttributes } from 'astro/types';
|
|
|
4
4
|
import IconBase from './IconBase.astro';
|
|
5
5
|
import { type HeroIconName } from './iconType.js';
|
|
6
6
|
|
|
7
|
-
interface Props extends
|
|
7
|
+
interface Props extends HTMLAttributes<'svg'> {
|
|
8
8
|
name: HeroIconName;
|
|
9
9
|
height?: number;
|
|
10
10
|
width?: number;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
const { name, ...props } = Astro.props;
|
|
14
12
|
---
|
|
15
|
-
<IconBase iconCollection={icons} {
|
|
13
|
+
<IconBase iconCollection={icons} {...Astro.props} />
|
|
@@ -43,15 +43,14 @@ interface Props extends HTMLAttributes<'svg'> {
|
|
|
43
43
|
width?: number;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
const { iconCollection, name, ...props } = Astro.props;
|
|
47
|
+
|
|
48
|
+
interface SVGAttributes extends HTMLAttributes<'svg'> {
|
|
47
49
|
// biome-ignore lint/suspicious/noExplicitAny: Allow any string index
|
|
48
50
|
[key: string]: any;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
const attributes = props as PropsAttributes;
|
|
54
|
-
|
|
53
|
+
const attributes = props as SVGAttributes;
|
|
55
54
|
const iconData = getIconData(iconCollection, name);
|
|
56
55
|
|
|
57
56
|
if (!iconData) {
|
|
@@ -59,19 +58,19 @@ if (!iconData) {
|
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
const renderData = iconToSVG(iconData, {
|
|
62
|
-
height: height,
|
|
63
|
-
width: width,
|
|
61
|
+
height: attributes.height || 24,
|
|
62
|
+
width: attributes.width || 24,
|
|
64
63
|
});
|
|
65
64
|
|
|
66
65
|
const body = replaceIDs(renderData.body);
|
|
67
66
|
|
|
68
67
|
let renderAttribsHTML =
|
|
69
|
-
body.indexOf('xlink:') === -1 ? '' : ' xmlns:xlink="http://www.w3.org/1999/xlink';
|
|
68
|
+
body.indexOf('xlink:') === -1 ? '' : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
|
|
70
69
|
|
|
71
70
|
for (const attr in attributes) {
|
|
72
71
|
renderAttribsHTML += ` ${attr}="${attributes[attr]}"`;
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
const svg = `<svg style="min-width: ${height}px" xmlns="http://www.w3.org/2000/svg"${renderAttribsHTML}>${body}</svg>`;
|
|
74
|
+
const svg = `<svg style="min-width: ${attributes.height || 24}px" xmlns="http://www.w3.org/2000/svg"${renderAttribsHTML}>${body}</svg>`;
|
|
76
75
|
---
|
|
77
76
|
<Fragment set:html={svg} />
|