Feat: datatable prop to choose row size

This commit is contained in:
csrapr 2021-02-12 16:08:08 +00:00 committed by Josh Harvey
parent 2663f0b4a8
commit 5fd1974242
4 changed files with 12 additions and 4 deletions

View file

@ -53,7 +53,6 @@ const Td = ({
[classes.size]: !header, [classes.size]: !header,
[classes.bold]: !header && bold [classes.bold]: !header && bold
} }
return <div className={classnames(className, classNames)}>{children}</div> return <div className={classnames(className, classNames)}>{children}</div>
} }

View file

@ -72,7 +72,11 @@ export default {
backgroundColor: tableErrorColor backgroundColor: tableErrorColor
}, },
mainContent: ({ size }) => { mainContent: ({ size }) => {
const minHeight = size === 'lg' ? 68 : 48 const sizes = {
sm: 34,
lg: 68
}
const minHeight = sizes[size] || 48
return { return {
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',

View file

@ -35,7 +35,8 @@ const Row = ({
expandRow, expandRow,
expWidth, expWidth,
expandable, expandable,
onClick onClick,
size
}) => { }) => {
const classes = useStyles() const classes = useStyles()
@ -45,11 +46,11 @@ const Row = ({
[classes.row]: true, [classes.row]: true,
[classes.expanded]: expanded [classes.expanded]: expanded
} }
return ( return (
<div className={classes.rowWrapper}> <div className={classes.rowWrapper}>
<div className={classnames({ [classes.before]: expanded && id !== 0 })}> <div className={classnames({ [classes.before]: expanded && id !== 0 })}>
<Tr <Tr
size={size}
className={classnames(trClasses)} className={classnames(trClasses)}
onClick={() => { onClick={() => {
expandable && expandRow(id) expandable && expandRow(id)
@ -97,6 +98,7 @@ const DataTable = ({
onClick, onClick,
loading, loading,
emptyText, emptyText,
rowSize,
...props ...props
}) => { }) => {
const [expanded, setExpanded] = useState(initialExpanded) const [expanded, setExpanded] = useState(initialExpanded)
@ -131,6 +133,7 @@ const DataTable = ({
<div ref={registerChild} style={style}> <div ref={registerChild} style={style}>
<Row <Row
width={width} width={width}
size={rowSize}
id={index} id={index}
expWidth={expWidth} expWidth={expWidth}
elements={elements} elements={elements}

View file

@ -74,6 +74,7 @@ const Transactions = () => {
} }
const getCustomerDisplayName = tx => { const getCustomerDisplayName = tx => {
console.log(tx)
if (tx.customerName) return tx.customerName if (tx.customerName) return tx.customerName
if (tx.customerIdCardData) return formatCustomerName(tx.customerIdCardData) if (tx.customerIdCardData) return formatCustomerName(tx.customerIdCardData)
return tx.customerPhone return tx.customerPhone
@ -172,6 +173,7 @@ const Transactions = () => {
data={R.path(['transactions'])(txResponse)} data={R.path(['transactions'])(txResponse)}
Details={DetailsRow} Details={DetailsRow}
expandable expandable
rowSize="sm"
/> />
</> </>
) )