aboutsummaryrefslogtreecommitdiff
path: root/components/account.tsx
blob: f24135fdd6253af26cb6c7cdebf547eef640b2a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var dummy =
	'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQYV2P4z/j/PwAHAQL/gXZXNQAAAABJRU5ErkJggg==';

export function AccountAvatar(props: {
	size: number;
	dummy?: boolean;
	fallbackFill?: string;
	round?: boolean;

	id?: string;
}) {
	var image = '';
	image += '/api/user/avatar';
	if (typeof props.id === 'string') {
		if (!props.id) image = '';
		else image += `?id=${props.id}`;
	}

	if (props.dummy) image = dummy;

	return <div
		style={{
			width: props.size,
			height: props.size,
			backgroundColor: props.fallbackFill || 'var(--background)',
			backgroundImage: `url(${image})`,
			backgroundSize: 'cover',
			display: 'inline-block',
			borderRadius: props.size / 2 * Number(props.round || 0),
		}}
	/>;
}