islamic-icons 1.0.0 → 1.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.
|
@@ -6,21 +6,26 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import Svg from 'react-native-svg';
|
|
8
8
|
const DEFAULT_SIZE = 24;
|
|
9
|
-
|
|
9
|
+
const DEFAULT_VIEWBOX = '0 0 24 24';
|
|
10
|
+
/** Extract inner content and viewBox if passed a full Svg element (from generator) */
|
|
10
11
|
function normalizeContent(node) {
|
|
11
12
|
if (React.isValidElement(node) && node.props?.children) {
|
|
12
13
|
const type = node.type;
|
|
14
|
+
const props = node.props;
|
|
13
15
|
if (type === Svg) {
|
|
14
|
-
return
|
|
16
|
+
return {
|
|
17
|
+
content: props.children,
|
|
18
|
+
viewBox: props.viewBox ?? DEFAULT_VIEWBOX,
|
|
19
|
+
};
|
|
15
20
|
}
|
|
16
21
|
}
|
|
17
|
-
return node;
|
|
22
|
+
return { content: node, viewBox: DEFAULT_VIEWBOX };
|
|
18
23
|
}
|
|
19
24
|
export function createIconComponentRN(displayName, defaultAriaLabel, svgContent) {
|
|
25
|
+
const { content, viewBox } = normalizeContent(svgContent);
|
|
20
26
|
const IconComponent = ({ size = DEFAULT_SIZE, color, style, 'aria-label': ariaLabel, title, ...rest }) => {
|
|
21
27
|
const sizeNum = typeof size === 'number' ? size : parseFloat(String(size)) || DEFAULT_SIZE;
|
|
22
|
-
|
|
23
|
-
return (_jsx(Svg, { width: sizeNum, height: sizeNum, viewBox: "0 0 24 24", fill: color ?? 'currentColor', style: style, accessibilityLabel: title ?? ariaLabel ?? defaultAriaLabel, accessible: !!(ariaLabel ?? title ?? defaultAriaLabel), ...rest, children: content }));
|
|
28
|
+
return (_jsx(Svg, { width: sizeNum, height: sizeNum, viewBox: viewBox, fill: color ?? 'currentColor', style: style, accessibilityLabel: title ?? ariaLabel ?? defaultAriaLabel, accessible: !!(ariaLabel ?? title ?? defaultAriaLabel), ...rest, children: content }));
|
|
24
29
|
};
|
|
25
30
|
IconComponent.displayName = displayName;
|
|
26
31
|
return IconComponent;
|