Skip to content

Commit

Permalink
misc checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
codekansas committed Aug 7, 2024
1 parent de22d44 commit 3e21dca
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 69 deletions.
58 changes: 30 additions & 28 deletions frontend/src/components/listing/ListingImages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ const ListingImages = (props: Props) => {
}
};

return (
return images.length > 0 || edit ? (
<div className="flex flex-col items-center justify-center my-4 p-4 relative">
<Button
onClick={() => setCollapsed(!collapsed)}
variant="outline"
className="mt-2 mb-4 text-3xl p-6"
>
Images
{collapsed ? (
<FaCaretSquareUp className="ml-4 text-gray-700" />
) : (
<FaCaretSquareDown className="ml-4 text-gray-700" />
)}
</Button>
{!collapsed && (
<div>
{images.length > 0 && (
{images.length > 0 && (
<>
<Button
onClick={() => setCollapsed(!collapsed)}
variant="outline"
className="mt-2 mb-4 text-md p-4"
>
Images
{collapsed ? (
<FaCaretSquareUp className="ml-4 text-gray-700" />
) : (
<FaCaretSquareDown className="ml-4 text-gray-700" />
)}
</Button>
{!collapsed && (
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-2 gap-2 mx-auto">
{images.map((image) => (
<div
Expand All @@ -86,20 +86,22 @@ const ListingImages = (props: Props) => {
))}
</div>
)}
{edit && (
<ListingFileUpload
artifactType="image"
fileExtensions={[".jpg", ".jpeg", ".png"]}
maxSize={4 * 1024 * 1024}
listingId={listingId}
onUpload={(artifact) => {
setImages([...images, artifact.artifact]);
}}
/>
)}
</div>
</>
)}
{edit && (
<ListingFileUpload
artifactType="image"
fileExtensions={[".jpg", ".jpeg", ".png"]}
maxSize={4 * 1024 * 1024}
listingId={listingId}
onUpload={(artifact) => {
setImages([...images, artifact.artifact]);
}}
/>
)}
</div>
) : (
<></>
);
};

Expand Down
82 changes: 41 additions & 41 deletions frontend/src/components/listing/ListingSTLs.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Canvas, useLoader } from "@react-three/fiber";
import { useLoader } from "@react-three/fiber";
import ListingFileUpload from "components/listing/ListingFileUpload";
import { Button } from "components/ui/Button/Button";
import { components } from "gen/api";
Expand All @@ -7,6 +7,7 @@ import { useAuthentication } from "hooks/useAuth";
import { useState } from "react";
import { FaCaretSquareDown, FaCaretSquareUp, FaTimes } from "react-icons/fa";
import { STLLoader } from "three/examples/jsm/loaders/STLLoader";
import { OBJLoader } from 'three/addons/loaders/OBJLoader';

const Model = ({ url }: { url: string }) => {
const stl = useLoader(STLLoader, url);
Expand All @@ -20,13 +21,15 @@ interface SingleStlViewerProps {
const SingleStlViewer = (props: SingleStlViewerProps) => {
const { url } = props;

return (
<Canvas onError={(error) => console.log(error)}>
<ambientLight />
<pointLight position={[10, 10, 10]} />
<Model url={url} />
</Canvas>
);
// return (
// <Canvas onError={(error) => console.log(error)}>
// <ambientLight />
// <pointLight position={[10, 10, 10]} />
// <Model url={url} />
// </Canvas>
// );

return <div>{url}</div>;
};

interface Props {
Expand Down Expand Up @@ -67,34 +70,29 @@ const ListingSTLs = (props: Props) => {
}
};

return (
return stls.length > 0 || edit ? (
<div className="flex flex-col items-center justify-center my-4 p-4 relative">
<Button
onClick={() => setCollapsed(!collapsed)}
variant="outline"
className="mt-2 mb-4 text-3xl p-6"
>
STLs
{collapsed ? (
<FaCaretSquareUp className="ml-4 text-gray-700" />
) : (
<FaCaretSquareDown className="ml-4 text-gray-700" />
)}
</Button>
{!collapsed && (
<div>
{stls.length > 0 && (
{stls.length > 0 && (
<>
<Button
onClick={() => setCollapsed(!collapsed)}
variant="outline"
className="mt-2 mb-4 text-md p-4"
>
STLs
{collapsed ? (
<FaCaretSquareUp className="ml-4 text-gray-700" />
) : (
<FaCaretSquareDown className="ml-4 text-gray-700" />
)}
</Button>
{!collapsed && (
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-2 gap-2 mx-auto">
{stls.map((stl) => (
<div
key={stl.artifact_id}
className="bg-background rounded-lg p-2 relative"
>
{/* <img
src={stl.url}
alt={stl.name}
className="rounded-lg w-full aspect-square"
/> */}
<SingleStlViewer url={stl.url} />
{edit && (
<Button
Expand All @@ -110,20 +108,22 @@ const ListingSTLs = (props: Props) => {
))}
</div>
)}
{edit && (
<ListingFileUpload
artifactType="stl"
fileExtensions={[".stl"]}
maxSize={4 * 1024 * 1024}
listingId={listingId}
onUpload={(artifact) => {
setStls([...stls, artifact.artifact]);
}}
/>
)}
</div>
</>
)}
{edit && (
<ListingFileUpload
artifactType="stl"
fileExtensions={[".stl"]}
maxSize={4 * 1024 * 1024}
listingId={listingId}
onUpload={(artifact) => {
setStls([...stls, artifact.artifact]);
}}
/>
)}
</div>
) : (
<></>
);
};

Expand Down

0 comments on commit 3e21dca

Please sign in to comment.