@mlola-ui/icons 1.0.1 → 1.0.3
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 +1 -1
- package/src/index.tsx +5 -4
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -19,11 +19,11 @@ const SHAPES = new Set(["path", "circle", "line", "polyline", "polygon", "rect",
|
|
|
19
19
|
* Give every shape `pathLength="1"`, so one CSS rule can draw any glyph from
|
|
20
20
|
* start to end whatever the true length of its strokes.
|
|
21
21
|
*/
|
|
22
|
-
function
|
|
22
|
+
function normalizePaths(node: React.ReactNode): React.ReactNode {
|
|
23
23
|
return React.Children.map(node, (child) => {
|
|
24
24
|
if (!React.isValidElement<{ children?: React.ReactNode; pathLength?: number }>(child)) return child;
|
|
25
25
|
if (typeof child.type === "string" && SHAPES.has(child.type)) return React.cloneElement(child, { pathLength: 1 });
|
|
26
|
-
if (child.type === React.Fragment) return <>{
|
|
26
|
+
if (child.type === React.Fragment) return <>{normalizePaths(child.props.children)}</>;
|
|
27
27
|
return child;
|
|
28
28
|
});
|
|
29
29
|
}
|
|
@@ -36,7 +36,8 @@ export function createMlolaGlyph(
|
|
|
36
36
|
(
|
|
37
37
|
{
|
|
38
38
|
size = "var(--mlola-glyph-size, 1.125rem)",
|
|
39
|
-
|
|
39
|
+
// An explicit --mlola-glyph-stroke wins; otherwise the theme's icon channel sets the weight.
|
|
40
|
+
strokeWidth = "var(--mlola-glyph-stroke, var(--ml-icon-stroke, 1.75))",
|
|
40
41
|
className,
|
|
41
42
|
animate = false,
|
|
42
43
|
opticalSize = "default",
|
|
@@ -75,7 +76,7 @@ export function createMlolaGlyph(
|
|
|
75
76
|
{...props}
|
|
76
77
|
>
|
|
77
78
|
{title ? <title>{title}</title> : null}
|
|
78
|
-
{
|
|
79
|
+
{normalizePaths(renderPaths({ animate }))}
|
|
79
80
|
</svg>
|
|
80
81
|
);
|
|
81
82
|
}
|