-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f02ac24
commit 4158dd3
Showing
11 changed files
with
118 additions
and
40 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { commandManager } from "actions/commandManager"; | ||
import { useMemo } from "react"; | ||
import { IconContext } from "react-icons"; | ||
import { BsFillPaletteFill } from "react-icons/bs"; | ||
import { MdUndo } from "react-icons/md"; | ||
import { useStore } from "store"; | ||
const { setIsToolbarElementConfigOpen } = useStore.getState(); | ||
const ToolbarLower = () => { | ||
const selectedElements = useStore((state) => state.selectedElements); | ||
const isToolbarElementConfigOpen = useStore((state) => state.isToolbarElementConfigOpen); | ||
const openToolbarELementConfigButton = useMemo(() => { | ||
if (selectedElements.length > 0) { | ||
return ( | ||
<button | ||
onClick={() => setIsToolbarElementConfigOpen(!isToolbarElementConfigOpen)} | ||
className="flex h-10 w-full flex-col items-center justify-center"> | ||
<BsFillPaletteFill /> | ||
</button> | ||
); | ||
} | ||
return null; | ||
}, [selectedElements.length, isToolbarElementConfigOpen]); | ||
return ( | ||
<div className="bg-primary-600 fixed inset-x-0 bottom-2 mx-auto flex h-fit w-11/12 items-center justify-stretch rounded-lg p-2 md:invisible"> | ||
<IconContext.Provider | ||
value={{ | ||
className: "fill-gray-300", | ||
size: "1.5rem", | ||
}}> | ||
<button | ||
className="flex h-10 w-full flex-col items-center justify-center" | ||
onClick={() => { | ||
commandManager.undoCommand(); | ||
}}> | ||
<MdUndo /> | ||
</button> | ||
{openToolbarELementConfigButton} | ||
</IconContext.Provider> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ToolbarLower; |
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,15 @@ | ||
import { useCallback } from "react"; | ||
import { useStore } from "store"; | ||
import { useGlobalEvent } from "./useGlobalEvent"; | ||
const { setIsMobile } = useStore.getState(); | ||
const useIsMobile = () => { | ||
const isMobileCallback = useCallback(() => { | ||
if (typeof window === "undefined") return false; | ||
if (window.innerWidth > 768) return false; | ||
setIsMobile(true); | ||
}, []); | ||
useGlobalEvent("resize", isMobileCallback); | ||
useGlobalEvent("orientationchange", isMobileCallback); | ||
useGlobalEvent("load", isMobileCallback); | ||
}; | ||
export { useIsMobile }; |
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