Skip to content

Commit

Permalink
Merge pull request #1409 from cozy/feat/tooltip
Browse files Browse the repository at this point in the history
feat: Import the tooltip component from MUI
  • Loading branch information
edas authored Mar 16, 2020
2 parents ca0046e + 451666b commit 0cf2c7e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/styleguide.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ module.exports = {
'../react/Well/index.jsx',
'../react/Infos/index.jsx',
'../react/InfosCarrousel/index.jsx',
'../react/Tooltip/index.jsx',
'../react/ContextHeader/index.jsx',
'../react/Filename/index.jsx',
'../react/AppTitle/index.jsx',
Expand Down
8 changes: 8 additions & 0 deletions react/Tooltip/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### Simplest usage

```js
import Tooltip from 'cozy-ui/transpiled/react/Tooltip';
<Tooltip title={'This is an explaination'}><u>hover over me</u></Tooltip>
```

This component is imported from MUI and has the same API.
24 changes: 24 additions & 0 deletions react/Tooltip/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { withStyles } from '@material-ui/core/styles'
import { Tooltip } from '@material-ui/core'

// We use css-in-js because using external css may create
// conflicts of priorities between MUI and cozy-UI.
// MUI always loads its styes at the end of <head>, making them
// override any previous selector with the same specificity.
// It also allows the code using this component to overrides
// only some rules and not the whole classname.
const styles = {
tooltip: {
backgroundColor: 'var(--paleGrey)',
borderRadius: '8px',
fontSize: '1rem',
color: 'var(--black)',
lineHeight: '1.3',
boxShadow:
'0 1px 3px 0 rgba(50, 54, 63, 0.19), 0 6px 18px 0 rgba(50, 54, 63, 0.19)'
}
}

const StyledTooltip = withStyles(styles, { name: 'MuiTooltip' })(Tooltip)

export default StyledTooltip

0 comments on commit 0cf2c7e

Please sign in to comment.