Skip to content

Commit 02333a3

Browse files
committed
Updated ArrowKeyStepper.example to demonstrate how the concept of "focus" could be added to a Grid
1 parent 4e1383c commit 02333a3

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

source/ArrowKeyStepper/ArrowKeyStepper.example.css

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
border: 1px solid #e0e0e0;
33
}
44

5-
.EvenCell,
6-
.OddCell {
5+
.Cell {
76
height: 100%;
87
display: flex;
98
align-items: center;
109
justify-content: center;
10+
border-right: 1px solid #e0e0e0;
11+
border-bottom: 1px solid #e0e0e0;
1112
}
1213

13-
.OddCell {
14-
background-color: rgba(0, 0, 0, .1);
14+
.FocusedCell {
15+
background-color: #e0e0e0;
16+
font-weight: bold;
1517
}

source/ArrowKeyStepper/ArrowKeyStepper.example.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import ArrowKeyStepper from './ArrowKeyStepper'
66
import AutoSizer from '../AutoSizer'
77
import Grid from '../Grid'
88
import shouldPureComponentUpdate from 'react-pure-render/function'
9+
import cn from 'classnames'
910
import styles from './ArrowKeyStepper.example.css'
1011

1112
export default class ArrowKeyStepperExample extends Component {
@@ -61,7 +62,7 @@ export default class ArrowKeyStepperExample extends Component {
6162
columnsCount={100}
6263
height={200}
6364
onSectionRendered={onSectionRendered}
64-
renderCell={this._renderCell}
65+
renderCell={({ columnIndex, rowIndex }) => this._renderCell({ columnIndex, rowIndex, scrollToColumn, scrollToRow }) }
6566
rowHeight={this._getRowHeight}
6667
rowsCount={100}
6768
scrollToColumn={scrollToColumn}
@@ -85,10 +86,10 @@ export default class ArrowKeyStepperExample extends Component {
8586
return (1 + (index % 3)) * 30
8687
}
8788

88-
_renderCell ({ columnIndex, rowIndex }) {
89-
const className = rowIndex % 2 === 0
90-
? columnIndex % 2 === 0 ? styles.EvenCell : styles.OddCell
91-
: columnIndex % 2 !== 0 ? styles.EvenCell : styles.OddCell
89+
_renderCell ({ columnIndex, rowIndex, scrollToColumn, scrollToRow }) {
90+
const className = cn(styles.Cell, {
91+
[styles.FocusedCell]: columnIndex === scrollToColumn && rowIndex === scrollToRow
92+
})
9293

9394
return (
9495
<div className={className}>

0 commit comments

Comments
 (0)