@imtf/icons 0.0.3 → 0.0.4
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/lib/src/index.d.ts
CHANGED
package/lib/src/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import require$$0, { createContext, useMemo } from 'react';
|
|
1
|
+
import require$$0, { createContext, useMemo, useContext, useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
/*! *****************************************************************************
|
|
4
4
|
Copyright (c) Microsoft Corporation.
|
|
@@ -2331,4 +2331,27 @@ var IconProvider = function (_a) {
|
|
|
2331
2331
|
return (jsxRuntime.exports.jsx(IconContext.Provider, __assign({ value: __assign(__assign(__assign({}, defaultContext), props), defaultValue) }, { children: children }), void 0));
|
|
2332
2332
|
};
|
|
2333
2333
|
|
|
2334
|
-
|
|
2334
|
+
var IconSVG = function (_a) {
|
|
2335
|
+
var defaultColor = _a.color, size = _a.size, src = _a.src, children = _a.children, props = __rest(_a, ["color", "size", "src", "children"]);
|
|
2336
|
+
var defaultContextValues = useContext(IconContext);
|
|
2337
|
+
var defaultValues = __assign(__assign(__assign({}, defaultContextValues), { color: defaultColor || defaultContextValues.color, size: size || defaultContextValues.size }), props);
|
|
2338
|
+
var color = useMemo(function () { return lodash_get(defaultValues.palette, defaultValues.color, defaultValues.color); }, [defaultValues.color, defaultValues.palette]);
|
|
2339
|
+
useEffect(function () {
|
|
2340
|
+
if (src && !children) {
|
|
2341
|
+
var wrapper = document.getElementById('SVGWrapper');
|
|
2342
|
+
wrapper.innerHTML = atob(src);
|
|
2343
|
+
var svg = wrapper === null || wrapper === void 0 ? void 0 : wrapper.children;
|
|
2344
|
+
var path = svg === null || svg === void 0 ? void 0 : svg[0].firstElementChild;
|
|
2345
|
+
svg === null || svg === void 0 ? void 0 : svg[0].setAttribute('width', typeof defaultValues.size === 'number'
|
|
2346
|
+
? defaultValues.size + 'px'
|
|
2347
|
+
: defaultValues.size);
|
|
2348
|
+
svg === null || svg === void 0 ? void 0 : svg[0].setAttribute('height', typeof defaultValues.size === 'number'
|
|
2349
|
+
? defaultValues.size + 'px'
|
|
2350
|
+
: defaultValues.size);
|
|
2351
|
+
path === null || path === void 0 ? void 0 : path.setAttribute('fill', color);
|
|
2352
|
+
}
|
|
2353
|
+
}, [color, src, children, size]);
|
|
2354
|
+
return children ? (require$$0.cloneElement(children, __assign({ fill: color, width: size, height: size }, props))) : src ? (jsxRuntime.exports.jsx("div", { id: "SVGWrapper" }, void 0)) : null;
|
|
2355
|
+
};
|
|
2356
|
+
|
|
2357
|
+
export { IconContext, IconProvider, IconSVG, defaultContext, withIconContext };
|