-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tooltip): improve tooltip with global component
- Loading branch information
Raphaël Benitte
committed
Aug 11, 2017
1 parent
2a5b075
commit 631265d
Showing
6 changed files
with
171 additions
and
82 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
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
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,45 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import pure from 'recompose/pure' | ||
|
||
const tooltipStyle = { | ||
display: 'flex', | ||
alignItems: 'center', | ||
} | ||
|
||
const chipStyle = { | ||
display: 'block', | ||
width: '16px', | ||
height: '16px', | ||
marginRight: '9px', | ||
borderRadius: '2px', | ||
} | ||
|
||
const textStyle = { | ||
whiteSpace: 'pre', | ||
} | ||
|
||
const BasicTooltip = ({ id, value, enableChip, color }) => | ||
<div style={tooltipStyle}> | ||
{enableChip && <span style={{ ...chipStyle, background: color }} />} | ||
{value !== undefined | ||
? <span style={textStyle}> | ||
{id}: <strong>{value}</strong> | ||
</span> | ||
: <span style={textStyle}> | ||
{id} | ||
</span>} | ||
</div> | ||
|
||
BasicTooltip.propTypes = { | ||
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, | ||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
enableChip: PropTypes.bool.isRequired, | ||
color: PropTypes.string, | ||
} | ||
|
||
BasicTooltip.defaultProps = { | ||
enableChip: false, | ||
} | ||
|
||
export default pure(BasicTooltip) |