mirror of
https://github.com/sunrin-ana/2025-SSF-Frontend.git
synced 2026-03-09 18:30:00 +00:00
test
This commit is contained in:
parent
6c6a88931c
commit
afe581ec34
69 changed files with 12702 additions and 25 deletions
43
src/components/features/diary/UploadImages.tsx
Normal file
43
src/components/features/diary/UploadImages.tsx
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
// src/components/PhotoUploadModal.tsx
|
||||
|
||||
import { component$, useSignal, Signal, $ } from '@builder.io/qwik';
|
||||
|
||||
type FileInfo = {
|
||||
name: string;
|
||||
size: number;
|
||||
type: string;
|
||||
lastModified: number;
|
||||
url?: string;
|
||||
};
|
||||
|
||||
export const PhotoUploadModal = component$(({ selectedImages, showPhotoUploadModal }: { selectedImages: Signal<File[]>, showPhotoUploadModal: Signal<boolean> }) => {
|
||||
|
||||
const fileInfo = useSignal<FileInfo | null>(null);
|
||||
const fileRef = useSignal<File | null>(null);
|
||||
const error = useSignal('');
|
||||
const fileInputRef = useSignal<HTMLInputElement>();
|
||||
|
||||
const handleFileSelect = $(async (selectedFile: File) => {
|
||||
if (selectedFile && selectedFile.type.startsWith('image/')) {
|
||||
fileInfo.value = {
|
||||
name: selectedFile.name,
|
||||
size: selectedFile.size,
|
||||
type: selectedFile.type,
|
||||
lastModified: selectedFile.lastModified,
|
||||
url: URL.createObjectURL(selectedFile)
|
||||
};
|
||||
fileRef.value = selectedFile;
|
||||
error.value = '';
|
||||
} else {
|
||||
error.value = '이미지 파일만 업로드 가능합니다.';
|
||||
fileInfo.value = null;
|
||||
fileRef.value = null;
|
||||
}
|
||||
});
|
||||
|
||||
if (!showPhotoUploadModal.value) return null;
|
||||
|
||||
return (
|
||||
|
||||
);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue