-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom tooltips to toolbar buttons (#1214)
* Add custom tooltips to toolbar buttons * Avoid redundancy in the aria-label * Remove disableTooltip option on IconButton * Bring tooltip closer to button
- Loading branch information
Showing
3 changed files
with
19 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Tooltip from '@material-ui/core/Tooltip'; | ||
|
||
export const IconButton = ({ icon, ...props }) => ( | ||
<button className="icon-button" type="button" {...props}> | ||
{icon} | ||
</button> | ||
export const IconButton = ({ icon, title, ...props }) => ( | ||
<Tooltip | ||
classes={{ tooltip: 'icon-button__tooltip' }} | ||
enterDelay={200} | ||
title={title} | ||
> | ||
<button className="icon-button" type="button" {...props}> | ||
{icon} | ||
</button> | ||
</Tooltip> | ||
); | ||
|
||
IconButton.propTypes = { | ||
disableTooltip: PropTypes.bool, | ||
icon: PropTypes.element.isRequired, | ||
title: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default IconButton; |
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 |
---|---|---|
|
@@ -17,3 +17,8 @@ | |
} | ||
} | ||
} | ||
|
||
.icon-button__tooltip { | ||
position: relative; | ||
top: -8px; | ||
} |
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