1 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
2 |
|
3 | import { h } from 'preact';
|
4 | import cn from 'classnames';
|
5 | import omit from './utils/omit';
|
6 | import Pill from './pill-icon';
|
7 |
|
8 | const customIcons = {
|
9 | pill: Pill
|
10 | };
|
11 |
|
12 | export const Icon = props => {
|
13 | const { icon, size, className, style } = props;
|
14 | const rest = omit(props, ['icon', 'size', 'className']);
|
15 | const px = `${size || 24}px`;
|
16 | const styles = Object.assign({}, style, {
|
17 | fontSize: px,
|
18 | width: px,
|
19 | height: px
|
20 | });
|
21 | const Custom = customIcons[icon];
|
22 | return h(
|
23 | 'i',
|
24 | _extends({}, rest, {
|
25 | style: styles,
|
26 | className: cn('dib', { 'material-icons': !Custom }, className)
|
27 | }),
|
28 | Custom ? h(Custom, null) : icon
|
29 | );
|
30 | }; |
\ | No newline at end of file |