@@ -5,6 +5,8 @@ import { ReactComponent as ZoomOutIcon } from "../../assets/icons/minus-solid.sv
55import { ReactComponent as ZoomResetIcon } from "../../assets/icons/dot-circle-regular.svg" ;
66import { useCamera } from "../../hooks/useCamera" ;
77
8+ type ZoomLabelKeys = "zoomIn" | "zoomOut" | "reset" ;
9+
810/**
911 * Properties for `ZoomControl` component
1012 */
@@ -23,6 +25,7 @@ export interface ZoomControlProps {
2325 * Number of ms for the zoom animation (default is 200ms)
2426 */
2527 animationDuration ?: number ;
28+
2629 /**
2730 * It's possible to customize the button, by passing to JSX Element.
2831 * First one is for the "zoom in", second for "zoom out" and third for "view whole graph".
@@ -36,6 +39,12 @@ export interface ZoomControlProps {
3639 * ```
3740 */
3841 children ?: [ JSX . Element , JSX . Element , JSX . Element ] ;
42+
43+ /**
44+ * Map of the labels we use in the component.
45+ * This is usefull for I18N
46+ */
47+ labels ?: { [ Key in ZoomLabelKeys ] ?: string } ;
3948}
4049
4150/**
@@ -60,6 +69,7 @@ export const ZoomControl: React.FC<ZoomControlProps> = ({
6069 style,
6170 animationDuration = 200 ,
6271 children,
72+ labels = { } ,
6373} : ZoomControlProps ) => {
6474 const { zoomIn, zoomOut, reset } = useCamera ( { duration : animationDuration , factor : 1.5 } ) ;
6575
@@ -72,17 +82,17 @@ export const ZoomControl: React.FC<ZoomControlProps> = ({
7282 return (
7383 < >
7484 < div { ...htmlProps } >
75- < button onClick = { ( ) => zoomIn ( ) } title = " Zoom In">
85+ < button onClick = { ( ) => zoomIn ( ) } title = { labels [ "zoomIn" ] || " Zoom In"} >
7686 { children ? children [ 0 ] : < ZoomInIcon style = { { width : "1em" } } /> }
7787 </ button >
7888 </ div >
7989 < div { ...htmlProps } >
80- < button onClick = { ( ) => zoomOut ( ) } title = " Zoom Out">
90+ < button onClick = { ( ) => zoomOut ( ) } title = { labels [ "zoomOut" ] || " Zoom Out"} >
8191 { children ? children [ 1 ] : < ZoomOutIcon style = { { width : "1em" } } /> }
8292 </ button >
8393 </ div >
8494 < div { ...htmlProps } >
85- < button onClick = { ( ) => reset ( ) } title = " See whole graph">
95+ < button onClick = { ( ) => reset ( ) } title = { labels [ "reset" ] || " See whole graph"} >
8696 { children ? children [ 2 ] : < ZoomResetIcon style = { { width : "1em" } } /> }
8797 </ button >
8898 </ div >
0 commit comments