Skip to content

Commit 9ae450d

Browse files
committed
refactor: rename redundant type and add more comments
1 parent 5475301 commit 9ae450d

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

example/app/chart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
type AxisLabelComponentProps,
2+
type AxisLabelProps,
33
LineChart,
44
type PanGestureHandlerOnChangeEventPayload,
55
HoverGestureHandlerOnChangeEventPayload,
@@ -21,7 +21,7 @@ const formatter = new Intl.NumberFormat("en-US", {
2121
currency: "USD",
2222
});
2323

24-
const AxisLabel: React.FC<AxisLabelComponentProps> = ({ value }) => (
24+
const AxisLabel: React.FC<AxisLabelProps> = ({ value }) => (
2525
<Text selectable={false}>{formatter.format(value)}</Text>
2626
);
2727

src/components/LineChart/AxisLabel.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ import Animated, {
88
withTiming,
99
} from "react-native-reanimated";
1010

11-
export interface AxisLabelComponentProps {
11+
export interface AxisLabelProps {
12+
/** The value that should be displayed as the label. */
1213
value: number;
1314
}
1415

1516
interface AxisLabelContainerProps {
17+
/** A label component to be displayed. */
1618
children: React.ReactNode;
19+
/** The x position of the label. */
1720
x: number;
21+
/** The width of the root container. */
1822
containerWidth: number;
1923
}
2024

src/components/LineChart/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { LayoutChangeEvent, StyleSheet, View, ViewProps } from "react-native";
44
import { GestureDetector } from "react-native-gesture-handler";
55
import { useSharedValue } from "react-native-reanimated";
66

7-
import { AxisLabelComponentProps, AxisLabelContainer } from "./AxisLabel";
7+
import { AxisLabelProps, AxisLabelContainer } from "./AxisLabel";
88
import { Cursor } from "./Cursor";
99
import { computePath, type ComputePathProps, computeGraphData } from "./computations";
1010
import {
@@ -79,15 +79,15 @@ interface LineChartProps extends ViewProps {
7979
* @note This compnent should not be a Skia component since it is not rendered
8080
* in the Canvas.
8181
*/
82-
TopAxisLabel?: React.FC<AxisLabelComponentProps>;
82+
TopAxisLabel?: React.FC<AxisLabelProps>;
8383
/**
8484
* The component to render as the bottom axis label.
8585
* @default null
8686
*
8787
* @note This compnent should not be a Skia component since it is not rendered
8888
* in the Canvas.
8989
*/
90-
BottomAxisLabel?: React.FC<AxisLabelComponentProps>;
90+
BottomAxisLabel?: React.FC<AxisLabelProps>;
9191
/**
9292
* The type of curve to use for the line chart. Currently, only "linear" is supported.
9393
*
@@ -271,7 +271,7 @@ export {
271271
LineChart,
272272
type LineChartProps,
273273
type PathFillProps,
274-
type AxisLabelComponentProps,
274+
type AxisLabelProps,
275275
// Gesture exports
276276
type PanGestureHandlerOnBeginEventPayload,
277277
type PanGestureHandlerEventPayload,

src/components/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export {
22
LineChart,
33
type LineChartProps,
44
type PathFillProps,
5-
type AxisLabelComponentProps,
5+
type AxisLabelProps,
66
// Gesture exports
77
type PanGestureHandlerOnBeginEventPayload,
88
type PanGestureHandlerEventPayload,

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export {
22
LineChart,
33
type LineChartProps,
4-
type AxisLabelComponentProps,
4+
type AxisLabelProps,
55
PanGestureHandlerOnBeginEventPayload,
66
PanGestureHandlerOnChangeEventPayload,
77
PanGestureHandlerEventPayload,

0 commit comments

Comments
 (0)