Skip to content

Commit

Permalink
feat(sunburst): Add typescript definition (#995)
Browse files Browse the repository at this point in the history
Co-authored-by: shibby <shibbyr@gmail.com>
  • Loading branch information
ronens88 and shibbyr committed Jun 24, 2020
1 parent fa847f6 commit a32603c
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions packages/sunburst/index.d.ts
@@ -0,0 +1,44 @@
import * as React from 'react'
import { Dimensions, Box, ColorProps, MotionProps } from '@nivo/core'

declare module '@nivo/sunburst' {
export interface SunburstDataNode {
// optional because it works without a color
// however it does throw a warning if no value is set and the value is requested
color?: string
// optional because it could have a different name given by the 'identity' property
id?: string
}

export interface SunburstDataParentNode extends SunburstDataNode {
children: SunburstDataNode[]
}

export interface SunburstDataLeafNode extends SunburstDataNode {
// optional because it could have a different name given by the 'value' property
value?: number
}

export interface SunburstData {
data: SunburstDataParentNode
}

export type SunburstProps = SunburstData &
Partial<{
identity: string | ((node: SunburstDataNode) => string)
value: string | ((node: SunburstDataNode) => string)
childColor: string | ((node: SunburstDataNode) => string)

borderWidth: number
borderColor: string
cornerRadius: number
margin: Box

isInteractive: boolean
}> &
ColorProps<SunburstDataNode> &
MotionProps

export class Sunburst extends React.Component<Dimensions & SunburstProps> {}
export class ResponsiveSunburst extends React.Component<SunburstProps> {}
}

0 comments on commit a32603c

Please sign in to comment.