Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 31 additions & 8 deletions src/tools/texture-lab/Canvas.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function Canvas({
viewMode,
onViewModeChange,
onMediaDrop,
onMediaLoad,
isPlaying,
currentTime,
duration,
Expand Down Expand Up @@ -187,6 +188,18 @@ export default function Canvas({
[onMediaDrop, isExporting]
);

const fileInputRef = useRef(null);
const handleFileSelect = useCallback(
e => {
const file = e.target.files?.[0];
if (file) {
onMediaLoad(file, 'file');
}
e.target.value = '';
},
[onMediaLoad]
);

return (
<Box
ref={containerRef}
Expand Down Expand Up @@ -435,15 +448,25 @@ export default function Canvas({
justify="center"
direction="column"
gap={1}
as= "button"
cursor="pointer"
onClick={() => fileInputRef.current?.click()}
>
<Box w="60px" h="60px" borderRadius="16px" display="flex" alignItems="center" justifyContent="center">
<Icon as={Upload} boxSize={8} color="var(--border-primary)" />
</Box>
<Text fontSize="14px" color="var(--text-muted)" textAlign="center">
Upload an image/video
<br />
to get started
</Text>
<input
type="file"
ref={fileInputRef}
onChange={handleFileSelect}
accept="image/png,image/jpeg,image/webp,video/mp4,video/webm,video/ogg"
style={{ display: 'none' }}
/>
<Box w="60px" h="60px" borderRadius="16px" display="flex" alignItems="center" justifyContent="center">
<Icon as={Upload} boxSize={8} color="var(--border-primary)" />
</Box>
<Text fontSize="14px" color="var(--text-muted)" textAlign="center">
Upload an image/video
<br />
to get started
</Text>
</Flex>
)}

Expand Down
1 change: 1 addition & 0 deletions src/tools/texture-lab/TextureLab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ export default function TextureLab({ toolSelector }) {
viewMode={viewMode}
onViewModeChange={handleViewModeChange}
onMediaDrop={file => handleMediaLoad(file, 'file')}
onMediaLoad={handleMediaLoad}
isPlaying={isPlaying}
currentTime={currentTime}
duration={duration}
Expand Down