Skip to content

Commit

Permalink
feat(avatar): avatar component rfc (#534)
Browse files Browse the repository at this point in the history
* feat: avatar component rfc

* fix: provide more a11y info regarding name prop

* fix: removes srcFallback prop
  • Loading branch information
chasestarr authored Nov 26, 2018
1 parent c8efbf0 commit 1a7a2b2
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions rfcs/avatar-component.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Avatar Component

## Usage

### Basic usage

```javascript
import * as React from 'react';
import {Avatar} from 'baseui/avatar';

export default () => <Avatar name="Jane Doe" src="https://url-of-img.jpg" />;
```

### Advanced usage

```javascript
import * as React from 'react';
import {Avatar} from 'baseui/avatar';

export default () => (
<Avatar
name="Jane Doe"
overrides={{
Avatar: {border: '2px solid blue'}
}}
size="scale1000"
src="https://img-may-not-exist.jpg"
/>
);
```

## Exports

* `Avatar`
* `StatefulAvatar`
* `StyledAvatar`

## `Avatar` API

* `name: string` - Required
Defines an alternative text description of the image.
* `overrides: {}` - Optional
* `Avatar: ?React.ComponentType` component to use for Avatar image styling
* `size: string` - Optional. Defaults to `scale1000`
Defines the width of the image. Should be an option from the $theme.sizing list otherwise, will use default.
* `src: string` - Required
Image to display.

## `StatefulAvatarContainer` API

* All props of a `Avatar` component. Handles displaying fallback color if provided src image fails to load.

## Presentational components props API

These properties are passed to every presentational (styled) component that is exported:

* `$size: string`
Sets img width. Provided value should map to an option in $theme.sizing. If not found, defaults to `scale1000`.

## Accessibility

Top level `name` prop will be set on the `<img>` element as its `alt` attribute.

0 comments on commit 1a7a2b2

Please sign in to comment.