Skip to content

Commit

Permalink
feat(core): remove enclosing div from container if non interactive
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphaël Benitte authored and Raphaël Benitte committed Mar 27, 2019
1 parent 8426ef5 commit 149ed0f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
46 changes: 29 additions & 17 deletions packages/core/src/components/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,38 @@ const Container = ({ children, theme, isInteractive = true }) => {
})
const { isTooltipVisible, tooltipContent, position } = state

let content
if (isInteractive) {
content = (
<div style={containerStyle} ref={containerEl}>
{children({
showTooltip: isInteractive ? showTooltip : noop,
hideTooltip: isInteractive ? hideTooltip : noop,
})}
{isTooltipVisible && (
<div
style={{
...tooltipStyle,
...position,
...theme.tooltip,
}}
>
{tooltipContent}
</div>
)}
</div>
)
} else {
content = children({
showTooltip: isInteractive ? showTooltip : noop,
hideTooltip: isInteractive ? hideTooltip : noop,
})
}

return (
<themeContext.Provider value={theme}>
<tooltipContext.Provider value={[showTooltip, hideTooltip]}>
<div style={containerStyle} ref={containerEl}>
{children({
showTooltip: isInteractive ? showTooltip : noop,
hideTooltip: isInteractive ? hideTooltip : noop,
})}
{isTooltipVisible && (
<div
style={{
...tooltipStyle,
...position,
...theme.tooltip,
}}
>
{tooltipContent}
</div>
)}
</div>
{content}
</tooltipContext.Provider>
</themeContext.Provider>
)
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/icons/ChoroplethIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import React, { Fragment } from 'react'
import React from 'react'
import choroplethGreyImg from '../../assets/icons/choropleth-grey.png'
import choroplethRedImg from '../../assets/icons/choropleth-red.png'
import { Icon } from './styled'
Expand Down

0 comments on commit 149ed0f

Please sign in to comment.