diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-10-20 00:18:43 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-10-20 00:19:37 +0800 |
commit | 6f2217570f0dd7060cf208da32b18c52c9798871 (patch) | |
tree | 0bd34b345ef58cc6156f700b93b44cd5f32ea420 /packages/website/ts/components/ui/custom_menu_item.tsx | |
parent | 91ca80b248ac75b0d8258dd4dfc7a6e0c36c572b (diff) | |
parent | 669ea191a5e34ec704851377ee5eedb03c2d1538 (diff) | |
download | dexon-0x-contracts-6f2217570f0dd7060cf208da32b18c52c9798871.tar.gz dexon-0x-contracts-6f2217570f0dd7060cf208da32b18c52c9798871.tar.zst dexon-0x-contracts-6f2217570f0dd7060cf208da32b18c52c9798871.zip |
Merge branch 'development' of https://github.com/0xProject/0x-monorepo into feature/instant/discharge
Diffstat (limited to 'packages/website/ts/components/ui/custom_menu_item.tsx')
-rw-r--r-- | packages/website/ts/components/ui/custom_menu_item.tsx | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/packages/website/ts/components/ui/custom_menu_item.tsx b/packages/website/ts/components/ui/custom_menu_item.tsx new file mode 100644 index 000000000..87ce32126 --- /dev/null +++ b/packages/website/ts/components/ui/custom_menu_item.tsx @@ -0,0 +1,50 @@ +import { Link } from '@0x/react-shared'; +import * as _ from 'lodash'; +import * as React from 'react'; + +interface CustomMenuItemProps { + to: string; + onClick?: () => void; + className?: string; +} + +interface CustomMenuItemState { + isHovering: boolean; +} + +export class CustomMenuItem extends React.Component<CustomMenuItemProps, CustomMenuItemState> { + public static defaultProps: Partial<CustomMenuItemProps> = { + onClick: _.noop.bind(_), + className: '', + }; + public constructor(props: CustomMenuItemProps) { + super(props); + this.state = { + isHovering: false, + }; + } + public render(): React.ReactNode { + const menuItemStyles = { + cursor: 'pointer', + opacity: this.state.isHovering ? 0.5 : 1, + }; + return ( + <Link to={this.props.to}> + <div + onClick={this.props.onClick.bind(this)} + className={`mx-auto ${this.props.className}`} + style={menuItemStyles} + onMouseEnter={this._onToggleHover.bind(this, true)} + onMouseLeave={this._onToggleHover.bind(this, false)} + > + {this.props.children} + </div> + </Link> + ); + } + private _onToggleHover(isHovering: boolean): void { + this.setState({ + isHovering, + }); + } +} |