<!-- this is a markdown file to show the docs in a custom way using html.
Avatar.stories.js is the standart way -->

import { Meta, Story, Canvas, ArgsTable, Preview } from '@storybook/addon-docs/blocks';

import { Avatar } from './Avatar';

<Meta title='Design System/Avatar' component={Avatar} />

# Avatar

## Displays an image that represents a user or organization

Use an avatar for attributing actions or content to specific users.

The user's name should _always_ be present when using Avatar – either printed beside the avatar or in a tooltip.

<Preview withToolbar>
	<Story name='standard'>
		<Avatar size='large' username='Tom Coleman' src='https://avatars2.githubusercontent.com/u/132554' />
	</Story>
</Preview>

<ArgsTable of={Avatar} />

## Usage

Avatar is used to represent a person or an organization. By default the avatar shows an image and gracefully falls back to the first initial of the username. While hydrating the component you may find it useful to render a skeleton template to indicate that Avatar is awaiting data. Avatars can be grouped with the AvatarList component.

### Sizes

4 sizes are supported.

<Story name='sizes'>
	<div>
		<Avatar size='large' username='Tom Coleman' src='https://avatars2.githubusercontent.com/u/132554' />
		<Avatar size='medium' username='Tom Coleman' src='https://avatars2.githubusercontent.com/u/132554' />
		<Avatar size='small' username='Tom Coleman' src='https://avatars2.githubusercontent.com/u/132554' />
		<Avatar size='tiny' username='Tom Coleman' src='https://avatars2.githubusercontent.com/u/132554' />
	</div>
</Story>

### Default Values

When no image is supplied to the `src` prop, Avatar displays initials.

Avatar should be used sparingly in situations without access to images.

<Story name='initials'>
	<div>
		<Avatar username='Tom Coleman' />
		<Avatar username='Dominic Nguyen' />
		<Avatar username='Kyle Suss' />
		<Avatar username='Michael Shilman' />
	</div>
</Story>

### Loading

The loading state is used when the image or username is, well, loading.

<Story name='loading'>
	<div>
		<Avatar size='large' loading />
		<Avatar size='medium' loading />
		<Avatar size='small' loading />
		<Avatar size='tiny' loading />
	</div>
</Story>

### Playground

Experiment with this story with the Controls addon in the Canvas tab.

export const Template = (args) => <Avatar {...args} />;

<Canvas>
	<Story
		name='controls'
		args={{
			loading: false,
			size: 'tiny',
			username: 'Dominic Nguyen',
			src: 'https://avatars2.githubusercontent.com/u/263385',
		}}>
		{Template.bind({})}
	</Story>
</Canvas>
