forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAvatar.tsx
More file actions
40 lines (38 loc) · 1.08 KB
/
Avatar.tsx
File metadata and controls
40 lines (38 loc) · 1.08 KB
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
import * as React from 'react';
import styles from '@patternfly/react-styles/css/components/Avatar/avatar';
import { css } from '@patternfly/react-styles';
export interface AvatarProps
extends Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, 'size'> {
/** Additional classes added to the Avatar. */
className?: string;
/** Attribute that specifies the URL of the image for the Avatar. */
src?: string;
/** Attribute that specifies the alternate text of the image for the Avatar. */
alt: string;
/** Border to add */
border?: 'light' | 'dark';
/** Size variant of avatar. */
size?: 'sm' | 'md' | 'lg' | 'xl';
}
export const Avatar: React.FunctionComponent<AvatarProps> = ({
className = '',
src = '',
alt,
border,
size,
...props
}: AvatarProps) => (
<img
src={src}
alt={alt}
className={css(
styles.avatar,
styles.modifiers[size],
border === 'light' && styles.modifiers.light,
border === 'dark' && styles.modifiers.dark,
className
)}
{...props}
/>
);
Avatar.displayName = 'Avatar';