@elastic/eui
Version:
Elastic UI Component Library
87 lines (86 loc) • 3.48 kB
JavaScript
var _excluded = ["className", "type", "size", "css"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import React from 'react';
import PropTypes from "prop-types";
import classNames from 'classnames';
import { useEuiMemoizedStyles } from '../../services';
import { EuiIcon } from '../icon/icon';
import { icon as EuiIconErrorFill } from '../icon/assets/error_fill';
import { icon as EuiIconCheckCircleFill } from '../icon/assets/check_circle_fill';
import { icon as EuiIconInfoFill } from './assets/info_fill';
import { icon as EuiIconWarningStatic } from './assets/warning_static';
import { euiNotificationIconStyles } from './notification_icon.styles';
import { jsx as ___EmotionJSX } from "@emotion/react";
var TYPES = ['info', 'success', 'warning', 'error'];
export var NOTIFICATION_ICONS_MAP = {
info: {
name: 'infoFill',
icon: EuiIconInfoFill
},
success: {
name: 'checkCircleFill',
icon: EuiIconCheckCircleFill
},
warning: {
name: 'warningStatic',
icon: EuiIconWarningStatic
},
error: {
name: 'errorFill',
icon: EuiIconErrorFill
}
};
var ICON_TYPES_MAP = {
info: {
icon: NOTIFICATION_ICONS_MAP.info.icon,
color: 'primary'
},
success: {
icon: NOTIFICATION_ICONS_MAP.success.icon,
color: 'success'
},
warning: {
icon: NOTIFICATION_ICONS_MAP.warning.icon
},
error: {
icon: NOTIFICATION_ICONS_MAP.error.icon,
color: 'danger'
}
};
export var EuiNotificationIcon = function EuiNotificationIcon(_ref) {
var className = _ref.className,
type = _ref.type,
_ref$size = _ref.size,
size = _ref$size === void 0 ? 'm' : _ref$size,
css = _ref.css,
rest = _objectWithoutProperties(_ref, _excluded);
var Icon = ICON_TYPES_MAP[type];
var classes = classNames('euiNotificationIcon', className);
var styles = useEuiMemoizedStyles(euiNotificationIconStyles);
var cssStyles = [styles.euiNotificationIcon, size === 'l' && styles.size[size], css];
return ___EmotionJSX(EuiIcon, _extends({}, rest, {
className: classes,
css: cssStyles,
type: Icon.icon,
color: Icon.color,
"aria-hidden": "true",
size: size
}));
};
EuiNotificationIcon.propTypes = {
className: PropTypes.string,
"aria-label": PropTypes.string,
"data-test-subj": PropTypes.string,
css: PropTypes.any,
type: PropTypes.any.isRequired,
size: PropTypes.oneOf(["m", "l"])
};