-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add generic tooltip component FadingTooltip
This component: - has a default fading transition for consistency in the webapp - lets users have newlines in the tooltips messages - adds a div wrapper to prevent some warnings (e.g. on disabled buttons) - increases tooltip max width to 600px
- Loading branch information
Showing
4 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Fade, Tooltip as MuiTooltip, withStyles } from '@material-ui/core'; | ||
|
||
const Tooltip = ({ children, ...other }) => { | ||
return ( | ||
<MuiTooltip TransitionComponent={Fade} TransitionProps={{ timeout: 600 }} {...other}> | ||
<div>{children}</div> | ||
</MuiTooltip> | ||
); | ||
}; | ||
|
||
Tooltip.propTypes = { | ||
/** | ||
* Elements that trigger the tooltip when hovered | ||
*/ | ||
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired, | ||
}; | ||
|
||
export const FadingTooltip = withStyles((theme) => ({ | ||
tooltip: { | ||
whiteSpace: 'pre-wrap', | ||
maxWidth: '600px', | ||
}, | ||
}))(Tooltip); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { FadingTooltip } from './FadingTooltip'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters