Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | import React from 'react'
import { User } from 'client/types/crowi'
import { CommonProps } from 'client/types/component'
type Props = CommonProps & {
user: User | undefined
size: string
}
// TODO UserComponent?
export default class UserPicture extends React.Component<Props> {
static defaultProps = {
user: {},
size: null,
}
getUserPicture(user: User | undefined) {
// from swig.setFilter('picture', function(user)
if (user && user.image && user.image != '/images/userpicture.png') {
return user.image
}
return '/images/userpicture.png'
}
getClassName() {
const className = this.props.className ? [] : ([] as string[])
className.push('picture')
className.push('picture-rounded')
if (this.props.size) {
className.push('picture-' + this.props.size)
}
return className.join(' ')
}
render() {
const { user, size, className, ...props } = this.props
return <img src={this.getUserPicture(user)} alt={user ? user.username : ''} className={this.getClassName()} {...props} />
}
}
|