Skip to content

Commit 5965e5d

Browse files
committed
feat: improve avatar ts-docs
1 parent 276ec58 commit 5965e5d

File tree

5 files changed

+37
-9
lines changed

5 files changed

+37
-9
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,6 @@ dist
111111
.idea
112112

113113
# generated docs
114-
./docs
114+
/docs
115115
*storybook.log
116-
storybook-static
116+
/storybook-static

packages/react-material-ui/src/components/Avatar/Avatar.tsx

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,46 @@ import Box from '@mui/material/Box';
33
import { Image } from './Styles';
44
import Text from '../Text';
55

6-
type Props = {
6+
/**
7+
* Avatar component props.
8+
*/
9+
export type AvatarProps = {
10+
/** Path or URL to image file */
711
src?: string;
12+
/** Alternate attribute text */
813
alt?: string;
14+
/** Size in pixels */
915
size?: number;
16+
/** Optional and/or fallback initials to display with the avatar */
1017
initials?: string;
18+
/** Custom `onClick` handler */
1119
onClick?: () => void;
20+
/** Background color name or code */
1221
backgroundColor?: string;
1322
};
1423

15-
export const Avatar = (props: Props) => {
24+
/**
25+
* The Avatar component is a UI element used to display a user's
26+
* profile picture or initials. It supports various features such as image
27+
* source handling, fallbacks (e.g., initials or default image),
28+
* and customization options for styling and sizes.
29+
*
30+
* @see [Storybook - Avatar](https://storybook.rockets.tools/?path=/docs/avatar)
31+
*
32+
* @example
33+
* ```tsx
34+
* <Avatar
35+
* src="https://example.com/nonexistent.jpg"
36+
* alt="Annabel B"
37+
* initials="AB"
38+
* size={40}
39+
* backgroundColor="#789abc"
40+
* />
41+
* ```
42+
*
43+
* @param props - Avatar component props
44+
*/
45+
export const Avatar = (props: AvatarProps) => {
1646
const { src, alt, size = 30, initials, backgroundColor, onClick } = props;
1747
const [failed, setFailed] = useState(!src);
1848

@@ -57,5 +87,3 @@ export const Avatar = (props: Props) => {
5787
</Box>
5888
);
5989
};
60-
61-
export default Avatar;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default } from './Avatar';
1+
export { Avatar, AvatarProps } from './Avatar';

packages/react-material-ui/src/components/HeaderAccount/HeaderAccount.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState, ReactNode } from 'react';
22
import Box from '@mui/material/Box';
33
import Text from '../Text';
4-
import Avatar from '../Avatar';
4+
import { Avatar } from '../Avatar';
55
import { TextProps } from 'interfaces';
66
import ExpandMore from '@mui/icons-material/ExpandMore';
77
import Button from '@mui/material/Button';

packages/react-material-ui/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { default as Avatar } from './components/Avatar';
1+
export { Avatar, AvatarProps } from './components/Avatar';
22
export { default as Checkbox } from './components/Checkbox';
33

44
import AppBar from './components/AppBar';

0 commit comments

Comments
 (0)