diff --git a/components/avatar/Avatar.js b/components/avatar/Avatar.js index f3ed1b70..f6813b69 100644 --- a/components/avatar/Avatar.js +++ b/components/avatar/Avatar.js @@ -1,24 +1,27 @@ import React, {PropTypes} from 'react'; +import { themr } from 'react-css-themr'; import FontIcon from '../font_icon'; -import style from './style'; -const Avatar = ({children, className, icon, image, title, ...other}) => { - return ( -
- {children} - {typeof image === 'string' ? : image} - {typeof icon === 'string' ? : icon} - {title ? {title[0]} : null} -
- ); -}; +const Avatar = ({children, className, icon, image, theme, title, ...other}) => ( +
+ {children} + {typeof image === 'string' ? : image} + {typeof icon === 'string' ? : icon} + {title ? {title[0]} : null} +
+); Avatar.propTypes = { children: PropTypes.node, className: PropTypes.string, icon: PropTypes.oneOfType([PropTypes.string, PropTypes.element]), image: PropTypes.oneOfType([PropTypes.string, PropTypes.element]), + theme: React.PropTypes.shape({ + avatar: React.PropTypes.string.isRequired, + image: React.PropTypes.string.isRequired, + letter: React.PropTypes.string.isRequired + }), title: PropTypes.string }; -export default Avatar; +export default themr('ToolboxAvatar')(Avatar); diff --git a/components/avatar/readme.md b/components/avatar/readme.md index c7a8b64b..031bff8f 100644 --- a/components/avatar/readme.md +++ b/components/avatar/readme.md @@ -5,6 +5,7 @@ Avatars can be used to represent people. This offer users the ability to persona ```jsx import Avatar from 'react-toolbox/lib/avatar'; +import theme from 'react-toolbox/lib/avatar/theme'; const GithubIcon = () => ( @@ -14,11 +15,11 @@ const GithubIcon = () => ( const AvatarTest = () => (
- - }/> - - - + + } theme={theme} /> + + +
); ``` @@ -32,3 +33,14 @@ const AvatarTest = () => ( | `icon` | `String` or `Element` | | A key to identify an Icon from Material Design Icons or a custom Icon Element.| | `image` | `String` or `Element` | | An image source or an image element. | | `title` | `String` | `''` | A title for the image. If no image is provided, the first letter will be displayed as the avatar. | +| `theme` | `Object` | `null` | Classnames object defining the component style.| + +## Theming + +You can take a look to the `_config.scss` variables. The theme should implement the following interface: + +| Name | Description| +|:---------|:-----------| +| `avatar` | Root class.| +| `image` | Used for the image if the avatar has image.| +| `letter` | Used for the letter in case the avatar has no image.| diff --git a/components/avatar/style.scss b/components/avatar/theme.scss similarity index 96% rename from components/avatar/style.scss rename to components/avatar/theme.scss index 29e796d3..714cc2f3 100644 --- a/components/avatar/style.scss +++ b/components/avatar/theme.scss @@ -10,6 +10,7 @@ font-size: $avatar-font-size; color: $avatar-color; text-align: center; + vertical-align: middle; background-color: $avatar-background; border-radius: 50%; > svg { diff --git a/spec/theme.js b/spec/theme.js index be42f46e..28288b53 100644 --- a/spec/theme.js +++ b/spec/theme.js @@ -1,3 +1,7 @@ import ToolboxAppBar from '../components/app_bar/theme.scss'; +import ToolboxAvatar from '../components/avatar/theme.scss'; -export default { ToolboxAppBar }; +export default { + ToolboxAppBar, + ToolboxAvatar +};