refactor: create public component for workspace avatar

This commit is contained in:
tzhangchi
2023-01-06 09:44:42 +08:00
parent 74900b1341
commit 6891e586bc
5 changed files with 40 additions and 35 deletions
@@ -0,0 +1,30 @@
import { stringToColour } from '@/utils';
interface IWorkspaceAvatar {
size: number;
name: string;
}
export const WorkspaceAvatar = (props: IWorkspaceAvatar) => {
const size = props.size || 20;
const sizeStr = size + 'px';
return (
<>
<div
style={{
width: sizeStr,
height: sizeStr,
border: '1px solid #fff',
color: '#fff',
fontSize: Math.ceil(0.5 * size) + 'px',
background: stringToColour(props.name || 'AFFiNE'),
borderRadius: '50%',
textAlign: 'center',
lineHeight: sizeStr,
}}
>
{(props.name || 'AFFiNE').substring(0, 1)}
</div>
</>
);
};