2020-12-06 04:47:48 +00:00
|
|
|
import React from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
2020-12-09 04:15:33 +00:00
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import { deleteDeckColumnAtIndex } from '../actions/deck'
|
2020-12-06 04:47:48 +00:00
|
|
|
import Icon from './icon'
|
|
|
|
import Text from './text'
|
|
|
|
import Button from './button'
|
|
|
|
|
|
|
|
class DeckColumnHeader extends React.PureComponent {
|
|
|
|
|
2020-12-09 04:15:33 +00:00
|
|
|
handleClickDelete = () => {
|
|
|
|
this.props.dispatch(deleteDeckColumnAtIndex(this.props.index))
|
|
|
|
}
|
|
|
|
|
|
|
|
handleClickRefresh = () => {
|
2020-12-16 22:29:06 +00:00
|
|
|
const { onRefresh } = this.props
|
|
|
|
if (!!onRefresh) onRefresh()
|
2020-12-09 04:15:33 +00:00
|
|
|
}
|
|
|
|
|
2020-12-06 04:47:48 +00:00
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
title,
|
|
|
|
subtitle,
|
|
|
|
icon,
|
|
|
|
children,
|
2020-12-09 04:57:51 +00:00
|
|
|
noButtons,
|
2020-12-16 22:29:06 +00:00
|
|
|
noRefresh,
|
2020-12-06 04:47:48 +00:00
|
|
|
} = this.props
|
|
|
|
|
|
|
|
return (
|
2020-12-21 18:25:05 +00:00
|
|
|
<div data-sort-header className={[_s.d, _s.w100PC, _s.overflowHidden, _s.flexRow, _s.aiCenter, _s.h60PX, _s.px15, _s.py10, _s.borderBottom1PX, _s.borderColorSecondary, _s.bgPrimary].join(' ')}>
|
2020-12-16 22:29:06 +00:00
|
|
|
<div data-sort-header className={[_s.d, _s.flexRow, _s.mr15, _s.cursorEWResize].join(' ')}>
|
|
|
|
<span className={[_s.d, _s.w1PX, _s.h24PX, _s.mr2, _s.bgSecondary].join(' ')} />
|
|
|
|
<span className={[_s.d, _s.w1PX, _s.h24PX, _s.mr2, _s.bgSecondary].join(' ')} />
|
|
|
|
<span className={[_s.d, _s.w1PX, _s.h24PX, _s.bgSecondary].join(' ')} />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{ !!icon && <Icon id={icon} className={[_s.cPrimary, _s.mr15].join(' ')} size='18px' /> }
|
2020-12-21 18:25:05 +00:00
|
|
|
<div className={[_s.d, _s.flexRow, _s.aiEnd, _s.flexShrink1, _s.overflowHidden, _s.textOverflowEllipsis2].join(' ')}>
|
2020-12-09 04:15:33 +00:00
|
|
|
{ !!title && <Text size='extraLarge' weight='medium'>{title}</Text> }
|
|
|
|
{ !!subtitle && <Text className={_s.ml5} color='secondary'>{subtitle}</Text> }
|
2020-12-06 04:47:48 +00:00
|
|
|
</div>
|
2020-12-09 04:15:33 +00:00
|
|
|
{
|
2020-12-09 04:57:51 +00:00
|
|
|
!!title && !noButtons &&
|
2020-12-09 04:15:33 +00:00
|
|
|
<div className={[_s.d, _s.flexRow, _s.aiCenter, _s.mlAuto, _s.jcCenter].join(' ')}>
|
2020-12-16 22:29:06 +00:00
|
|
|
{
|
|
|
|
!noRefresh &&
|
|
|
|
<Button
|
|
|
|
isNarrow
|
|
|
|
noClasses
|
|
|
|
onClick={this.handleClickRefresh}
|
|
|
|
className={[_s.d, _s.mr5, _s.cursorPointer, _s.outlineNone, _s.bgTransparent, _s.px5, _s.py5].join(' ')}
|
|
|
|
iconClassName={_s.cSecondary}
|
|
|
|
icon='repost'
|
|
|
|
/>
|
|
|
|
}
|
2020-12-09 04:15:33 +00:00
|
|
|
<Button
|
|
|
|
isNarrow
|
|
|
|
noClasses
|
|
|
|
onClick={this.handleClickDelete}
|
|
|
|
className={[_s.d, _s.mr5, _s.cursorPointer, _s.outlineNone, _s.bgTransparent, _s.px5, _s.py5].join(' ')}
|
|
|
|
iconClassName={_s.cSecondary}
|
|
|
|
icon='trash'
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
}
|
2020-12-06 04:47:48 +00:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DeckColumnHeader.propTypes = {
|
|
|
|
title: PropTypes.string,
|
|
|
|
subtitle: PropTypes.string,
|
|
|
|
icon: PropTypes.string,
|
2020-12-09 04:15:33 +00:00
|
|
|
index: PropTypes.number,
|
2020-12-09 04:57:51 +00:00
|
|
|
noButtons: PropTypes.bool,
|
2020-12-16 22:29:06 +00:00
|
|
|
noRefresh: PropTypes.bool,
|
|
|
|
onRefresh: PropTypes.func,
|
2020-12-06 04:47:48 +00:00
|
|
|
}
|
|
|
|
|
2020-12-09 04:15:33 +00:00
|
|
|
export default connect()(DeckColumnHeader)
|