|
|
@@ -1,25 +1,16 @@
|
|
|
-import { useEffect, useRef, useState } from 'react';
|
|
|
import { Button } from '@/components/ui/button.js';
|
|
|
import { Card, CardContent, CardHeader } from '@/components/ui/card.js';
|
|
|
-import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select.js';
|
|
|
+import { FormControl, FormField, FormItem, FormLabel } from '@/components/ui/form.js';
|
|
|
import { Input } from '@/components/ui/input.js';
|
|
|
import { Label } from '@/components/ui/label.js';
|
|
|
-import { Separator } from '@/components/ui/separator.js';
|
|
|
-import { Form, FormField, FormItem, FormLabel, FormControl } from '@/components/ui/form.js';
|
|
|
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select.js';
|
|
|
+import { VendureImage } from '@/components/shared/vendure-image.js';
|
|
|
+import { AssetFragment } from '@/graphql/fragments.js';
|
|
|
+import { cn, formatFileSize } from '@/lib/utils.js';
|
|
|
+import { ChevronLeft, ChevronRight, Crosshair, Edit, ExternalLink, X } from 'lucide-react';
|
|
|
+import { useEffect, useRef, useState } from 'react';
|
|
|
import { useForm } from 'react-hook-form';
|
|
|
-import { VendureImage } from '@/components/vendure-image.js';
|
|
|
-import {
|
|
|
- ChevronLeft,
|
|
|
- ChevronRight,
|
|
|
- Edit,
|
|
|
- ExternalLink,
|
|
|
- Tags,
|
|
|
- X,
|
|
|
- Crosshair
|
|
|
-} from 'lucide-react';
|
|
|
-import { cn } from '@/lib/utils.js';
|
|
|
import { FocalPointControl } from './focal-point-control.js';
|
|
|
-import { AssetFragment } from '@/graphql/fragments.js';
|
|
|
|
|
|
export type PreviewPreset = 'tiny' | 'thumb' | 'small' | 'medium' | 'large' | '';
|
|
|
|
|
|
@@ -28,7 +19,7 @@ interface Point {
|
|
|
y: number;
|
|
|
}
|
|
|
|
|
|
-export type Asset = AssetFragment;
|
|
|
+export type Asset = AssetFragment & { tags?: { value: string }[] };
|
|
|
|
|
|
interface AssetPreviewProps {
|
|
|
asset: Asset;
|
|
|
@@ -168,11 +159,7 @@ export function AssetPreview({
|
|
|
<Card>
|
|
|
<CardContent className="space-y-4 pt-6">
|
|
|
{!editable && onEditClick && (
|
|
|
- <Button
|
|
|
- variant="ghost"
|
|
|
- className="w-full justify-start"
|
|
|
- onClick={onEditClick}
|
|
|
- >
|
|
|
+ <Button variant="ghost" className="w-full justify-start" onClick={onEditClick}>
|
|
|
<Edit className="mr-2 h-4 w-4" />
|
|
|
Edit
|
|
|
<ChevronRight className="ml-auto h-4 w-4" />
|
|
|
@@ -195,9 +182,7 @@ export function AssetPreview({
|
|
|
) : (
|
|
|
<div>
|
|
|
<Label>Name</Label>
|
|
|
- <p className="truncate text-sm text-muted-foreground">
|
|
|
- {activeAsset.name}
|
|
|
- </p>
|
|
|
+ <p className="truncate text-sm text-muted-foreground">{activeAsset.name}</p>
|
|
|
</div>
|
|
|
)}
|
|
|
|
|
|
@@ -319,13 +304,10 @@ export function AssetPreview({
|
|
|
className={cn(
|
|
|
'relative',
|
|
|
centered && 'flex items-center justify-center',
|
|
|
- settingFocalPoint && 'cursor-crosshair'
|
|
|
+ settingFocalPoint && 'cursor-crosshair',
|
|
|
)}
|
|
|
>
|
|
|
- <div
|
|
|
- className="relative"
|
|
|
- style={{ width: `${width}px`, height: `${height}px` }}
|
|
|
- >
|
|
|
+ <div className="relative" style={{ width: `${width}px`, height: `${height}px` }}>
|
|
|
<VendureImage
|
|
|
ref={imageRef}
|
|
|
asset={activeAsset}
|
|
|
@@ -361,12 +343,3 @@ export function AssetPreview({
|
|
|
</div>
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
-// Helper function to format file size
|
|
|
-function formatFileSize(bytes: number): string {
|
|
|
- if (bytes === 0) return '0 Bytes';
|
|
|
- const k = 1024;
|
|
|
- const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
|
|
- const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
|
- return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
|
-}
|