-
-
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(website): add TimeRange component
- Loading branch information
Showing
5 changed files
with
561 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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; | ||
background: #333; | ||
padding: 10px; | ||
border-radius: 4px; | ||
grid-template-columns: 100px 1fr; | ||
grid-column-gap: 12px; | ||
` | ||
const TooltipKey = styled.span` | ||
font-weight: 600; | ||
` | ||
|
||
const CustomTooltip = day => { | ||
return ( | ||
<TooltipWrapper style={{ color: day.color }}> | ||
<TooltipKey>day</TooltipKey> | ||
<span>{day.day}</span> | ||
<TooltipKey>value</TooltipKey> | ||
<span>{day.value}</span> | ||
<TooltipKey>coordinates.x</TooltipKey> | ||
<span>{day.coordinates.x}</span> | ||
<TooltipKey>coordinates.y</TooltipKey> | ||
<span>{day.coordinates.y}</span> | ||
<TooltipKey>height</TooltipKey> | ||
<span>{day.height}</span> | ||
<TooltipKey>width</TooltipKey> | ||
<span>{day.width}</span> | ||
</TooltipWrapper> | ||
) | ||
} | ||
|
||
export default settingsMapper( | ||
{ | ||
tooltip: (value, values) => { | ||
if (!values['custom tooltip example']) return undefined | ||
|
||
return CustomTooltip | ||
}, | ||
}, | ||
{ | ||
exclude: ['custom tooltip example'], | ||
} | ||
) |
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,13 @@ | ||
flavors: | ||
- flavor: svg | ||
path: /time-range/ | ||
|
||
TimeRange: | ||
package: '@nivo/calendar' | ||
tags: | ||
- svg | ||
- isomorphic | ||
stories: [] | ||
description: | | ||
The TimeRange chart is similar to the [Calendar](self:/calendar) chart, but | ||
it allows you to specify dates less than a year. |
Oops, something went wrong.