UNPKG

@elastic/eui

Version:

Elastic UI Component Library

62 lines (61 loc) 2.76 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.EuiIllustration = void 0; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); var _react = _interopRequireDefault(require("react")); var _classnames = _interopRequireDefault(require("classnames")); var _services = require("../../services"); var _illustration = require("./illustration.styles"); var _react2 = require("@emotion/react"); var _excluded = ["type", "alt", "className", "fullWidth"]; /* * 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. */ /** * The data contract for an illustration asset (e.g. an export from `@elastic/eui-illustrations`). * It is declared here so that `@elastic/eui` does not depend on the illustrations package. * The illustrations package can be released independently as long as its assets satisfy this shape. * * @remarks * The `light`/`dark` markup is inlined via `dangerouslySetInnerHTML`. Only pass * trusted, package-authored SVGs — never untrusted or user-supplied markup, as * it would be rendered as-is and could introduce an XSS vulnerability. */ var EuiIllustration = exports.EuiIllustration = function EuiIllustration(_ref) { var type = _ref.type, alt = _ref.alt, className = _ref.className, _ref$fullWidth = _ref.fullWidth, fullWidth = _ref$fullWidth === void 0 ? true : _ref$fullWidth, rest = (0, _objectWithoutProperties2.default)(_ref, _excluded); var _useEuiTheme = (0, _services.useEuiTheme)(), colorMode = _useEuiTheme.colorMode; var styles = (0, _services.useEuiMemoizedStyles)(_illustration.euiIllustrationStyles); var classes = (0, _classnames.default)('euiIllustration', className); var cssStyles = [styles.euiIllustration, fullWidth && styles.fullWidth]; var svg = colorMode === 'DARK' ? type.dark : type.light; var isDecorative = alt === ''; var a11yProps = isDecorative ? { 'aria-hidden': true } : { role: 'img', 'aria-label': alt !== null && alt !== void 0 ? alt : type.title }; return (0, _react2.jsx)("span", (0, _extends2.default)({ className: classes, css: cssStyles }, a11yProps, rest, { dangerouslySetInnerHTML: { __html: svg } })); }; EuiIllustration.displayName = 'EuiIllustration';