omnivore/packages/web/components/elements/Avatar.tsx

47 lines
990 B
TypeScript
Raw Permalink Normal View History

2022-02-11 17:24:33 +00:00
import { styled } from './../tokens/stitches.config'
2024-08-26 05:39:52 +00:00
import { Root, Fallback } from '@radix-ui/react-avatar'
2022-02-11 17:24:33 +00:00
type AvatarProps = {
imageURL?: string
height: string
fallbackText: string
2022-12-12 15:49:15 +00:00
tooltip?: string
2022-02-11 17:24:33 +00:00
}
export function Avatar(props: AvatarProps): JSX.Element {
return (
<StyledAvatar
2022-12-12 15:49:15 +00:00
title={props.tooltip}
2022-02-11 17:24:33 +00:00
css={{
width: props.height,
height: props.height,
borderRadius: '50%',
}}
>
<StyledFallback>{props.fallbackText}</StyledFallback>
</StyledAvatar>
)
}
const StyledAvatar = styled(Root, {
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
verticalAlign: 'middle',
overflow: 'hidden',
userSelect: 'none',
})
const StyledFallback = styled(Fallback, {
width: '100%',
height: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
2023-02-27 03:51:46 +00:00
fontSize: '15px',
fontWeight: 600,
fontFamily: '$inter',
color: '$avatarFont',
2023-02-27 03:51:46 +00:00
backgroundColor: '$avatarBg',
2022-02-11 17:24:33 +00:00
})