Skip to content

Commit f98e58d

Browse files
committed
fix: Make lane header sticky when scrolling card content
#54
1 parent 2c5a0b4 commit f98e58d

3 files changed

Lines changed: 37 additions & 28 deletions

File tree

src/components/Lane.js

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import Loader from './Loader'
33
import PropTypes from 'prop-types'
44
import Card from './Card'
55
import {
6-
Section,
7-
Header,
8-
Title,
9-
RightContent,
10-
DraggableList,
11-
Placeholder,
12-
AddCardLink,
13-
LaneWrapper,
14-
ScrollableLane
15-
} from '../styles/Base'
6+
Section,
7+
Header,
8+
Title,
9+
RightContent,
10+
DraggableList,
11+
Placeholder,
12+
AddCardLink,
13+
LaneWrapper,
14+
ScrollableLane, LaneHeader,
15+
} from '../styles/Base';
1616
import {bindActionCreators} from 'redux'
1717
import {connect} from 'react-redux'
1818
import update from 'immutability-helper'
@@ -43,7 +43,7 @@ class Lane extends Component {
4343
onLaneScroll(nextPage, this.props.id).then(moreCards => {
4444
if (!moreCards || moreCards.length === 0) {
4545
// if no cards present, stop retrying until user action
46-
node.scrollTop = node.scrollTop - 50
46+
node.scrollTop = node.scrollTop - 100
4747
} else {
4848
this.props.actions.paginateLane({
4949
laneId: this.props.id,
@@ -64,10 +64,9 @@ class Lane extends Component {
6464
})
6565
}
6666

67-
laneDidMount = (node, dragReference) => {
67+
laneDidMount = (node) => {
6868
if (node) {
6969
node.addEventListener('scroll', this.handleScroll)
70-
dragReference(node)
7170
}
7271
}
7372

@@ -181,11 +180,11 @@ class Lane extends Component {
181180
))
182181

183182
return (
184-
<div>
183+
<ScrollableLane innerRef={this.laneDidMount}>
185184
<DraggableList>{cardList}</DraggableList>
186185
{editable && !addCardMode && this.renderAddCardLink()}
187186
{addCardMode && this.renderNewCard()}
188-
</div>
187+
</ScrollableLane>
189188
)
190189
}
191190

@@ -196,14 +195,14 @@ class Lane extends Component {
196195
} else {
197196
const {title, label, titleStyle, labelStyle} = this.props
198197
return (
199-
<Header>
198+
<LaneHeader>
200199
<Title style={titleStyle}>{title}</Title>
201200
{label && (
202201
<RightContent>
203202
<span style={labelStyle}>{label}</span>
204203
</RightContent>
205204
)}
206-
</Header>
205+
</LaneHeader>
207206
)
208207
}
209208
}
@@ -221,7 +220,7 @@ class Lane extends Component {
221220
{...otherProps}
222221
key={id}
223222
onClick={() => onLaneClick && onLaneClick(id)}
224-
innerRef={ref => this.laneDidMount(ref, dropProvided.innerRef)}
223+
innerRef={dropProvided.innerRef}
225224
isDraggingOver={isDraggingOver}
226225
{...dropProvided.draggableProps}>
227226
{this.renderHeader()}

src/styles/Base.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,34 @@ export const BoardDiv = styled.div`
2525
height: 100vh;
2626
`
2727

28+
export const Header = styled.header`
29+
margin-bottom: 10px;
30+
display: flex;
31+
flex-direction: row;
32+
align-items: flex-start;
33+
`
34+
2835
export const Section = styled.section`
2936
background-color: #e3e3e3;
3037
border-radius: 3px;
3138
margin: 5px 5px;
3239
position: relative;
3340
padding: 10px;
3441
min-width: 250px;
35-
height: auto;
3642
padding-bottom: ${props => (props.isDraggingOver ? '130px' : '30px')};
37-
max-height: 95%;
38-
overflow-y: auto;
43+
display: flex;
44+
height: auto;
45+
max-height: 90%;
46+
flex-direction: column;
3947
`
4048

41-
export const Header = styled.header`
42-
margin-bottom: 10px;
43-
display: flex;
44-
flex-direction: row;
45-
align-items: flex-start;
49+
export const LaneHeader = styled(Header)`
50+
margin-bottom: 10px;
51+
`
52+
53+
export const ScrollableLane = styled.div`
54+
flex: 1;
55+
overflow-y: auto;
4656
`
4757

4858
export const Title = styled.span`
@@ -60,7 +70,7 @@ export const RightContent = styled.span`
6070
`
6171

6272
export const DraggableList = styled.div`
63-
min-height: 10px;
73+
6474
`
6575

6676
export const CardWrapper = styled.article`

src/styles/Elements.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const DeleteWrapper = styled.div`
55
text-align: center;
66
position: absolute;
77
top: -8px;
8-
right: -8px;
8+
right: 0px;
99
`
1010

1111
export const DeleteIcon = styled.span`

0 commit comments

Comments
 (0)