Skip to content

Commit f56a73c

Browse files
committed
fix(ClassNames): Allow overriding Board, Lane and Card with custom classnames
#186
1 parent 07b3c7e commit f56a73c

File tree

6 files changed

+298
-291
lines changed

6 files changed

+298
-291
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"homepage": "https://github.com/rcdexta/react-trello",
4141
"dependencies": {
4242
"@terebentina/react-popover": "^2.0.0",
43+
"classnames": "^2.2.6",
4344
"immutability-helper": "^2.8.1",
4445
"lodash": "^4.17.11",
4546
"prop-types": "^15.6.2",

src/components/Board.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {Component} from 'react'
22
import BoardContainer from './BoardContainer'
33
import {Provider} from 'react-redux'
4+
import classNames from 'classnames'
45
import {applyMiddleware, createStore} from 'redux'
56
import boardReducer from '../reducers/BoardReducer'
67
import logger from 'redux-logger'
@@ -22,11 +23,12 @@ export default class Board extends Component {
2223
}
2324

2425
render() {
26+
const allClassNames = classNames('react-trello-board', this.props.className || '')
2527
return (
2628
<Provider store={this.store}>
2729
<>
2830
<GlobalStyle />
29-
<BoardContainer className="react-trello-board" {...this.props} id={this.id} />
31+
<BoardContainer className={allClassNames} {...this.props} id={this.id} />
3032
</>
3133
</Provider>
3234
)

src/components/Card.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types'
33
import {CardHeader, CardRightContent, CardTitle, Detail, Footer, MovableCardWrapper} from '../styles/Base'
44
import Tag from './Tag'
55
import DeleteButton from './widgets/DeleteButton'
6+
import classNames from 'classnames'
67

78
class Card extends Component {
89
removeCard = e => {
@@ -40,9 +41,10 @@ class Card extends Component {
4041
render() {
4142
const {id, cardStyle, editable, hideCardDeleteIcon, customCardLayout, dragStyle, onDelete, ...otherProps} = this.props
4243
const style = customCardLayout ? {...cardStyle, padding: 0} : cardStyle
44+
const allClassNames = classNames('react-trello-board', this.props.className || '')
4345
return (
4446
<MovableCardWrapper
45-
className="react-trello-card"
47+
className={allClassNames}
4648
key={id}
4749
data-id={id}
4850
style={{

src/components/Lane.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
LaneMenuTitle,
2626
MenuButton
2727
} from '../styles/Elements'
28+
import classNames from 'classnames'
2829

2930
class Lane extends Component {
3031
state = {
@@ -263,8 +264,9 @@ class Lane extends Component {
263264
render() {
264265
const {loading, isDraggingOver} = this.state
265266
const {id, onLaneClick, onLaneScroll, onCardClick, onCardAdd, onCardDelete, ...otherProps} = this.props
267+
const allClassNames = classNames('react-trello-board', this.props.className || '')
266268
return (
267-
<Section {...otherProps} key={id} onClick={() => onLaneClick && onLaneClick(id)} draggable={false} className="react-trello-lane">
269+
<Section {...otherProps} key={id} onClick={() => onLaneClick && onLaneClick(id)} draggable={false} className={allClassNames}>
268270
{this.renderHeader()}
269271
{this.renderDragContainer(isDraggingOver)}
270272
{loading && <Loader />}

0 commit comments

Comments
 (0)