chore: consolidate platform split checks
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useRef, useState, type CSSProperties, type ReactNode } from "react";
|
||||
import { i18nMessage } from "../i18n/LanguageContext";import { useRef, useState, type CSSProperties, type ReactNode } from "react";
|
||||
import { UploadCloud } from "lucide-react";
|
||||
|
||||
export type FileDropZoneProps = {
|
||||
@@ -23,13 +23,13 @@ export default function FileDropZone({
|
||||
disabled = false,
|
||||
busy = false,
|
||||
progress = null,
|
||||
label = "Drop files here",
|
||||
actionLabel = "or click to select files",
|
||||
busyLabel = "Uploading files",
|
||||
label = "i18n:govoplan-core.drop_files_here.77348907",
|
||||
actionLabel = "i18n:govoplan-core.or_click_to_select_files.91b05dc1",
|
||||
busyLabel = "i18n:govoplan-core.uploading_files.6536791d",
|
||||
progressLabel,
|
||||
note,
|
||||
className = "",
|
||||
inputLabel = "Drop files here or click to select files",
|
||||
inputLabel = "i18n:govoplan-core.drop_files_here_or_click_to_select_files.7eda8608",
|
||||
onFiles
|
||||
}: FileDropZoneProps) {
|
||||
const inputRef = useRef<HTMLInputElement | null>(null);
|
||||
@@ -79,25 +79,25 @@ export default function FileDropZone({
|
||||
event.preventDefault();
|
||||
setDragActive(false);
|
||||
if (!interactionDisabled) void handleFiles(event.dataTransfer.files);
|
||||
}}
|
||||
>
|
||||
{showProgress ? (
|
||||
<span
|
||||
className={`file-drop-progress ${progressValue === null ? "is-indeterminate" : ""}`.trim()}
|
||||
role="progressbar"
|
||||
aria-label="Upload progress"
|
||||
aria-valuemin={0}
|
||||
aria-valuemax={100}
|
||||
aria-valuenow={roundedProgress ?? undefined}
|
||||
style={progressStyle}
|
||||
>
|
||||
<span>{roundedProgress === null ? "" : `${roundedProgress}%`}</span>
|
||||
</span>
|
||||
) : (
|
||||
<UploadCloud size={28} aria-hidden="true" />
|
||||
)}
|
||||
}}>
|
||||
|
||||
{showProgress ?
|
||||
<span
|
||||
className={`file-drop-progress ${progressValue === null ? "is-indeterminate" : ""}`.trim()}
|
||||
role="progressbar"
|
||||
aria-label="i18n:govoplan-core.upload_progress.927d75fe"
|
||||
aria-valuemin={0}
|
||||
aria-valuemax={100}
|
||||
aria-valuenow={roundedProgress ?? undefined}
|
||||
style={progressStyle}>
|
||||
|
||||
<span>{roundedProgress === null ? "" : i18nMessage("i18n:govoplan-core.value.8c5f2c0e", { value0: roundedProgress })}</span>
|
||||
</span> :
|
||||
|
||||
<UploadCloud size={28} aria-hidden="true" />
|
||||
}
|
||||
<strong>{showProgress ? busyLabel : label}</strong>
|
||||
<span>{showProgress ? progressLabel ?? (roundedProgress === null ? "Uploading…" : `${roundedProgress}% uploaded`) : actionLabel}</span>
|
||||
<span>{showProgress ? progressLabel ?? (roundedProgress === null ? "i18n:govoplan-core.uploading.d921a79a" : i18nMessage("i18n:govoplan-core.value_uploaded.2c4bcc60", { value0: roundedProgress })) : actionLabel}</span>
|
||||
{note && <span className="muted small-text">{note}</span>}
|
||||
</div>
|
||||
<input
|
||||
@@ -106,8 +106,8 @@ export default function FileDropZone({
|
||||
accept={accept}
|
||||
multiple={multiple}
|
||||
hidden
|
||||
onChange={(event) => event.target.files && void handleFiles(event.target.files)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
onChange={(event) => event.target.files && void handleFiles(event.target.files)} />
|
||||
|
||||
</>);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user