fix: simplify Tooltip

This commit is contained in:
Mauricio Navarro Miranda 2020-08-20 03:42:33 -05:00 committed by Josh Harvey
parent e7805040f0
commit 5210e14a19
12 changed files with 16 additions and 29 deletions

View file

@ -1,9 +1,8 @@
import { makeStyles, ClickAwayListener } from '@material-ui/core' import { makeStyles, ClickAwayListener } from '@material-ui/core'
import classnames from 'classnames' import classnames from 'classnames'
import React, { useState, memo, cloneElement } from 'react' import React, { useState, memo } from 'react'
import Popper from 'src/components/Popper' import Popper from 'src/components/Popper'
import { ReactComponent as HelpIcon } from 'src/styling/icons/action/help/zodiac.svg'
const useStyles = makeStyles({ const useStyles = makeStyles({
transparentButton: { transparentButton: {
@ -26,7 +25,7 @@ const Tooltip = memo(
enableOver = false, enableOver = false,
enableClick = false, enableClick = false,
className, className,
element, Icon,
children, children,
width, width,
...props ...props
@ -50,22 +49,9 @@ const Tooltip = memo(
type={'button'} type={'button'}
className={classnames(className, classes.transparentButton)} className={classnames(className, classes.transparentButton)}
onPointerOver={event => enableOver && handleOpenHelpPopper(event)} onPointerOver={event => enableOver && handleOpenHelpPopper(event)}
onClick={ onClick={event => enableClick && handleOpenHelpPopper(event)}
element?.props?.onClick
? element.props.onClick
: event => enableClick && handleOpenHelpPopper(event)
}
{...props}> {...props}>
{element && <Icon className={classes.preventDefaultTooltip}></Icon>
cloneElement(element, {
className: classnames(
element.props.className,
classes.preventDefaultTooltip
)
})}
{!element && (
<HelpIcon className={classes.preventDefaultTooltip}></HelpIcon>
)}
<Popper <Popper
open={helpPopperOpen} open={helpPopperOpen}
anchorEl={helpPopperAnchorEl} anchorEl={helpPopperAnchorEl}

View file

@ -2,13 +2,13 @@ import { makeStyles } from '@material-ui/core/styles'
import classnames from 'classnames' import classnames from 'classnames'
import React from 'react' import React from 'react'
import typographyStyles from 'src/components/typography/styles'
import { import {
primaryColor, primaryColor,
spring2, spring2,
spring3, spring3,
disabledColor disabledColor
} from 'src/styling/variables' } from 'src/styling/variables'
import typographyStyles from 'src/components/typography/styles'
const { label1 } = typographyStyles const { label1 } = typographyStyles

View file

@ -39,7 +39,7 @@ function Select({ label, items, ...props }) {
<label {...getLabelProps()}>{startCase(label)}</label> <label {...getLabelProps()}>{startCase(label)}</label>
<button {...getToggleButtonProps()}> <button {...getToggleButtonProps()}>
<span className={classes.selectedItem}>{startCase(selectedItem)}</span> <span className={classes.selectedItem}>{startCase(selectedItem)}</span>
<Arrowdown className={classes.preventDefaultTooltip}/> <Arrowdown className={classes.preventDefaultTooltip} />
</button> </button>
<ul {...getMenuProps()}> <ul {...getMenuProps()}>
{isOpen && {isOpen &&

View file

@ -1,5 +1,5 @@
import React, { memo, useState } from 'react'
import { makeStyles } from '@material-ui/core' import { makeStyles } from '@material-ui/core'
import React, { memo, useState } from 'react'
import TextInputFormik from './TextInput' import TextInputFormik from './TextInput'
import { styles } from './TextInput.styles' import { styles } from './TextInput.styles'

View file

@ -5,8 +5,8 @@ import { NavLink } from 'react-router-dom'
import { Link } from 'src/components/buttons' import { Link } from 'src/components/buttons'
import { H4 } from 'src/components/typography' import { H4 } from 'src/components/typography'
import { ReactComponent as Logo } from 'src/styling/icons/menu/logo.svg'
import AddMachine from 'src/pages/AddMachine' import AddMachine from 'src/pages/AddMachine'
import { ReactComponent as Logo } from 'src/styling/icons/menu/logo.svg'
import styles from './Header.styles' import styles from './Header.styles'

View file

@ -2,13 +2,13 @@ import { makeStyles } from '@material-ui/core/styles'
import classnames from 'classnames' import classnames from 'classnames'
import React, { memo } from 'react' import React, { memo } from 'react'
import typographyStyles from 'src/components/typography/styles'
import { import {
tableHeaderColor, tableHeaderColor,
tableHeaderHeight, tableHeaderHeight,
spacer, spacer,
white white
} from 'src/styling/variables' } from 'src/styling/variables'
import typographyStyles from 'src/components/typography/styles'
const { label2 } = typographyStyles const { label2 } = typographyStyles

View file

@ -1,5 +1,5 @@
import React, { useState } from 'react'
import { makeStyles } from '@material-ui/core' import { makeStyles } from '@material-ui/core'
import React, { useState } from 'react'
import { Button } from 'src/components/buttons' import { Button } from 'src/components/buttons'
import { ReactComponent as CompleteIcon } from 'src/styling/icons/stage/spring/complete.svg' import { ReactComponent as CompleteIcon } from 'src/styling/icons/stage/spring/complete.svg'

View file

@ -1,10 +1,10 @@
import typographyStyles from 'src/components/typography/styles'
import { import {
placeholderColor, placeholderColor,
backgroundColor, backgroundColor,
primaryColor, primaryColor,
mainWidth mainWidth
} from 'src/styling/variables' } from 'src/styling/variables'
import typographyStyles from 'src/components/typography/styles'
const { tl2, p } = typographyStyles const { tl2, p } = typographyStyles

View file

@ -9,6 +9,7 @@ import { NamespacedTable as EditableTable } from 'src/components/editableTable'
import { Switch } from 'src/components/inputs' import { Switch } from 'src/components/inputs'
import TitleSection from 'src/components/layout/TitleSection' import TitleSection from 'src/components/layout/TitleSection'
import { P, Label2 } from 'src/components/typography' import { P, Label2 } from 'src/components/typography'
import { ReactComponent as HelpIcon } from 'src/styling/icons/action/help/zodiac.svg'
import { fromNamespace, toNamespace } from 'src/utils/config' import { fromNamespace, toNamespace } from 'src/utils/config'
import Wizard from './Wizard' import Wizard from './Wizard'
@ -88,7 +89,7 @@ const CashOut = ({ name: SCREEN_KEY }) => {
<Label2 className={classes.switchLabel}> <Label2 className={classes.switchLabel}>
{fudgeFactorActive ? 'On' : 'Off'} {fudgeFactorActive ? 'On' : 'Off'}
</Label2> </Label2>
<Tooltip width={304} enableClick> <Tooltip width={304} enableClick Icon={HelpIcon}>
<P> <P>
Automatically accept customer deposits as complete if their Automatically accept customer deposits as complete if their
received amount is 10 crypto atoms or less. received amount is 10 crypto atoms or less.

View file

@ -1,6 +1,6 @@
import CustomerDetails from './CustomerDetails' import CustomerDetails from './CustomerDetails'
import IdDataCard from './IdDataCard'
import IdCardPhotoCard from './IdCardPhotoCard' import IdCardPhotoCard from './IdCardPhotoCard'
import IdDataCard from './IdDataCard'
import PhoneCard from './PhoneCard' import PhoneCard from './PhoneCard'
import TransactionsList from './TransactionsList' import TransactionsList from './TransactionsList'

View file

@ -1,4 +1,4 @@
import Customers from './Customers'
import CustomerProfile from './CustomerProfile' import CustomerProfile from './CustomerProfile'
import Customers from './Customers'
export { Customers, CustomerProfile } export { Customers, CustomerProfile }

View file

@ -88,7 +88,7 @@ const CoinATMRadar = memo(() => {
<div> <div>
<div className={classes.titleWrapper}> <div className={classes.titleWrapper}>
<H4>Coin ATM Radar share settings</H4> <H4>Coin ATM Radar share settings</H4>
<Tooltip enableClick width={304} element={<HelpIcon />}> <Tooltip enableClick width={304} Icon={HelpIcon}>
<P> <P>
For details on configuring this panel, please read the relevant For details on configuring this panel, please read the relevant
knowledgebase article{' '} knowledgebase article{' '}