-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new install panel with drag and drop functionality
- Loading branch information
Showing
22 changed files
with
128 additions
and
26 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { useEffect } from "react"; | ||
import { useMutation, useQueryClient } from "@tanstack/react-query"; | ||
import { DownloadIcon } from "lucide-react"; | ||
import { OnFileDrop, OnFileDropOff } from "@wailsjs/runtime/runtime"; | ||
import { QUERY_KEYS } from "@/constants"; | ||
import { installMod } from "@/lib/install"; | ||
import { cn } from "@/lib/utils"; | ||
import { | ||
Popover, | ||
PopoverContent, | ||
PopoverTrigger, | ||
} from "@/components/ui/popover"; | ||
|
||
interface InstallPanelProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
export default function InstallPanel({ children }: InstallPanelProps) { | ||
const queryClient = useQueryClient(); | ||
const { mutate, isPending } = useMutation({ | ||
mutationFn: installMod, | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: [QUERY_KEYS.getAllMods] }); | ||
}, | ||
}); | ||
|
||
useEffect(() => { | ||
OnFileDrop((_x, _y, paths) => { | ||
if (paths.length < 1) return; | ||
|
||
mutate(paths[0]); | ||
}, true); | ||
|
||
return () => { | ||
OnFileDropOff(); | ||
}; | ||
}, []); | ||
|
||
const preventDoubleClick = (e: React.MouseEvent<HTMLDivElement>) => { | ||
if (e.detail === 2) { | ||
e.stopPropagation(); | ||
} | ||
}; | ||
|
||
return ( | ||
<Popover> | ||
<PopoverTrigger asChild>{children}</PopoverTrigger> | ||
<PopoverContent | ||
onClick={preventDoubleClick} | ||
className="flex w-[400px] flex-col gap-y-4" | ||
> | ||
<h1 className="font-bold">Install Mods</h1> | ||
<div | ||
onClick={() => mutate("")} | ||
className={cn( | ||
"relative flex aspect-video w-full cursor-pointer flex-col items-center justify-center gap-y-3 rounded border border-dashed data-[wails-drop-target-active]:bg-red-500", | ||
isPending && "animate-pulse" | ||
)} | ||
style={{ "--wails-drop-target": "drop" } as React.CSSProperties} | ||
> | ||
<DownloadIcon className="size-8 text-muted-foreground" /> | ||
<p className="text-sm text-muted-foreground"> | ||
Install mods by dropping or clicking here. | ||
</p> | ||
</div> | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
export const GITHUB_URL = "https://github.com/fly2z/aeromod"; | ||
|
||
export const QUERY_KEYS = { | ||
getAllMods: "getAllMods", | ||
getModNames: "getModNames", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,4 @@ | |
} | ||
}, | ||
"include": ["src"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ | |
"noFallthroughCasesInSwitch": true | ||
}, | ||
"include": ["vite.config.ts"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters