Skip to content

Commit b0d2265

Browse files
refactor: streamline UnityProps type definition by consolidating canvas element properties
1 parent 849e49a commit b0d2265

File tree

1 file changed

+14
-32
lines changed

1 file changed

+14
-32
lines changed
Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,22 @@
1-
import { CSSProperties } from "react";
21
import { UnityProvider } from "./unity-provider";
32
import { UnityArguments } from "./unity-arguments";
3+
import { CanvasHTMLAttributes, DetailedHTMLProps } from "react";
4+
5+
type HTMLCanvasElementProps = DetailedHTMLProps<
6+
CanvasHTMLAttributes<HTMLCanvasElement>,
7+
HTMLCanvasElement
8+
>;
49

510
type UnityProps = Pick<
611
UnityArguments,
712
"devicePixelRatio" | "matchWebGLToCanvasSize" | "disabledCanvasEvents"
8-
> & {
9-
/**
10-
* The Unity provider that contains the necessary URLs to load the Unity
11-
* instance. This is required to load the Unity WebGL build.
12-
*/
13-
unityProvider: UnityProvider;
14-
15-
/**
16-
* The ID of the Unity canvas element. If not provided, a unique ID will be
17-
* generated. It is recommended to let the library generate a unique ID
18-
* unless you have a specific reason to use a custom ID.
19-
*/
20-
id?: string;
21-
22-
/**
23-
* The style of the Unity canvas element.
24-
*/
25-
style?: CSSProperties;
26-
27-
/**
28-
* The class name of the Unity canvas element. This can be used to apply
29-
* custom styles to the canvas.
30-
*/
31-
className?: string;
32-
33-
/**
34-
* The tab index of the Unity canvas element. This can be used to make the
35-
* canvas focusable.
36-
*/
37-
tabIndex?: number;
38-
};
13+
> &
14+
Pick<HTMLCanvasElementProps, "id" | "style" | "className" | "tabIndex"> & {
15+
/**
16+
* The Unity provider that contains the necessary URLs to load the Unity
17+
* instance. This is required to load the Unity WebGL build.
18+
*/
19+
unityProvider: UnityProvider;
20+
};
3921

4022
export type { UnityProps };

0 commit comments

Comments
 (0)