Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject classes into rows #112

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"[javascript]": {
"editor.formatOnSave": false
},
"[javascriptreact]": {
"editor.formatOnSave": false
},
"editor.formatOnSave": true,
"editor.detectIndentation": false,
"editor.tabSize": 2,
Expand Down
8 changes: 5 additions & 3 deletions src/Components/DataRow.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'

class DataRow extends Component {
static noop () {
Expand All @@ -13,15 +14,15 @@ class DataRow extends Component {
}

render () {
const { row, fields, onClick, onMouseUp, onMouseDown, onContextMenu, rowIsActive } = this.props
const { row, fields, onClick, onMouseUp, onMouseDown, onContextMenu, rowIsActive, className } = this.props

return (
<tr
onClick={e => onClick(e, row)}
onMouseUp={e => onMouseUp(e, row)}
onMouseDown={e => onMouseDown(e, row)}
onContextMenu={e => onContextMenu(e, row)}
className={rowIsActive(row) ? 'table-active' : null}
className={classNames(className, { 'table-active': rowIsActive(row) })}
>
{this.renderCheckboxCell()}
{fields.map(field => this.renderCell(field, row))}
Expand Down Expand Up @@ -234,7 +235,8 @@ DataRow.propTypes = {
index: PropTypes.number.isRequired,
fields: PropTypes.array,
rowIsActive: PropTypes.bool,
disableCheckbox: PropTypes.bool
disableCheckbox: PropTypes.bool,
className: PropTypes.string
}

export default DataRow
Loading