Skip to content

Commit

Permalink
fix(core): add Defs types and export for typescript (#1146)
Browse files Browse the repository at this point in the history
Close #1115
  • Loading branch information
wyze committed Oct 5, 2020
1 parent 7d52c07 commit 99b520e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
42 changes: 42 additions & 0 deletions packages/core/index.d.ts
Expand Up @@ -143,4 +143,46 @@ declare module '@nivo/core' {
export type DataFormatter = (value: DatumValue) => string | number

export function useValueFormatter(formatter?: DataFormatter | string): DataFormatter

export type LinearGradientDef = {
id: string
type: 'linearGradient'
colors: {
offset: number
color: string
opacity?: number
}[]
}

export type PatternDotsDef = {
id: string
type: 'patternDots'
color?: string
background?: string
size?: number
padding?: number
stagger?: boolean
}

export type PatternSquaresDef = Omit<PatternDotsDef, 'type'> & {
type: 'patternDots'
}

export type PatternLinesDef = {
id: string
type: 'patternLines'
spacing?: number
rotation?: number
background?: string
color?: string
lineWidth?: number
}

export type Def = LinearGradientDef | PatternDotsDef | PatternSquaresDef | PatternLinesDef

export type DefsProps = {
defs: Def[]
}

export function Defs(props: DefsProps): JSX.Element
}
Expand Up @@ -28,6 +28,7 @@ LinearGradient.propTypes = {
PropTypes.shape({
offset: PropTypes.number.isRequired,
color: PropTypes.string.isRequired,
opacity: PropTypes.number,
})
).isRequired,
}
Expand Down

0 comments on commit 99b520e

Please sign in to comment.