Skip to content

Commit

Permalink
Integrated MeshProps forwarding for GalleryItem
Browse files Browse the repository at this point in the history
  • Loading branch information
isoteriksoftware committed Jun 1, 2024
1 parent 0772930 commit 00ef8b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,12 +457,12 @@ This allows you to customize the appearance of the gallery item.
#### Props
```tsx
type GalleryItemProps = PropsWithChildren<{
type GalleryItemProps = MeshProps & {
/**
* The material to apply to the gallery item.
*/
material: Material | Material[];
}>;
};
```

#### Example Usage
Expand Down
4 changes: 2 additions & 2 deletions src/components/GalleryItem/GalleryItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import GalleryItemContext from "./GalleryItemContext";
* @param children The children to render.
*/
export const GalleryItem = React.forwardRef<Mesh, GalleryItemProps>(
({ material, children }, ref) => {
({ material, children, ...rest }, ref) => {
const itemData = useContext(GalleryItemContext);
if (itemData === GALLERY_ITEM_NO_PROVIDER_FLAG) {
throw new Error("GalleryItem must be a child of Gallery");
Expand Down Expand Up @@ -77,7 +77,7 @@ export const GalleryItem = React.forwardRef<Mesh, GalleryItemProps>(
}, [material, mesh]);

return (
<primitive object={mesh} ref={ref}>
<primitive object={mesh} ref={ref} {...rest}>
{children}
</primitive>
);
Expand Down
6 changes: 3 additions & 3 deletions src/components/GalleryItem/GalleryItem.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { PropsWithChildren } from "react";
import {
Material,
MeshBasicMaterial,
Expand All @@ -10,6 +9,7 @@ import {
PointsMaterial,
SpriteMaterial,
} from "three";
import { MeshProps } from "@react-three/fiber";

/**
* A flag to indicate that the gallery item has no provider.
Expand All @@ -27,12 +27,12 @@ export interface GalleryItemState {
/**
* The GalleryItem component properties.
*/
export type GalleryItemProps = PropsWithChildren<{
export type GalleryItemProps = MeshProps & {
/**
* The material to apply to the gallery item.
*/
material: Material | Material[];
}>;
};

/**
* This type represents materials having a map property.
Expand Down

0 comments on commit 00ef8b9

Please sign in to comment.