mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-08 04:36:13 +08:00
refactor: create public component for workspace avatar
This commit is contained in:
@@ -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>
|
||||
</>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user