Skip to content

Commit dafaa76

Browse files
committed
[NEB-210] Nebula: Add image upload
1 parent a68ec74 commit dafaa76

File tree

12 files changed

+485
-170
lines changed

12 files changed

+485
-170
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"use client";
2+
3+
import { Button } from "@/components/ui/button";
4+
import type React from "react";
5+
import { useRef } from "react";
6+
7+
interface ImageUploadProps {
8+
value: File | undefined;
9+
onChange?: (files: File[]) => void;
10+
children?: React.ReactNode;
11+
variant?: React.ComponentProps<typeof Button>["variant"];
12+
className?: string;
13+
multiple?: boolean;
14+
}
15+
16+
export function ImageUploadButton(props: ImageUploadProps) {
17+
const fileInputRef = useRef<HTMLInputElement>(null);
18+
19+
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
20+
const files = Array.from(e.target.files || []);
21+
props.onChange?.(files);
22+
};
23+
24+
return (
25+
<div>
26+
<Button
27+
variant={props.variant}
28+
onClick={() => fileInputRef.current?.click()}
29+
className={props.className}
30+
>
31+
{props.children}
32+
</Button>
33+
<input
34+
ref={fileInputRef}
35+
type="file"
36+
multiple={props.multiple}
37+
accept="image/*"
38+
onChange={handleFileChange}
39+
className="hidden"
40+
aria-label="Upload image"
41+
/>
42+
</div>
43+
);
44+
}

apps/dashboard/src/app/nebula-app/(app)/api/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ type NebulaUserMessageContentItem =
88
type: "image";
99
image_url: string;
1010
}
11+
| {
12+
type: "image";
13+
b64: string;
14+
}
1115
| {
1216
type: "text";
1317
text: string;

0 commit comments

Comments
 (0)