refactor: rename props

This commit is contained in:
Krist Wongsuphasawat 2019-05-17 09:41:36 -07:00 committed by Yongjie Zhao
parent d3e140c3ae
commit 41fc7dc75c
4 changed files with 15 additions and 15 deletions

View File

@ -1,6 +1,6 @@
import { ChartFormData } from '@superset-ui/chart'; import { ChartFormData } from '@superset-ui/chart';
import { RenderingFormData } from './Line'; import { FormDataProps } from './Line';
type CombinedFormData = ChartFormData & RenderingFormData; type CombinedFormData = ChartFormData & FormDataProps;
export default CombinedFormData; export default CombinedFormData;

View File

@ -3,7 +3,7 @@
import React from 'react'; import React from 'react';
import { TooltipFrame, TooltipTable } from '@superset-ui/chart-composition'; import { TooltipFrame, TooltipTable } from '@superset-ui/chart-composition';
import { chartTheme } from '@data-ui/theme'; import { chartTheme } from '@data-ui/theme';
import { TooltipInput } from './Line'; import { TooltipProps } from './Line';
const MARK_STYLE = { marginRight: 4 }; const MARK_STYLE = { marginRight: 4 };
@ -13,7 +13,7 @@ export default function DefaultTooltipRenderer({
encoder, encoder,
series = {}, series = {},
theme = chartTheme, theme = chartTheme,
}: TooltipInput) { }: TooltipProps) {
return ( return (
<TooltipFrame> <TooltipFrame>
<> <>

View File

@ -25,7 +25,7 @@ chartTheme.gridStyles.stroke = '#f1f3f5';
const DEFAULT_MARGIN = { top: 20, right: 20, left: 20, bottom: 20 }; const DEFAULT_MARGIN = { top: 20, right: 20, left: 20, bottom: 20 };
export interface TooltipInput { export interface TooltipProps {
encoder: Encoder; encoder: Encoder;
allSeries: Series[]; allSeries: Series[];
datum: SeriesValue; datum: SeriesValue;
@ -45,13 +45,13 @@ const defaultProps = {
}; };
/** Part of formData that is needed for rendering logic in this file */ /** Part of formData that is needed for rendering logic in this file */
export type RenderingFormData = { export type FormDataProps = {
margin?: Margin; margin?: Margin;
theme?: typeof chartTheme; theme?: typeof chartTheme;
} & PartialSpec<Encoding>; } & PartialSpec<Encoding>;
export type Hooks = { export type HookProps = {
TooltipRenderer?: React.ComponentType<TooltipInput>; TooltipRenderer?: React.ComponentType<TooltipProps>;
} & LegendHooks<ChannelTypes>; } & LegendHooks<ChannelTypes>;
type Props = { type Props = {
@ -59,8 +59,8 @@ type Props = {
width: string | number; width: string | number;
height: string | number; height: string | number;
data: Dataset; data: Dataset;
} & Hooks & } & HookProps &
RenderingFormData & FormDataProps &
Readonly<typeof defaultProps>; Readonly<typeof defaultProps>;
export interface Series { export interface Series {

View File

@ -1,20 +1,20 @@
import { pick } from 'lodash'; import { pick } from 'lodash';
import { ChartProps } from '@superset-ui/chart'; import { ChartProps } from '@superset-ui/chart';
import { Hooks, RenderingFormData } from './Line'; import { HookProps, FormDataProps } from './Line';
/* eslint-disable sort-keys */ /* eslint-disable sort-keys */
export default function transformProps(chartProps: ChartProps) { export default function transformProps(chartProps: ChartProps) {
const { width, height, payload } = chartProps; const { width, height, payload } = chartProps;
const { data } = payload; const { data } = payload;
const formData = chartProps.formData as RenderingFormData; const formData = chartProps.formData as FormDataProps;
const hooks = chartProps.hooks as Hooks; const hooks = chartProps.hooks as HookProps;
/** /**
* Use type-check to make sure the field names are expected ones * Use type-check to make sure the field names are expected ones
* and only pick these fields to pass to the chart. * and only pick these fields to pass to the chart.
*/ */
const fieldsFromFormData: (keyof RenderingFormData)[] = [ const fieldsFromFormData: (keyof FormDataProps)[] = [
'commonEncoding', 'commonEncoding',
'encoding', 'encoding',
'margin', 'margin',
@ -22,7 +22,7 @@ export default function transformProps(chartProps: ChartProps) {
'theme', 'theme',
]; ];
const fieldsFromHooks: (keyof Hooks)[] = [ const fieldsFromHooks: (keyof HookProps)[] = [
'TooltipRenderer', 'TooltipRenderer',
'LegendGroupRenderer', 'LegendGroupRenderer',
'LegendItemRenderer', 'LegendItemRenderer',