-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathIconifyIcon.tsx
More file actions
37 lines (34 loc) · 985 Bytes
/
IconifyIcon.tsx
File metadata and controls
37 lines (34 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { Icon, IconProps } from "@iconify/react";
import { Box, BoxProps } from "@mui/material";
interface IconifyProps extends IconProps {
sx?: BoxProps["sx"];
flipOnRTL?: boolean;
icon: string;
}
// ⚡ Bolt Performance Optimization
// Removed static imports of @iconify-json/* datasets to prevent massive bundle bloat.
// Passing the icon string directly to the Icon component allows @iconify/react
// to fetch SVG data on-demand and cache it, significantly reducing the initial JS payload size.
const IconifyIcon = ({
icon,
flipOnRTL = false,
sx,
...rest
}: IconifyProps) => {
return (
<Box
component={icon ? Icon : "span"}
{...(icon ? { icon: icon } : ({} as any))}
className='iconify'
sx={[
flipOnRTL && {
transform: (theme) =>
theme.direction === "rtl" ? "scaleX(-1)" : "none",
},
...(Array.isArray(sx) ? sx : [sx]),
]}
{...rest}
/>
);
};
export default IconifyIcon;