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

65 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-02-28 15:20:47 +00:00
import classNames from 'classnames/bind'
2020-04-02 17:57:04 +01:00
import Button from './button'
2020-02-28 15:20:47 +00:00
import Icon from './icon'
2020-04-02 17:57:04 +01:00
import Text from './text'
2020-02-28 15:20:47 +00:00
const cx = classNames.bind(_s)
export default class StatusActionBarItem extends PureComponent {
static propTypes = {
title: PropTypes.string.isRequired,
2020-04-07 02:53:23 +01:00
altTitle: PropTypes.string,
2020-02-28 15:20:47 +00:00
onClick: PropTypes.func.isRequired,
icon: PropTypes.string.isRequired,
active: PropTypes.bool,
disabled: PropTypes.bool,
2020-03-25 03:08:43 +00:00
buttonRef: PropTypes.node,
2020-02-28 15:20:47 +00:00
}
render() {
2020-03-25 03:08:43 +00:00
const {
title,
onClick,
icon,
active,
disabled,
2020-04-07 02:53:23 +01:00
buttonRef,
altTitle
2020-03-25 03:08:43 +00:00
} = this.props
2020-02-28 15:20:47 +00:00
const btnClasses = cx({
justifyContentCenter: 1,
alignItemsCenter: 1,
2020-03-11 23:56:18 +00:00
px10: 1,
2020-04-07 02:53:23 +01:00
backgroundSubtle_onHover: !disabled,
2020-02-28 15:20:47 +00:00
})
2020-04-02 17:57:04 +01:00
const color = active ? 'brand' : 'secondary'
const weight = active ? 'bold' : 'medium'
2020-02-28 15:20:47 +00:00
return (
2020-04-02 17:57:04 +01:00
<div className={[_s.default, _s.flexNormal, _s.px5].join(' ')}>
<Button
block
radiusSmall
backgroundColor='none'
2020-04-07 02:53:23 +01:00
title={altTitle}
2020-04-02 17:57:04 +01:00
color={color}
buttonRef={buttonRef}
2020-02-28 15:20:47 +00:00
className={btnClasses}
onClick={onClick}
active={active}
disabled={disabled}
2020-04-02 17:57:04 +01:00
icon={icon}
iconWidth='16px'
iconHeight='16px'
iconClassName={[_s.default, _s.mr10, _s.inheritFill].join(' ')}
2020-02-28 15:20:47 +00:00
>
2020-04-02 17:57:04 +01:00
<Text color='inherit' size='small' weight={weight}>
{title}
</Text>
</Button>
2020-02-28 15:20:47 +00:00
</div>
)
}
}