UNPKG

@yandex/ui

Version:

Yandex UI components

25 lines (24 loc) 1.18 kB
import { __assign, __rest } from "tslib"; import React from 'react'; import { cn } from '@bem-react/classname'; import './Icon.css'; export var cnIcon = cn('Icon'); /** * Компонент для вставки иконки. * @param {IIconProps} props */ export var Icon = function (_a) { var direction = _a.direction, size = _a.size, url = _a.url, _b = _a.style, style = _b === void 0 ? {} : _b, children = _a.children, title = _a.title, onClick = _a.onClick, // Извлекаем свойства, т.к. они не нужны на DOM узле // FIXME: https://github.com/bem/bem-react/issues/381 // @ts-ignore _type = _a.type, // @ts-ignore _glyph = _a.glyph, props = __rest(_a, ["direction", "size", "url", "style", "children", "title", "onClick", "type", "glyph"]); var className = cnIcon({ direction: direction, size: size }, [props.className]); if (url !== undefined) { style.backgroundImage = "url('" + url + "')"; } return (React.createElement("span", __assign({}, props, { "aria-hidden": true, className: className, style: style, title: title, onClick: onClick }), children)); }; Icon.displayName = cnIcon();