-
-
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.
refactor page-game components + overwrite saves button
- Loading branch information
1 parent
3d69168
commit 7e6d4f7
Showing
8 changed files
with
232 additions
and
107 deletions.
There are no files selected for viewing
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,9 +1,15 @@ | ||
package utils | ||
|
||
import ( | ||
"os" | ||
|
||
cp "github.com/otiai10/copy" | ||
) | ||
|
||
func CopyDir(src, dst string) error { | ||
// hard copy (remove target dir and then copy) | ||
if err := os.RemoveAll(dst); err != nil { | ||
return err | ||
} | ||
return cp.Copy(src, dst) | ||
} |
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,55 @@ | ||
import { Button, Chip } from "@material-tailwind/react"; | ||
import clsx from "clsx"; | ||
import { FaFolderOpen } from "react-icons/fa6"; | ||
import WithTooltip from "@/components/WithTooltip"; | ||
|
||
type QuickSaveChipProps = { | ||
enabled: boolean; | ||
onClose: () => void; | ||
onOpen: () => void; | ||
}; | ||
|
||
const QuickSaveChip = (props: QuickSaveChipProps) => { | ||
return ( | ||
<div className="flex gap-4"> | ||
<Chip | ||
className={clsx({ | ||
"[&_button]:pointer-events-none [&_button]:opacity-50": | ||
!props.enabled, | ||
})} | ||
variant="ghost" | ||
color={props.enabled ? "green" : "red"} | ||
size="sm" | ||
value={ | ||
<div className="flex items-center gap-2"> | ||
<span>Quick Save</span> | ||
|
||
<WithTooltip content="Open" placement="top"> | ||
<Button | ||
onClick={() => props.onOpen()} | ||
className="p-0.5" | ||
variant="text" | ||
> | ||
<FaFolderOpen size={12} /> | ||
</Button> | ||
</WithTooltip> | ||
</div> | ||
} | ||
onClose={() => props.onClose()} | ||
icon={ | ||
<span | ||
className={clsx( | ||
"mx-auto mt-1 block h-2 w-2 rounded-full content-['']", | ||
{ | ||
"bg-red-900": !props.enabled, | ||
"bg-green-900": props.enabled, | ||
}, | ||
)} | ||
/> | ||
} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default QuickSaveChip; |
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,77 @@ | ||
import { Button, Typography } from "@material-tailwind/react"; | ||
import { FaDownload, FaFolderOpen, FaTrash, FaUpload } from "react-icons/fa6"; | ||
import { type SaveSingle } from "@/hooks/useSave"; | ||
import WithTooltip from "@/components/WithTooltip"; | ||
|
||
type SavePropsCallback = () => Promise<void> | void; | ||
|
||
type SaveProps = { | ||
data: SaveSingle; | ||
onLoad: SavePropsCallback; | ||
onSave: SavePropsCallback; | ||
onDelete: SavePropsCallback; | ||
onOpenDirectory: SavePropsCallback; | ||
}; | ||
|
||
const Save = (props: SaveProps) => { | ||
const formatDate = (dateString: string) => { | ||
const date = new Date(dateString); | ||
const intlDate = new Intl.DateTimeFormat("en-US").format(date); | ||
return intlDate; | ||
}; | ||
|
||
return ( | ||
<div | ||
className="grid grid-cols-12 items-center justify-between break-all even:bg-blue-gray-50/50" | ||
key={props.data.Name} | ||
> | ||
<div className="col-span-7 flex items-center gap-2"> | ||
<div> | ||
<WithTooltip content="Load" placement="top"> | ||
<Button | ||
onClick={() => props.onLoad()} | ||
className="p-3" | ||
variant="text" | ||
> | ||
<FaUpload size={15} /> | ||
</Button> | ||
</WithTooltip> | ||
|
||
<WithTooltip content="Save" placement="top"> | ||
<Button | ||
onClick={() => props.onSave()} | ||
className="p-3" | ||
variant="text" | ||
> | ||
<FaDownload size={15} /> | ||
</Button> | ||
</WithTooltip> | ||
</div> | ||
|
||
<Typography>{props.data.Name}</Typography> | ||
</div> | ||
|
||
<Typography className="col-span-3 px-2"> | ||
{formatDate(props.data.CreatedAt)} | ||
</Typography> | ||
|
||
<WithTooltip content="Open" placement="top"> | ||
<Button | ||
onClick={() => props.onOpenDirectory()} | ||
className="p-3" | ||
variant="text" | ||
> | ||
<FaFolderOpen size={15} /> | ||
</Button> | ||
</WithTooltip> | ||
|
||
<WithTooltip content="Delete" placement="top"> | ||
<Button onClick={() => props.onDelete()} className="p-3" variant="text"> | ||
<FaTrash size={15} /> | ||
</Button> | ||
</WithTooltip> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Save; |
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,26 @@ | ||
import { Tooltip, Typography } from "@material-tailwind/react"; | ||
import { type ReactElement } from "react"; | ||
|
||
type WithTooltipProps = { | ||
children: ReactElement; | ||
content: string; | ||
placement: string; | ||
}; | ||
|
||
const WithTooltip = (props: WithTooltipProps) => { | ||
return ( | ||
<Tooltip | ||
content={ | ||
<Typography className="text-black" variant="small"> | ||
{props.content} | ||
</Typography> | ||
} | ||
placement={props.placement} | ||
className="border border-blue-gray-50 bg-white shadow-xl shadow-black/10" | ||
> | ||
{props.children} | ||
</Tooltip> | ||
); | ||
}; | ||
|
||
export default WithTooltip; |
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
Oops, something went wrong.