Skip to content

Commit

Permalink
feat(website): add TimeRange component
Browse files Browse the repository at this point in the history
  • Loading branch information
wyze committed Jun 10, 2021
1 parent c7f9876 commit fec51a1
Show file tree
Hide file tree
Showing 5 changed files with 561 additions and 0 deletions.
55 changes: 55 additions & 0 deletions website/src/data/components/time-range/mapper.js
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'],
}
)
13 changes: 13 additions & 0 deletions website/src/data/components/time-range/meta.yml
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.
Loading

0 comments on commit fec51a1

Please sign in to comment.