feat(ui): refine homepage and improve core interactions
This commit is contained in:
@@ -61,6 +61,12 @@ export function TryItWidget({
|
||||
|
||||
const handleFileChange = (file: File) => {
|
||||
const maxMB = tool.tryIt?.limits?.maxMB || 12;
|
||||
const acceptedTypes = ['image/jpeg', 'image/png', 'image/webp'];
|
||||
if (!acceptedTypes.includes(file.type)) {
|
||||
setStatus('error');
|
||||
setErrorMessage('Choose a JPG, PNG, or WebP image.');
|
||||
return;
|
||||
}
|
||||
if (file.size > maxMB * 1024 * 1024) {
|
||||
setStatus('error');
|
||||
setErrorMessage(`File exceeds ${maxMB}MB limit.`);
|
||||
@@ -210,6 +216,15 @@ export function TryItWidget({
|
||||
}}
|
||||
onDragLeave={() => setIsDragOver(false)}
|
||||
onClick={() => fileInputRef.current?.click()}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault();
|
||||
fileInputRef.current?.click();
|
||||
}
|
||||
}}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
aria-label="Choose a JPG, PNG, or WebP photo to edit"
|
||||
className={`border-2 border-dashed rounded-3xl p-8 sm:p-14 text-center cursor-pointer transition-all duration-300 group ${
|
||||
isDragOver
|
||||
? 'border-blue-500 bg-blue-50/50 scale-[1.01]'
|
||||
@@ -220,6 +235,7 @@ export function TryItWidget({
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
accept="image/jpeg,image/png,image/webp"
|
||||
accept="image/jpeg,image/png,image/webp"
|
||||
className="hidden"
|
||||
onChange={(e) => e.target.files?.[0] && handleFileChange(e.target.files[0])}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user