Skip to content

Commit ffc2056

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

File tree

11 files changed

+423
-146
lines changed

11 files changed

+423
-146
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
tooltipLabel?: string;
14+
multiple?: boolean;
15+
}
16+
17+
export function ImageUploadButton(props: ImageUploadProps) {
18+
const fileInputRef = useRef<HTMLInputElement>(null);
19+
20+
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
21+
const files = Array.from(e.target.files || []);
22+
props.onChange?.(files);
23+
};
24+
25+
return (
26+
<div>
27+
<Button
28+
variant={props.variant}
29+
onClick={() => fileInputRef.current?.click()}
30+
className={props.className}
31+
>
32+
{props.children}
33+
</Button>
34+
<input
35+
ref={fileInputRef}
36+
type="file"
37+
multiple={props.multiple}
38+
accept="image/*"
39+
onChange={handleFileChange}
40+
className="hidden"
41+
aria-label="Upload image"
42+
/>
43+
</div>
44+
);
45+
}

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)