You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-wallet/src/js/views/Device/views/Account/components/Send/components/CoinSelectOption.js

51 lines
1.3 KiB

/* @flow */
import * as React from 'react';
type Props = {
children: React.Node,
className: string,
isDisabled: boolean,
isFocused: boolean,
isSelected: boolean,
onFocus: Function,
onSelect: Function,
option: any,
}
export default class CoinSelectOption extends React.Component<Props> {
constructor(props: Props) {
super(props);
}
handleMouseDown(event: MouseEvent) {
event.preventDefault();
event.stopPropagation();
this.props.onSelect(this.props.option, event);
}
handleMouseEnter(event: MouseEvent) {
this.props.onFocus(this.props.option, event);
}
handleMouseMove(event: MouseEvent) {
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>
);
}
}