2020-08-17 15:07:16 -05:00
|
|
|
import React from 'react'
|
2020-08-17 15:59:29 -05:00
|
|
|
import PropTypes from 'prop-types'
|
2020-05-27 01:22:07 -04:00
|
|
|
import {
|
|
|
|
CX,
|
|
|
|
BREAKPOINT_EXTRA_SMALL,
|
|
|
|
} from '../constants'
|
|
|
|
import Responsive from '../features/ui/util/responsive_component'
|
2020-04-02 12:57:04 -04:00
|
|
|
import Button from './button'
|
|
|
|
import Text from './text'
|
2020-02-28 10:20:47 -05:00
|
|
|
|
2020-08-17 19:57:35 -05:00
|
|
|
class StatusActionBarItem extends React.PureComponent {
|
2020-02-28 10:20:47 -05:00
|
|
|
|
|
|
|
render() {
|
2020-03-24 23:08:43 -04:00
|
|
|
const {
|
|
|
|
title,
|
|
|
|
onClick,
|
|
|
|
icon,
|
|
|
|
active,
|
|
|
|
disabled,
|
2020-04-06 21:53:23 -04:00
|
|
|
buttonRef,
|
|
|
|
altTitle
|
2020-03-24 23:08:43 -04:00
|
|
|
} = this.props
|
2020-02-28 10:20:47 -05:00
|
|
|
|
2020-05-01 01:50:27 -04:00
|
|
|
const btnClasses = CX({
|
2020-08-18 15:43:06 -05:00
|
|
|
jcCenter: 1,
|
|
|
|
aiCenter: 1,
|
2020-06-14 12:33:00 -04:00
|
|
|
px10: 1,
|
2020-04-29 18:32:49 -04:00
|
|
|
bgSubtle_onHover: !disabled,
|
2020-02-28 10:20:47 -05:00
|
|
|
})
|
|
|
|
|
2020-05-01 01:50:27 -04:00
|
|
|
const iconClasses = CX({
|
2020-08-18 15:49:11 -05:00
|
|
|
d: 1,
|
2020-05-01 01:50:27 -04:00
|
|
|
inheritFill: 1,
|
|
|
|
mr10: !!title,
|
|
|
|
})
|
|
|
|
|
2020-04-02 12:57:04 -04:00
|
|
|
const color = active ? 'brand' : 'secondary'
|
|
|
|
const weight = active ? 'bold' : 'medium'
|
|
|
|
|
2020-02-28 10:20:47 -05:00
|
|
|
return (
|
2020-08-18 15:49:11 -05:00
|
|
|
<div className={[_s.d, _s.px5, _s.flexNormal].join(' ')}>
|
2020-04-02 12:57:04 -04:00
|
|
|
<Button
|
2020-04-23 02:13:29 -04:00
|
|
|
isBlock
|
2020-04-02 12:57:04 -04:00
|
|
|
radiusSmall
|
|
|
|
backgroundColor='none'
|
2020-04-06 21:53:23 -04:00
|
|
|
title={altTitle}
|
2020-04-02 12:57:04 -04:00
|
|
|
color={color}
|
|
|
|
buttonRef={buttonRef}
|
2020-02-28 10:20:47 -05:00
|
|
|
className={btnClasses}
|
|
|
|
onClick={onClick}
|
2020-04-23 02:13:29 -04:00
|
|
|
isDisabled={disabled}
|
2020-04-02 12:57:04 -04:00
|
|
|
icon={icon}
|
2020-06-14 12:33:00 -04:00
|
|
|
iconSize='16px'
|
2020-05-01 01:50:27 -04:00
|
|
|
iconClassName={iconClasses}
|
|
|
|
>
|
|
|
|
{
|
|
|
|
!!title &&
|
2020-05-27 01:22:07 -04:00
|
|
|
<Responsive min={BREAKPOINT_EXTRA_SMALL}>
|
|
|
|
<Text color='inherit' size='small' weight={weight}>
|
|
|
|
{title}
|
|
|
|
</Text>
|
|
|
|
</Responsive>
|
2020-05-01 01:50:27 -04:00
|
|
|
}
|
2020-04-02 12:57:04 -04:00
|
|
|
</Button>
|
2020-02-28 10:20:47 -05:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2020-05-14 22:31:24 -04:00
|
|
|
|
2020-08-17 19:57:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusActionBarItem.propTypes = {
|
|
|
|
title: PropTypes.string.isRequired,
|
|
|
|
altTitle: PropTypes.string,
|
|
|
|
onClick: PropTypes.func.isRequired,
|
|
|
|
icon: PropTypes.string.isRequired,
|
|
|
|
active: PropTypes.bool,
|
|
|
|
disabled: PropTypes.bool,
|
|
|
|
buttonRef: PropTypes.oneOf([
|
|
|
|
PropTypes.func,
|
|
|
|
PropTypes.node,
|
|
|
|
]),
|
|
|
|
}
|
|
|
|
|
|
|
|
export default StatusActionBarItem
|