Skip to content

Commit 722e95b

Browse files
committed
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
1 parent 1cb512b commit 722e95b

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export { UserInfo, HelpMenu } from './menus';
2424
export {
2525
ErrorBanner,
2626
ErrorsPanel,
27+
FadingTooltip,
2728
FixedRatioContainer,
2829
LoadingLine,
2930
PermissionsGate,
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { Fade, Tooltip as MuiTooltip, withStyles } from '@material-ui/core';
4+
5+
const Tooltip = ({ children, ...other }) => {
6+
return (
7+
<MuiTooltip TransitionComponent={Fade} TransitionProps={{ timeout: 600 }} {...other}>
8+
<div>{children}</div>
9+
</MuiTooltip>
10+
);
11+
};
12+
13+
Tooltip.propTypes = {
14+
/**
15+
* Elements that trigger the tooltip when hovered
16+
*/
17+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
18+
};
19+
20+
export const FadingTooltip = withStyles((theme) => ({
21+
tooltip: {
22+
whiteSpace: 'pre-wrap',
23+
maxWidth: '600px',
24+
},
25+
}))(Tooltip);

src/misc/FadingTooltip/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { FadingTooltip } from './FadingTooltip';

src/misc/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ export { ScenarioValidationStatusChip } from './ScenarioValidationStatusChip';
77
export { LoadingLine } from './LoadingLine';
88
export { ErrorBanner } from './ErrorBanner';
99
export { DefaultAvatar } from './DefaultAvatar';
10+
export { FadingTooltip } from './FadingTooltip';
1011
export { PermissionsGate } from './PermissionsGate';

0 commit comments

Comments
 (0)