Skip to content

Commit e07e4a6

Browse files
committed
fix(Styling with classnames): All component styles can be overridden with css classnames. Also, exam
#123
1 parent be53dac commit e07e4a6

9 files changed

Lines changed: 61 additions & 21 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ eventBus.publish({type: 'UPDATE_LANES', lanes: newLaneData})
146146

147147
The first event in the above example will move the card `Buy Milk` from the planned lane to completed lane. We expect that this library can be wired to a backend push api that can alter the state of the board in realtime.
148148

149+
### Styling
150+
151+
There are two ways to apply styles to the library components including `Board`, `Lane` or `Card`:
152+
153+
* Use the predefined css classnames attached to these elements that go by `.react-trello-lane`, `.react-trello-card`, `.react-trello-board`
154+
* You can also pass custom style attributes as part of data. Refer to the storybook for examples
155+
149156
### Custom Card Styling
150157

151158
You can completely customize the look-and-feel of each card in any lane by passing in a custom component as child to the Board as seen below:

src/components/Board.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class Board extends Component {
2323
render() {
2424
return (
2525
<Provider store={this.store}>
26-
<BoardContainer {...this.props} id={this.id}/>
26+
<BoardContainer className="react-trello-board" {...this.props} id={this.id}/>
2727
</Provider>
2828
)
2929
}

src/components/Card.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Card extends Component {
3636
const style = customCardLayout ? {...cardStyle, padding: 0} : cardStyle
3737
return (
3838
<MovableCardWrapper
39+
className="react-trello-card"
3940
key={id}
4041
data-id={id}
4142
style={{

src/components/Lane.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ class Lane extends Component {
246246
const {loading, isDraggingOver} = this.state
247247
const {id, onLaneClick, ...otherProps} = this.props
248248
return (
249-
<Section {...otherProps} key={id} onClick={() => onLaneClick && onLaneClick(id)} draggable={false}>
249+
<Section {...otherProps} key={id} onClick={() => onLaneClick && onLaneClick(id)} draggable={false} className="react-trello-lane">
250250
{this.renderHeader()}
251251
{this.renderDragContainer(isDraggingOver)}
252252
{loading && <Loader />}

src/styles/Base.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,14 @@ export const CardWrapper = styled.article`
108108
export const MovableCardWrapper = styled(CardWrapper)`
109109
&:hover {
110110
background-color: #f0f0f0;
111+
color: #000
111112
}
112113
`
113114

114115
export const CardHeader = styled(Header)`
115116
border-bottom: 1px solid #eee;
116117
padding-bottom: 6px;
118+
color: #000;
117119
`
118120

119121
export const CardTitle = styled(Title)`

stories/BoardStyling.story.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

stories/Styling.story.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React from 'react'
2+
import {withInfo} from '@storybook/addon-info'
3+
import {storiesOf} from '@storybook/react'
4+
5+
import Board from '../src'
6+
7+
import './board.css'
8+
9+
const data = require('./data/base.json')
10+
11+
storiesOf('Styling', module).add(
12+
'Board Styling',
13+
withInfo('Change the background and other css styles for the board container')(() => (
14+
<Board data={data} style={{padding: '30px 20px', fontFamily: 'Verdana'}} className="boardContainer" />
15+
))
16+
)
17+
18+
const dataWithLaneStyles = {
19+
lanes: [
20+
{
21+
id: 'PLANNED',
22+
title: 'Planned Tasks',
23+
label: '20/70',
24+
style: {width: 280, backgroundColor: '#3179ba', color: '#fff', boxShadow: '2px 2px 4px 0px rgba(0,0,0,0.75)'},
25+
cards: [
26+
{
27+
id: 'Milk',
28+
title: 'Buy milk',
29+
label: '15 mins',
30+
description: '2 Gallons of milk at the Deli store'
31+
},
32+
{
33+
id: 'Plan2',
34+
title: 'Dispose Garbage',
35+
label: '10 mins',
36+
description: 'Sort out recyclable and waste as needed'
37+
}
38+
]
39+
}
40+
]
41+
}
42+
43+
storiesOf('Styling', module).add(
44+
'Lane Styling',
45+
withInfo('Change the look and feel of the lane')(() => <Board data={dataWithLaneStyles} style={{backgroundColor: '#eee'}} />)
46+
)

stories/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import './Base.story'
2+
import './DragDrop.story'
23
import './Pagination.story'
34
import './Interactions.story'
45
import './Sort.story'
56
import './Realtime.story'
6-
import './DragDrop.story'
77
import './CollapsibleLanes.story'
88
import './PaginationAndEvents.story'
99
import './Tags.story'
1010
import './CustomCardStyling.story'
1111
import './CustomCardWithDrag.story'
12-
import './CustomLaneStyling.story'
13-
import './BoardStyling.story'
12+
import './CustomLaneTemplates.story'
13+
import './Styling.story'
1414
import './AsyncLoad.story'
1515
import './RestrictedLanes.story'
1616
import './EditableBoard.story'

0 commit comments

Comments
 (0)