-
-
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(calendar): add ability to define custom tooltip
- Loading branch information
Raphaël Benitte
authored and
Raphaël Benitte
committed
Jun 4, 2018
1 parent
d3b8951
commit 7a076bf
Showing
8 changed files
with
207 additions
and
31 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
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,61 @@ | ||
/* | ||
* This file is part of the nivo project. | ||
* | ||
* Copyright 2016-present, Raphaël Benitte. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
import { settingsMapper } from '../../../lib/settings' | ||
|
||
const TooltipWrapper = styled.div` | ||
display: grid; | ||
grid-template-columns: 1fr 1fr; | ||
grid-column-gap: 12px; | ||
` | ||
const TooltipKey = styled.span` | ||
font-weight: 600; | ||
` | ||
|
||
const CustomTooltip = node => ( | ||
<TooltipWrapper style={{ color: node.color }}> | ||
<TooltipKey>day</TooltipKey> | ||
<span>{node.day}</span> | ||
<TooltipKey>value</TooltipKey> | ||
<span>{node.value}</span> | ||
<TooltipKey>x</TooltipKey> | ||
<span>{node.x}</span> | ||
<TooltipKey>y</TooltipKey> | ||
<span>{node.y}</span> | ||
<TooltipKey>size</TooltipKey> | ||
<span>{node.size}</span> | ||
</TooltipWrapper> | ||
) | ||
|
||
export default settingsMapper( | ||
{ | ||
theme: (value, values) => { | ||
if (!values['custom tooltip example']) return value | ||
|
||
return { | ||
...values.theme, | ||
tooltip: { | ||
container: { | ||
...values.theme.tooltip.container, | ||
background: '#333', | ||
}, | ||
}, | ||
} | ||
}, | ||
tooltip: (value, values) => { | ||
if (!values['custom tooltip example']) return null | ||
|
||
return CustomTooltip | ||
}, | ||
}, | ||
{ | ||
exclude: ['custom tooltip example'], | ||
} | ||
) |