From 66d2f4f09b2d9a47258779ebb199e8741a0e1658 Mon Sep 17 00:00:00 2001 From: plouc Date: Mon, 16 Nov 2020 08:45:07 +0900 Subject: [PATCH] feat(core): add proper type for useTheme hook --- packages/core/index.d.ts | 87 +++++++++++++++++++++++---------- packages/marimekko/src/hooks.ts | 1 - 2 files changed, 61 insertions(+), 27 deletions(-) diff --git a/packages/core/index.d.ts b/packages/core/index.d.ts index 8a77a79db5..da68d235ef 100644 --- a/packages/core/index.d.ts +++ b/packages/core/index.d.ts @@ -37,65 +37,100 @@ declare module '@nivo/core' { colorBy?: string | GetColor } - export type Theme = Partial<{ - crosshair: Partial<{ - line: Partial<{ + export type CompleteTheme = { + crosshair: { + line: { stroke: string strokeWidth: number strokeOpacity: number strokeDasharray: string - }> - }> + } + } background: string fontFamily: string fontSize: number textColor: string - axis: Partial<{ - domain: Partial<{ + axis: { + domain: { line: Partial - }> - ticks: Partial<{ + } + ticks: { line: Partial text: Partial - }> - legend: Partial<{ + } + legend: { text: Partial - }> - }> - grid: Partial<{ + } + } + grid: { line: Partial - }> - legends: Partial<{ + } + legends: { text: Partial - }> - labels: Partial<{ + } + labels: { text: Partial - }> - markers: Partial<{ + } + markers: { lineColor: string lineStrokeWidth: number textColor: string fontSize: string | 0 text: Partial - }> - dots: Partial<{ + } + dots: { text: Partial - }> - tooltip: Partial<{ + } + tooltip: { container: Partial basic: Partial chip: Partial table: Partial tableCell: Partial - }> - annotations: Partial<{ + } + annotations: { text: Partial link: Partial outline: Partial symbol: Partial + } + } + + export type Theme = Partial<{ + crosshair: Partial<{ + line: Partial }> + axis: Partial<{ + domain: Partial<{ + line: Partial + }> + ticks: Partial<{ + line: Partial + text: Partial + }> + legend: Partial<{ + text: Partial + }> + }> + grid: Partial<{ + line: Partial + }> + legends: Partial<{ + text: Partial + }> + labels: Partial<{ + text: Partial + }> + markers: Partial + dots: Partial<{ + text: Partial + }> + tooltip: Partial + annotations: Partial }> + export function useTheme(): CompleteTheme + export type MotionProps = Partial<{ animate: boolean motionDamping: number diff --git a/packages/marimekko/src/hooks.ts b/packages/marimekko/src/hooks.ts index 6cf20ba027..e35cc83d85 100644 --- a/packages/marimekko/src/hooks.ts +++ b/packages/marimekko/src/hooks.ts @@ -2,7 +2,6 @@ import { useMemo } from 'react' import { get } from 'lodash' import { stack as d3Stack, Stack, stackOffsetDiverging, Series } from 'd3-shape' import { ScaleLinear, scaleLinear } from 'd3-scale' -// @ts-ignore import { useTheme } from '@nivo/core' import { InheritedColorConfig, useInheritedColor, useOrdinalColorScale } from '@nivo/colors' import {