diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-07-02 05:34:50 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-07-02 05:51:02 +0800 |
commit | 5a7908984e118f2babf7c0680bf17afa148f5122 (patch) | |
tree | e1208cef885a84b7f19274a3092af18ed9f08d4c /packages/website/ts/components/ui | |
parent | 955fdf5d13945fc7267e8ce0cc1f6016c57f3b72 (diff) | |
download | dexon-sol-tools-5a7908984e118f2babf7c0680bf17afa148f5122.tar dexon-sol-tools-5a7908984e118f2babf7c0680bf17afa148f5122.tar.gz dexon-sol-tools-5a7908984e118f2babf7c0680bf17afa148f5122.tar.bz2 dexon-sol-tools-5a7908984e118f2babf7c0680bf17afa148f5122.tar.lz dexon-sol-tools-5a7908984e118f2babf7c0680bf17afa148f5122.tar.xz dexon-sol-tools-5a7908984e118f2babf7c0680bf17afa148f5122.tar.zst dexon-sol-tools-5a7908984e118f2babf7c0680bf17afa148f5122.zip |
Consolidate logic for common menu items
Diffstat (limited to 'packages/website/ts/components/ui')
-rw-r--r-- | packages/website/ts/components/ui/simple_menu.tsx | 66 |
1 files changed, 56 insertions, 10 deletions
diff --git a/packages/website/ts/components/ui/simple_menu.tsx b/packages/website/ts/components/ui/simple_menu.tsx index 22414d101..52d97b1ea 100644 --- a/packages/website/ts/components/ui/simple_menu.tsx +++ b/packages/website/ts/components/ui/simple_menu.tsx @@ -1,9 +1,12 @@ import * as _ from 'lodash'; import * as React from 'react'; +import * as CopyToClipboard from 'react-copy-to-clipboard'; +import { Link } from 'react-router-dom'; import { Container } from 'ts/components/ui/container'; import { Text } from 'ts/components/ui/text'; import { colors } from 'ts/style/colors'; +import { WebsitePaths } from 'ts/types'; export interface SimpleMenuProps { minWidth?: number | string; @@ -23,18 +26,61 @@ export const SimpleMenu: React.StatelessComponent<SimpleMenuProps> = ({ children ); }; +SimpleMenu.defaultProps = { + minWidth: '220px', +}; + export interface SimpleMenuItemProps { - text: string; + displayText: string; onClick?: () => void; } -export const SimpleMenuItem: React.StatelessComponent<SimpleMenuItemProps> = ({ text, onClick }) => ( - <Container marginTop="16px" className="flex flex-column"> - <Text fontSize="14px" fontColor={colors.darkGrey} onClick={onClick} hoverColor={colors.mediumBlue}> - {text} - </Text> - </Container> -); +export const SimpleMenuItem: React.StatelessComponent<SimpleMenuItemProps> = ({ displayText, onClick }) => { + // Falling back to _.noop for onclick retains the hovering effect + return ( + <Container marginTop="16px" className="flex flex-column"> + <Text + fontSize="14px" + fontColor={colors.darkGrey} + onClick={onClick || _.noop} + hoverColor={colors.mediumBlue} + > + {displayText} + </Text> + </Container> + ); +}; -SimpleMenu.defaultProps = { - minWidth: '220px', +export interface CopyAddressSimpleMenuItemProps { + userAddress: string; + onClick?: () => void; +} +export const CopyAddressSimpleMenuItem: React.StatelessComponent<CopyAddressSimpleMenuItemProps> = ({ + userAddress, + onClick, +}) => { + return ( + <CopyToClipboard text={userAddress}> + <SimpleMenuItem displayText="Copy Address to Clipboard" onClick={onClick} /> + </CopyToClipboard> + ); +}; + +export interface LinkSimpleMenuItemProps { + onClick?: () => void; +} +export const GoToAccountManagementSimpleMenuItem: React.StatelessComponent<LinkSimpleMenuItemProps> = ({ onClick }) => { + return ( + <Link to={`${WebsitePaths.Portal}/account`} style={{ textDecoration: 'none' }}> + <SimpleMenuItem displayText="Manage Account..." onClick={_.noop} /> + </Link> + ); +}; + +export interface DifferentWalletSimpleMenuItemProps { + onClick?: () => void; +} +export const DifferentWalletSimpleMenuItem: React.StatelessComponent<DifferentWalletSimpleMenuItemProps> = ({ + onClick, +}) => { + return <SimpleMenuItem displayText="Use a Different Wallet..." onClick={onClick} />; }; |