Skip to content

Commit

Permalink
add avatar background
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego VIeira committed Dec 8, 2018
1 parent eb2d572 commit c08d223
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default class MyComponent extends React.Component {
<Avatar
style={{width: '100px', height: '100px'}}
avatarStyle='Circle'
avatarBackground='#65C9FF'
topType='LongHairMiaWallace'
accessoriesType='Prescription02'
hairColor='BrownDark'
Expand Down
5 changes: 3 additions & 2 deletions src/avatar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ export enum AvatarStyle {
export interface Props {
avatarStyle: AvatarStyle
style?: React.CSSProperties
avatarBackground?: string
}

export default class Avatar extends React.Component<Props> {
render () {
const { avatarStyle } = this.props
const { avatarStyle, avatarBackground } = this.props
const circle = avatarStyle === AvatarStyle.Circle
return (
<svg
Expand Down Expand Up @@ -68,7 +69,7 @@ export default class Avatar extends React.Component<Props> {
<g
id='Color/Palette/Blue-01'
mask='url(#mask-2)'
fill='#65C9FF'>
fill={avatarBackground ? avatarBackground : '#65C9FF'}>
<rect id='🖍Color' x='0' y='0' width='240' height='240' />
</g>
</g>
Expand Down
11 changes: 6 additions & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { OptionContext, allOptions } from './options'
export { default as Avatar, AvatarStyle } from './avatar'
export { Option, OptionContext, allOptions } from './options'

import {default as PieceComponent} from './avatar/piece';
import { default as PieceComponent } from './avatar/piece'

export interface Props {
avatarStyle: string
Expand All @@ -24,8 +24,9 @@ export interface Props {
eyebrowType?: string
mouthType?: string
skinColor?: string
pieceType?:string
pieceSize?:string
pieceType?: string
pieceSize?: string
avatarBackground?: string
}

export default class AvatarComponent extends React.Component<Props> {
Expand All @@ -47,8 +48,8 @@ export default class AvatarComponent extends React.Component<Props> {
}

render () {
const { avatarStyle, style } = this.props
return <Avatar avatarStyle={avatarStyle as AvatarStyle} style={style} />
const { avatarStyle, style, avatarBackground } = this.props
return <Avatar avatarStyle={avatarStyle as AvatarStyle} style={style} avatarBackground={avatarBackground} />
}

private updateOptionContext (props: Props) {
Expand Down

0 comments on commit c08d223

Please sign in to comment.