mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-24 11:29:12 +00:00
29 lines
730 B
TypeScript
29 lines
730 B
TypeScript
import React from 'react';
|
|
import { Container, Image } from './Avatar.styled';
|
|
|
|
export type AvatarProps = {
|
|
src?: string;
|
|
children?: string | React.ReactNode;
|
|
size?: number;
|
|
hash?: string;
|
|
deliberatelyEmpty?: boolean;
|
|
};
|
|
|
|
/** Chuldren is recommended to not be larger than 2 uppercase letters. */
|
|
export const Avatar = (props: AvatarProps) => (
|
|
<Container size={props.size} deliberatelyEmpty={props.deliberatelyEmpty}>
|
|
{props.src && props.hash && (
|
|
<Image
|
|
style={{
|
|
backgroundImage: `url(${props.src})`,
|
|
}}
|
|
/>
|
|
)}
|
|
<div>
|
|
{props.children || (
|
|
/* needs specifically to prevent layout issues. */
|
|
<> </>
|
|
)}
|
|
</div>
|
|
</Container>
|
|
);
|