-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #282 from hackforla/175-FRONT-HoverOverInfo
Closes #175 added HoverOverInfo component
- Loading branch information
Showing
8 changed files
with
133 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import PropTypes from 'proptypes'; | ||
|
||
const HoverOverInfo = ({ | ||
title, | ||
text, | ||
position, | ||
children | ||
}) => ( | ||
<span | ||
data-for="react-tooltip" | ||
data-tip={JSON.stringify({ title, text })} | ||
data-place={position}> | ||
{ children } | ||
</span> | ||
); | ||
|
||
export default HoverOverInfo; | ||
|
||
HoverOverInfo.propTypes = { | ||
title: PropTypes.string, | ||
text: PropTypes.string, | ||
position: PropTypes.oneOf(['top', 'bottom', 'left', 'right']), | ||
}; | ||
|
||
HoverOverInfo.defaultProps = { | ||
position: 'right' | ||
}; |
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,42 @@ | ||
import React from 'react'; | ||
import ReactTooltip from 'react-tooltip'; | ||
import Icon from '../../common/Icon'; | ||
import COLORS from '../../../styles/COLORS'; | ||
import './styles.scss'; | ||
|
||
const Tooltip = () => ( | ||
<div className="tooltip"> | ||
<ReactTooltip | ||
id="react-tooltip" | ||
effect="solid" | ||
getContent={data => { | ||
if (!data) return null; | ||
let { text, title } = JSON.parse(data); | ||
if (!text && !title) return null; | ||
|
||
return ( | ||
<div style={{ color: COLORS.BRAND.MAIN }}> | ||
{ title && | ||
<div className="has-text-weight-bold is-size-6"> | ||
<Icon | ||
id="react-tooltip-icon" | ||
icon="info-circle" | ||
size="small" | ||
style={{ marginRight: '6px' }} | ||
/> | ||
{ title } | ||
</div> | ||
} | ||
{ text && | ||
<div className="tooltip-text is-size-6"> | ||
{ text } | ||
</div> | ||
} | ||
</div> | ||
); | ||
}} | ||
/> | ||
</div> | ||
); | ||
|
||
export default Tooltip; |
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,24 @@ | ||
.tooltip { | ||
position: absolute; | ||
z-index: 1101; // must exceed z-index of the side menu (1100) | ||
|
||
$bg-color: rgb(200, 200, 200); | ||
|
||
#react-tooltip { | ||
background-color: $bg-color; | ||
max-width: 200px; | ||
padding: 8px 12px; | ||
word-break: break-word; | ||
line-height: 20px; | ||
opacity: 1.0; | ||
|
||
&.place-right:after { border-right-color: $bg-color; } | ||
&.place-top:after { border-top-color: $bg-color; } | ||
&.place-left:after { border-left-color: $bg-color; } | ||
&.place-bottom:after { border-bottom-color: $bg-color; } | ||
|
||
.tooltip-text { | ||
margin-top: 6px; | ||
} | ||
} | ||
} |