mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 07:33:12 +09:00
Correctly disable dropzone when host is offline
This commit is contained in:
1 parent
05b697fd24
commit
c6abe29e89
4 files changed
+22
-13
No files matched your search
@@ -3,11 +3,19 @@ import { DraggingContext } from "../model/is_dragging";
|
||||
import { useContext } from "react";
|
||||
|
||||
// This component is used to display a dropzone when a file is being dragged over the parent component
|
||||
export function Dropzone() {
|
||||
export function Dropzone({ disabled = false }: { disabled?: boolean }) {
|
||||
const isDroppingFile = useContext(DraggingContext);
|
||||
|
||||
const textStyle: { color?: string } = {};
|
||||
let text = "Drop to upload";
|
||||
if (disabled) {
|
||||
textStyle.color = "red";
|
||||
text = "Target is offline";
|
||||
}
|
||||
const borderColor = disabled ? "gray" : "rgb(22, 119, 255)";
|
||||
|
||||
return <div
|
||||
className="dropzone" // Don't remove this class, linked to SiteLayout.tsx
|
||||
className={`dropzone ${disabled ? "disabled" : "enabled"}`} // Don't remove this class, linked to SiteLayout
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: "0",
|
||||
@@ -17,7 +25,7 @@ export function Dropzone() {
|
||||
zIndex: "90",
|
||||
backgroundColor: "#88888844",
|
||||
borderRadius: "20px",
|
||||
border: "dashed 2px rgb(22, 119, 255)",
|
||||
border: `dashed 2px ${borderColor}`,
|
||||
display: isDroppingFile ? "block" : "none",
|
||||
}}
|
||||
>
|
||||
@@ -34,9 +42,9 @@ export function Dropzone() {
|
||||
height: "100%",
|
||||
}}
|
||||
>
|
||||
<InboxOutlined />
|
||||
<p style={{ fontSize: "24px", display: "block", textAlign: "center", marginTop: "8px" }}>
|
||||
Drop to upload
|
||||
<InboxOutlined style={textStyle} />
|
||||
<p style={{ ...textStyle, fontSize: "24px", display: "block", textAlign: "center", marginTop: "8px" }}>
|
||||
{text}
|
||||
</p>
|
||||
</div>
|
||||
</div>;
|
||||
|
||||
Reference in new issue
Block a user