1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-15 12:59:09 +00:00
trezor-wallet/src/js/components/wallet/account/send/CoinSelectOption.js

49 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-02-20 09:30:36 +00:00
/* @flow */
'use strict';
2018-04-16 21:19:50 +00:00
import * as React from 'react';
type Props = {
children: React.Node,
className: string,
isDisabled: boolean,
isFocused: boolean,
isSelected: boolean,
onFocus: Function,
onSelect: Function,
option: any,
}
2018-02-20 09:30:36 +00:00
2018-04-16 21:19:50 +00:00
export default class CoinSelectOption extends React.Component<Props> {
constructor(props: Props) {
2018-02-20 09:30:36 +00:00
super(props);
}
2018-04-16 21:19:50 +00:00
handleMouseDown(event: MouseEvent) {
2018-02-20 09:30:36 +00:00
event.preventDefault();
event.stopPropagation();
this.props.onSelect(this.props.option, event);
}
2018-04-16 21:19:50 +00:00
handleMouseEnter(event: MouseEvent) {
2018-02-20 09:30:36 +00:00
this.props.onFocus(this.props.option, event);
}
2018-04-16 21:19:50 +00:00
handleMouseMove(event: MouseEvent) {
2018-02-20 09:30:36 +00:00
if (this.props.isFocused) return;
this.props.onFocus(this.props.option, event);
}
render() {
const css = `${this.props.className} ${this.props.option.value}`;
return (
<div className={ css }
onMouseDown={ this.handleMouseDown.bind(this) }
onMouseEnter={ this.handleMouseEnter.bind(this) }
onMouseMove={ this.handleMouseMove.bind(this) }
title={ this.props.option.label }>
<span>{ this.props.children }</span>
</div>
);
}
2018-04-16 21:19:50 +00:00
}