Skip to content

Commit

Permalink
Change style of mod upload button on drag and drop
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielv123 committed Feb 27, 2024
1 parent 2075814 commit ebf6536
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions packages/web_ui/src/components/ModsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import PageLayout from "./PageLayout";
import PluginExtra from "./PluginExtra";
import SectionHeader from "./SectionHeader";
import ModDetails from "./ModDetails";
import { InboxOutlined } from "@ant-design/icons";

const strcmp = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" }).compare;

Expand Down Expand Up @@ -131,6 +132,7 @@ export default function ModsPage() {
let navigate = useNavigate();
let [mods] = useMods();
let [modPacks] = useModPacks();
const [isDroppingFile, setIsDroppingFile] = useState(false);

function actions(mod: lib.ModInfo) {
return <Space>
Expand Down Expand Up @@ -173,11 +175,26 @@ export default function ModsPage() {
accept=".zip"
multiple
headers={{
"X-Access-Token": control.connector.token||"",
"X-Access-Token": control.connector.token || "",
}}
action={`${webRoot}api/upload-mod`}
>
<Button icon={<UploadOutlined/>}>Upload</Button>
<Button
onDragEnter={e => setIsDroppingFile(true)}
onDragLeave={e => {
// Only process if we are leaving the dropzone for an element that is not a child of the button
if ((e.currentTarget as Node).contains(e.relatedTarget as Node)) {
return;
}
setIsDroppingFile(false);
}}
onDrop={e => setIsDroppingFile(false)}
style={{
// Distinct border when dropping file
border: isDroppingFile ? "dashed 2px rgb(22, 119, 255)" : undefined,
}}
icon={isDroppingFile ? <InboxOutlined /> : <UploadOutlined />}
>Upload</Button>
</Upload>;
}

Expand Down

0 comments on commit ebf6536

Please sign in to comment.