Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #61 from zalmoxisus/cssfix
Browse files Browse the repository at this point in the history
Improve actions list styling
  • Loading branch information
zalmoxisus committed Jan 4, 2017
2 parents 3473260 + ae02d9a commit 78e58e6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
29 changes: 18 additions & 11 deletions src/ActionListRow.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component, PropTypes } from 'react';
import shouldPureComponentUpdate from 'react-pure-render/function';
import dateformat from 'dateformat';
import debounce from 'lodash.debounce';
import RightSlider from './RightSlider';

const BUTTON_SKIP = 'Skip';
Expand All @@ -23,14 +24,6 @@ export default class ActionListRow extends Component {

shouldComponentUpdate = shouldPureComponentUpdate

componentDidMount() {
document.addEventListener('mouseleave', this.handleMouseLeave);
}

componentWillUnmount() {
document.removeEventListener('mouseleave', this.handleMouseLeave);
}

render() {
const { styling, isSelected, action, isInitAction, onSelect,
timestamps, isSkipped } = this.props;
Expand All @@ -45,6 +38,7 @@ export default class ActionListRow extends Component {
<div onClick={onSelect}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
onMouseDown={this.handleMouseDown}
{...styling([
'actionListItem',
isSelected && 'actionListItemSelected',
Expand Down Expand Up @@ -89,11 +83,24 @@ export default class ActionListRow extends Component {
}
}

handleMouseEnter = () => {
this.setState({ hover: true });
handleMouseEnter = e => {
if (this.hover) return;
this.handleMouseEnterDebounced(e.buttons);
}

handleMouseEnterDebounced = debounce((buttons) => {
if (buttons) return;
this.setState({ hover: true });
}, 300)

handleMouseLeave = () => {
this.setState({ hover: false });
this.handleMouseEnterDebounced.cancel();
if (this.state.hover) this.setState({ hover: false });
}

handleMouseDown = e => {
if (e.target.className.indexOf('selectorButton') === 0) return;
if (this.handleMouseEnterDebounced) this.handleMouseEnterDebounced.cancel();
if (this.state.hover) this.setState({ hover: false });
}
}
5 changes: 3 additions & 2 deletions src/utils/createStylingFromTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ const getSheetFromColorMap = map => ({
actionListItemButtons: {
position: 'relative',
height: '20px',
'flex-basis': '25%',
display: 'flex'
},

Expand All @@ -144,7 +143,7 @@ const getSheetFromColorMap = map => ({
},

actionListItemName: {
overflow: 'auto',
overflow: 'hidden',
'text-overflow': 'ellipsis',
'line-height': '20px'
},
Expand Down Expand Up @@ -347,6 +346,7 @@ const getSheetFromColorMap = map => ({
},

rightSlider: {
'font-smoothing': 'subpixel-antialiased', // http://stackoverflow.com/a/21136111/4218591
position: 'absolute',
right: 0,
transform: 'translateX(150%)',
Expand All @@ -359,6 +359,7 @@ const getSheetFromColorMap = map => ({
},

rightSliderShown: {
position: 'static',
transform: 'translateX(0)',
},

Expand Down

0 comments on commit 78e58e6

Please sign in to comment.