Skip to content

Commit

Permalink
Add custom tooltips to toolbar buttons (#1214)
Browse files Browse the repository at this point in the history
* 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
mirka authored Feb 27, 2019
1 parent a17023d commit a43e935
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
17 changes: 13 additions & 4 deletions lib/icon-button/index.js
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;
5 changes: 5 additions & 0 deletions lib/icon-button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@
}
}
}

.icon-button__tooltip {
position: relative;
top: -8px;
}
2 changes: 1 addition & 1 deletion lib/note-toolbar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class NoteToolbar extends Component {
<IconButton
icon={isPreviewing ? <PreviewStopIcon /> : <PreviewIcon />}
onClick={this.setEditorMode}
title="Preview"
title="Preview • Ctrl+Shift+P"
/>
</div>
)}
Expand Down

0 comments on commit a43e935

Please sign in to comment.