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 { RenderingFormData } from './Line';
import { FormDataProps } from './Line';
type CombinedFormData = ChartFormData & RenderingFormData;
type CombinedFormData = ChartFormData & FormDataProps;
export default CombinedFormData;

View File

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

View File

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

View File

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