diff --git a/components/Tooltip/Tooltip.jsx b/components/Tooltip/Tooltip.jsx index 862387110..dcfc47e14 100644 --- a/components/Tooltip/Tooltip.jsx +++ b/components/Tooltip/Tooltip.jsx @@ -19,8 +19,8 @@ class Tooltip extends Component { const pointerGap = this.props.pointerGap const tooltipPadding = this.props.tooltipPadding const tooltipDelay = this.props.tooltipDelay - const tooltip = ReactDOM.findDOMNode(this) - const ttContainer = tooltip.querySelector('.tooltip-container') + const tooltip = ReactDOM.findDOMNode(this).querySelector('.tooltip-container') + const ttContainer = tooltip.querySelector('.tooltip-content-container') const tooltipPointer = ttContainer.querySelector('.tooltip-pointer') const targetRect = evt.currentTarget.getBoundingClientRect() const targetRectCenterX = (targetRect.width / 2) + targetRect.left + window.scrollX @@ -84,7 +84,7 @@ class Tooltip extends Component { } hideTooltip() { - const tooltip = ReactDOM.findDOMNode(this) + const tooltip = ReactDOM.findDOMNode(this).querySelector('.tooltip-container') if (!tooltip.classList.contains('tooltip-hide')) { tooltip.classList.add('tooltip-hide') tooltip.style.transition = 'opacity 0s linear' @@ -103,8 +103,7 @@ class Tooltip extends Component { } componentDidMount() { - const targetId = this.props.tooltipId - const target = document.getElementById(targetId) + const target = ReactDOM.findDOMNode(this).querySelector('.tooltip-target') if (this.props.popMethod === 'hover') { target.addEventListener('mouseenter', this.showTooltip) target.addEventListener('mouseleave', this.hideTooltip) @@ -115,8 +114,7 @@ class Tooltip extends Component { } componentWillUnmount() { - const targetId = this.props.tooltipId - const target = document.getElementById(targetId) + const target = ReactDOM.findDOMNode(this).querySelector('.tooltip-target') target.removeEventListener('mouseenter', this.showTooltip) target.removeEventListener('mouseleave', this.hideTooltip) @@ -125,22 +123,32 @@ class Tooltip extends Component { } render() { + const body = (
This is a tooltip using the default theme.
This is a tooltip activated with a mouse click.
This tooltip also contains custom classes passed through the tooltip component render.
@@ -23,33 +21,29 @@ const TooltipExamples = () => (This is a tooltip using a custom theme.
This is a tooltip with a 3 second popup delay and a transition effect.
This is a tooltip with alternative padding, margin, pointer size and gap sized configured through tooltip custom attributes.
+This is a tooltip with alternative padding, margin, pointer size and gap size configured through tooltip custom attributes.
This is a tooltip on an image and also containing an image.
Tooltips can be applied to any HTML tag, and contain any content.
diff --git a/components/Tooltip/TooltipExamples.scss b/components/Tooltip/TooltipExamples.scss index 861f45a93..4f560cb05 100644 --- a/components/Tooltip/TooltipExamples.scss +++ b/components/Tooltip/TooltipExamples.scss @@ -1,48 +1,67 @@ .tooltip-examples-container { - .hastooltip { - position: relative; - width: 150px; - background-color: #999; - height: 150px; - margin: 10px; - font-size: 14px; - font-weight: bold; - color: #fff; - text-align: center; - padding: 15px; - - tooltip-1 { - float: left; - } - tooltip-2 { - float: right; - width: 50%; - background-color: #C00; - } + .Tooltip { + .tooltip-target { + position: relative; + width: 150px; + background-color: #999; + height: 150px; + margin: 10px; + font-size: 14px; + font-weight: bold; + color: #fff; + text-align: center; + padding: 15px; - tooltip-3 { - clear: both; - margin-left: 25%; - background-color: #CC0; + tooltip-1 { + float: left; + } - } + tooltip-2 { + float: right; + width: 50%; + background-color: #C00; + } - tooltip-4 { - margin-left: 50%; - background-color: #0C0; - } + tooltip-3 { + clear: both; + margin-left: 25%; + background-color: #CC0; - tooltip-5 { - margin-left: 75%; - background-color: #00C; - } + } + + tooltip-4 { + margin-left: 50%; + background-color: #0C0; + } - tooltip-6 { - margin-left: calc(100% - 200px); - padding: 0; - height: 200px; - width: 200px; + tooltip-5 { + margin-left: 75%; + background-color: #00C; + } + + tooltip-6 { + margin-left: calc(100% - 200px); + padding: 0; + height: 200px; + width: 200px; + } + } + //custom theme + &.blue-round { + .tooltip-content-container { + background-color: #0000CC; + border: 3px solid #000; + -webkit-border-radius: 50%; + -moz-border-radius: 50%; + border-radius: 50%; + .tooltip-pointer { + background-color: #0000CC; + } + .tooltip-body { + color: #FFF; + } + } } } }