File size: 974 Bytes
7bbd534
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
33
34
35
36
37
38
39
40
41
42
'use client'
import { chakra, useColorMode } from '@chakra-ui/system';
import { ComponentProps } from 'react';
import { Image } from './Image';

type AvatarImageProps = Partial<
    ComponentProps<typeof Image> & {
        showBorder?: boolean;
    }
>;

export function NextAvatar({
    src,
    showBorder,
    alt = '',
    style,
    ...props
}: AvatarImageProps) {
    const { colorMode } = useColorMode();

    return (
        <Image
            {...props}
            {...(showBorder
                ? {
                      border: '2px',
                      borderColor: colorMode === 'dark' ? 'navy.700' : 'white',
                  }
                : {})}
            alt={alt}
            objectFit={'fill'}
            src={src}
            style={{ ...style, borderRadius: '50%' }}
        />
    );
}

export const ChakraNextAvatar = chakra(NextAvatar, {
  shouldForwardProp: (prop) =>
    ['width', 'height', 'src', 'alt', 'layout'].includes(prop),
});