Skip to content

Commit

Permalink
move grid types into own type
Browse files Browse the repository at this point in the history
  • Loading branch information
annacmc committed Dec 23, 2024
1 parent 85d0591 commit 5a4bbd8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import { GridRows, GridColumns } from '@visx/grid';
import React from 'react';
import styles from './grid-control.module.scss';
import type { BaseChartProps } from '../shared/types';
import type { BaseGridProps } from '../shared/types';

interface GridControlProps extends BaseChartProps {
// TODO: Fix any type after resolving visx scale type issues
// eslint-disable-next-line @typescript-eslint/no-explicit-any
xScale: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
yScale: any;
top?: number;
}

const GridControl: React.FC< GridControlProps > = ( {
const GridControl: React.FC< BaseGridProps > = ( {
width,
height,
xScale,
Expand Down
47 changes: 17 additions & 30 deletions projects/js-packages/charts/src/components/shared/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,48 +66,35 @@ export type ChartTheme = {
};

/**
* Base properties shared across all chart components
* Base properties for grid components
*/
export type BaseChartProps< T = DataPoint | DataPointDate > = {
export type BaseGridProps = {
/**
* Array of data points to display in the chart
*/
data?: T extends DataPoint | DataPointDate ? T[] : T;
/**
* Additional CSS class name for the chart container
*/
className?: string;
/**
* Width of the chart in pixels
* Width of the grid in pixels
*/
width: number;
/**
* Height of the chart in pixels
*/
height?: number;
/**
* Chart margins
* Height of the grid in pixels
*/
margin?: {
top: number;
right: number;
bottom: number;
left: number;
};
height: number;
/**
* Whether to show tooltips on hover. False by default.
* Grid visibility. x is default.
*/
withTooltips?: boolean;
gridVisibility?: 'x' | 'y' | 'xy' | 'none';
/**
* Whether to show legend
* X-axis scale for the grid
* TODO: Fix any type after resolving visx scale type issues
*/
showLegend?: boolean;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
xScale: any;
/**
* Legend orientation
* Y-axis scale for the grid
* TODO: Fix any type after resolving visx scale type issues
*/
legendOrientation?: 'horizontal' | 'vertical';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
yScale: any;
/**
* Grid visibility. x is default.
* Top offset for the grid
*/
gridVisibility?: 'x' | 'y' | 'xy' | 'none';
top?: number;
};

0 comments on commit 5a4bbd8

Please sign in to comment.