gab-social/app/javascript/gabsocial/components/progress_bar.js

59 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-03-26 03:11:32 +00:00
import classNames from 'classnames/bind'
import Button from './button'
2020-02-19 23:57:07 +00:00
import Text from './text'
2020-03-26 03:11:32 +00:00
const cx = classNames.bind(_s)
2020-02-05 22:45:48 +00:00
export default class ProgressBar extends PureComponent {
static propTypes = {
progress: PropTypes.number,
2020-03-26 03:11:32 +00:00
small: PropTypes.bool,
title: PropTypes.string,
2020-02-05 22:45:48 +00:00
}
render() {
2020-03-26 03:11:32 +00:00
const {
progress,
small,
title,
href
} = this.props
2020-02-05 22:45:48 +00:00
const completed = Math.min(parseFloat(progress), 100)
const style = {
width: `${completed}%`,
}
2020-03-26 03:11:32 +00:00
const containerOptions = {
href,
className: cx({
default: 1,
backgroundPanel: !small,
backgroundSubtle2: small,
noUnderline: 1,
circle: 1,
overflowHidden: 1,
cursorPointer: 1,
height22PX: !small,
height4PX: small,
}),
}
2020-02-05 22:45:48 +00:00
return (
2020-03-26 03:11:32 +00:00
<Button
noClasses
{...containerOptions}
>
<div className={[_s.default, _s.backgroundColorBrandDark, _s.circle, _s.height100PC].join(' ')} style={style} />
<div className={[_s.default, _s.positionAbsolute, _s.width100PC, _s.height100PC, _s.alignItemsCenter, _s.justifyContentCenter].join(' ')}>
{
!!title &&
<Text size='small' weight='bold' color='white'>
{title}
</Text>
}
2020-02-19 23:57:07 +00:00
</div>
2020-03-26 03:11:32 +00:00
</Button>
2020-02-05 22:45:48 +00:00
)
}
}