UNPKG

@elastic/eui

Version:

Elastic UI Component Library

57 lines (55 loc) 2.39 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; 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. */ import React from 'react'; import classNames from 'classnames'; import { useEuiMemoizedStyles, useEuiTheme } from '../../services'; import { euiIllustrationStyles } from './illustration.styles'; /** * 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. */ import { jsx as ___EmotionJSX } from "@emotion/react"; export var 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 = _objectWithoutProperties(_ref, _excluded); var _useEuiTheme = useEuiTheme(), colorMode = _useEuiTheme.colorMode; var styles = useEuiMemoizedStyles(euiIllustrationStyles); var classes = classNames('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 ___EmotionJSX("span", _extends({ className: classes, css: cssStyles }, a11yProps, rest, { dangerouslySetInnerHTML: { __html: svg } })); }; EuiIllustration.displayName = 'EuiIllustration';