2019-05-24 23:58:27 +00:00
|
|
|
import * as React from 'react';
|
|
|
|
import classNames from 'classnames';
|
2019-06-17 18:46:42 +00:00
|
|
|
import { getImagePath, SkinToneKey } from './lib';
|
2019-05-24 23:58:27 +00:00
|
|
|
|
|
|
|
export type OwnProps = {
|
|
|
|
inline?: boolean;
|
|
|
|
shortName: string;
|
|
|
|
skinTone?: SkinToneKey | number;
|
|
|
|
size?: 16 | 20 | 28 | 32 | 64 | 66;
|
|
|
|
};
|
|
|
|
|
|
|
|
export type Props = OwnProps &
|
|
|
|
Pick<React.HTMLProps<HTMLDivElement>, 'style' | 'className'>;
|
|
|
|
|
|
|
|
export const Emoji = React.memo(
|
|
|
|
React.forwardRef<HTMLDivElement, Props>(
|
|
|
|
(
|
|
|
|
{ style = {}, size = 28, shortName, skinTone, inline, className }: Props,
|
|
|
|
ref
|
|
|
|
) => {
|
2019-06-17 18:46:42 +00:00
|
|
|
const image = getImagePath(shortName, skinTone);
|
2019-05-24 23:58:27 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
ref={ref}
|
|
|
|
className={classNames(
|
|
|
|
'module-emoji',
|
|
|
|
`module-emoji--${size}px`,
|
|
|
|
inline ? 'module-emoji--inline' : null,
|
|
|
|
className
|
|
|
|
)}
|
2019-06-17 18:46:42 +00:00
|
|
|
style={style}
|
|
|
|
>
|
|
|
|
<img
|
|
|
|
className={`module-emoji__image--${size}px`}
|
|
|
|
src={image}
|
|
|
|
alt={shortName}
|
|
|
|
/>
|
|
|
|
</div>
|
2019-05-24 23:58:27 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|