@@ -12,6 +12,7 @@ import { Button } from "@/components/ui/button";
1212import { FormControl , FormLabel } from "@/components/ui/form" ;
1313import { Input } from "@/components/ui/input" ;
1414import { ImageType } from "@/config/enums" ;
15+ import type { ImageSize } from "@/features/abstract-resource-form" ;
1516import { ApiImage , uploadFile , useMutationWrapper } from "@/features/backend" ;
1617import { declineNoun } from "@/features/polish" ;
1718import type { Resource } from "@/features/resources" ;
@@ -20,15 +21,40 @@ import type {
2021 ResourceSchemaKey ,
2122} from "@/features/resources/types" ;
2223import { getToastMessages } from "@/lib/get-toast-messages" ;
24+ import { cn } from "@/lib/utils" ;
2325import type { WrapperProps } from "@/types/components" ;
2426
2527import { ImagePreviewModal } from "../presentation/image-preview-modal" ;
2628
27- function InputBox ( { children } : WrapperProps ) {
29+ function getImageSizeClasses ( size : ImageSize ) : string {
30+ switch ( size ) {
31+ case "small" : {
32+ return "md:size-32" ;
33+ }
34+ case "medium" : {
35+ return "md:size-48" ;
36+ }
37+ case "large" : {
38+ return "md:size-64" ;
39+ }
40+ case "wide" : {
41+ return "md:h-48 md:w-full aspect-video" ;
42+ }
43+ }
44+ }
45+
46+ function InputBox ( {
47+ children,
48+ size = "medium" ,
49+ } : WrapperProps & { size ?: ImageSize } ) {
2850 return (
2951 < InputSlot
3052 renderAs = "div"
31- className = "aspect-video h-fit max-h-48 w-full overflow-hidden rounded-lg md:size-48"
53+ className = { cn (
54+ "h-fit w-full overflow-hidden rounded-lg" ,
55+ size !== "wide" && "aspect-video max-h-48" ,
56+ getImageSizeClasses ( size ) ,
57+ ) }
3258 >
3359 { children }
3460 </ InputSlot >
@@ -41,6 +67,7 @@ export function ImageUpload<T extends Resource>({
4167 value,
4268 label,
4369 type = ImageType . Logo ,
70+ size = "medium" ,
4471 existingImage,
4572 resourceData,
4673 disabled,
@@ -50,6 +77,7 @@ export function ImageUpload<T extends Resource>({
5077 onChange : ( value : string | null ) => void ;
5178 label : string ;
5279 type ?: ImageType ;
80+ size ?: ImageSize ;
5381 existingImage ?: ReactNode ;
5482 resourceData ?: ResourceFormValues < T > ;
5583 disabled ?: boolean ;
@@ -112,7 +140,7 @@ export function ImageUpload<T extends Resource>({
112140 < FormLabel className = "flex flex-col items-start space-y-1.5" >
113141 { label }
114142 { hasImage ? null : (
115- < InputBox >
143+ < InputBox size = { size } >
116144 < div className = "flex size-full cursor-pointer flex-col items-center justify-center" >
117145 < Camera className = "text-image-input-icon size-12" />
118146 < span className = "text-muted-foreground text-xs" >
@@ -123,7 +151,7 @@ export function ImageUpload<T extends Resource>({
123151 ) }
124152 </ FormLabel >
125153 { hasImage ? (
126- < InputBox >
154+ < InputBox size = { size } >
127155 < FormControl >
128156 < Button
129157 type = "button"
0 commit comments