-
-
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 TypeScript definitions
- Loading branch information
Raphaël Benitte
authored and
Raphaël Benitte
committed
Jun 4, 2018
1 parent
bd2258f
commit 98106ab
Showing
4 changed files
with
81 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import * as React from 'react' | ||
import { Dimensions, Theme, Box } from '@nivo/core' | ||
import { LegendProps } from '@nivo/legends' | ||
|
||
declare module '@nivo/calendar' { | ||
export type DateOrString = string | Date | ||
|
||
export interface CalendarDatum { | ||
day: string | ||
value: number | ||
} | ||
|
||
export interface CalendarData { | ||
from: DateOrString | ||
to: DateOrString | ||
data: CalendarDatum[] | ||
} | ||
|
||
export type CalendarDirection = 'horizontal' | 'vertical' | ||
|
||
export type CalendarLegend = LegendProps & { | ||
itemCount: number | ||
} | ||
|
||
export interface CalendarDayData { | ||
date: Date | ||
day: string | ||
value?: number | ||
color: string | ||
size: number | ||
x: number | ||
y: number | ||
} | ||
|
||
export type CalendarCommonProps = Partial<{ | ||
domain: 'auto' | number[] | ||
direction: CalendarDirection | ||
colors: string[] | ||
margin: Box | ||
|
||
// years | ||
yearLabel: (year: number) => string | number | ||
yearSpacing: number | ||
yearLegendOffset: number | ||
|
||
// months | ||
monthLabel: (year: number, month: number) => string | number | ||
monthBorderWidth: number | ||
monthBorderColor: string | ||
monthLegendOffset: number | ||
|
||
// days | ||
daySpacing: number | ||
dayBorderWidth: number | ||
dayBorderColor: string | ||
emptyColor: string | ||
|
||
// interactivity | ||
isInteractive: boolean | ||
|
||
// tooltip | ||
tooltipFormat: (value: number) => string | number | ||
|
||
// legends | ||
legends: CalendarLegend[] | ||
|
||
theme: Theme | ||
}> | ||
|
||
export type CalendarSvgProps = CalendarData | ||
& CalendarCommonProps | ||
& Partial<{ | ||
onClick: (datum: CalendarDayData, event: React.MouseEvent<SVGRectElement>) => void | ||
}> | ||
|
||
export class Calendar extends React.Component<CalendarSvgProps & Dimensions> {} | ||
export class ResponsiveCalendar extends React.Component<CalendarSvgProps> {} | ||
} |
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
"files": [ | ||
"README.md", | ||
"index.js", | ||
"index.d.ts", | ||
"cjs/" | ||
], | ||
"dependencies": { | ||
|
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