@airplane/views
Version:
A React library for building Airplane views. Views components are optimized in style and functionality to produce internal apps that are easy to build and maintain.
42 lines (41 loc) • 1.27 kB
JavaScript
import { jsx, Fragment } from "react/jsx-runtime";
import { createEmotionCache, MantineProvider, useMantineTheme } from "@mantine/core";
import { forwardRef, cloneElement } from "react";
import { THEME } from "@airplane/views";
const IconWithoutRef = ({
innerRef,
size = "md",
color,
children,
...props
}) => {
const theme = useMantineTheme();
const iconColor = color ? theme.fn.variant({
variant: "filled",
color
}).background : void 0;
const iconSize = theme.fn.size({
size,
sizes: theme.other.icon.sizes
});
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ cloneElement(children, {
color: iconColor,
width: iconSize,
height: iconSize,
ref: innerRef,
...props
}) });
};
const Icon = /* @__PURE__ */ forwardRef((props, ref) => {
const emotionCache = createEmotionCache({
key: "airplane",
container: document.getElementById("airplane-emotion-insertion-point") ?? void 0
});
return /* @__PURE__ */ jsx(MantineProvider, { theme: THEME, withGlobalStyles: true, withNormalizeCSS: true, emotionCache, children: /* @__PURE__ */ jsx(IconWithoutRef, { ...props, innerRef: ref }) });
});
Icon.displayName = "Icon";
export {
Icon,
IconWithoutRef
};
//# sourceMappingURL=Icon.js.map