-
Notifications
You must be signed in to change notification settings - Fork 378
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
Hover plugin #639
base: master
Are you sure you want to change the base?
Hover plugin #639
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { GRIDDLE_ROW_MOUSE_ENTER, GRIDDLE_ROW_MOUSE_LEAVE } from './constants'; | ||
|
||
export const rowMouseEnter = griddleKey => ({type: GRIDDLE_ROW_MOUSE_ENTER, griddleKey}); | ||
|
||
export const rowMouseLeave = () => ({type: GRIDDLE_ROW_MOUSE_LEAVE}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from 'react'; | ||
import compose from 'recompose/compose'; | ||
import { connect } from 'react-redux'; | ||
import { bindActionCreators } from 'redux'; | ||
|
||
import components from '../../components'; | ||
import { rowMouseEnter, rowMouseLeave } from './actions'; | ||
|
||
export const RowContainer = compose( | ||
connect( | ||
state => { | ||
return { | ||
hoveredRowKey: state.get('hoveredRowKey', null) | ||
}; | ||
}, | ||
(dispatch, {griddleKey}) => bindActionCreators({ | ||
focusIn: rowMouseEnter.bind(this, griddleKey), | ||
focusOut: rowMouseLeave | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As of #679, if these were |
||
}, dispatch) | ||
), | ||
components.RowContainer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than |
||
); | ||
|
||
export const Row = ({Cell, griddleKey, columnIds, style, className, focusIn, focusOut, hoveredRowKey}) => ( | ||
<tr | ||
key={griddleKey} | ||
style={style} | ||
className={className} | ||
onMouseEnter={focusIn} | ||
onMouseLeave={focusOut} | ||
> | ||
{ columnIds && columnIds.map(c => ( | ||
<Cell | ||
key={`${c}-${griddleKey}`} | ||
griddleKey={griddleKey} | ||
columnId={c} | ||
style={style} | ||
className={className} | ||
hoveredRowKey={hoveredRowKey} | ||
/> | ||
))} | ||
</tr> | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const GRIDDLE_ROW_MOUSE_ENTER = 'GRIDDLE_ROW_MOUSE_ENTER'; | ||
export const GRIDDLE_ROW_MOUSE_LEAVE = 'GRIDDLE_ROW_MOUSE_LEAVE'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as components from './components'; | ||
import * as reducer from './reducers'; | ||
|
||
export default { | ||
components, | ||
reducer | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const GRIDDLE_ROW_MOUSE_ENTER = (state, {griddleKey}) => | ||
state.set('hoveredRowKey', griddleKey); | ||
|
||
export const GRIDDLE_ROW_MOUSE_LEAVE = (state, action) => | ||
state.delete('hoveredRowKey'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely convinced it should be the plugin's responsibility to inject
hoveredRowKey
intoCell
(or anywhere). It seems to be an implementation detail of this demo. I'm more inclined to avoid customizingRow
altogether, lettingButtonsColumn
be connected instead: