@gravity-ui/uikit
Version:
Gravity UI base styling and components
44 lines (43 loc) • 1.42 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { CircleCheck, CircleCheckFill, CircleInfo, CircleInfoFill, CircleXmark, CircleXmarkFill, Thunderbolt, ThunderboltFill, TriangleExclamation, TriangleExclamationFill, } from '@gravity-ui/icons';
import { Icon } from "../Icon/index.js";
import { colorText } from "../Text/colorText/colorText.js";
import { DEFAULT_ICON_SIZE, bAlert } from "./constants.js";
const typeToIcon = {
danger: {
filled: CircleXmarkFill,
outlined: CircleXmark,
},
info: {
filled: CircleInfoFill,
outlined: CircleInfo,
},
success: {
filled: CircleCheckFill,
outlined: CircleCheck,
},
warning: {
filled: TriangleExclamationFill,
outlined: TriangleExclamation,
},
utility: {
filled: ThunderboltFill,
outlined: Thunderbolt,
},
normal: null,
};
export const AlertIcon = ({ className, theme, view = 'filled', size = DEFAULT_ICON_SIZE, }) => {
const iconByTheme = typeToIcon[theme];
if (!iconByTheme) {
return null;
}
let color;
if (theme === 'success') {
color = 'positive';
}
else if (theme !== 'normal') {
color = theme;
}
return (_jsx("div", { className: bAlert('icon', colorText({ color }, className)), children: _jsx(Icon, { data: iconByTheme[view], size: size }) }));
};
//# sourceMappingURL=AlertIcon.js.map