-
Notifications
You must be signed in to change notification settings - Fork 829
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(avatar): avatar component rfc (#534)
* feat: avatar component rfc * fix: provide more a11y info regarding name prop * fix: removes srcFallback prop
- Loading branch information
1 parent
c8efbf0
commit 1a7a2b2
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |