-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:reearth/reearth-visualizer into fea…
…t/project-recylebin
- Loading branch information
Showing
28 changed files
with
1,800 additions
and
1,435 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { useHasActiveGQLTasks } from "@reearth/services/state"; | ||
import { keyframes, styled } from "@reearth/services/theme"; | ||
import { FC, useCallback, useEffect, useState } from "react"; | ||
|
||
const offsetX = 16; | ||
const offsetY = 16; | ||
|
||
const CursorStatus: FC = () => { | ||
const [mousePosition, setMousePosition] = useState({ x: -100, y: -100 }); | ||
const [inView, setInView] = useState(true); | ||
const [enabled] = useHasActiveGQLTasks(); | ||
|
||
const handleMouseMove = useCallback((event: MouseEvent) => { | ||
setMousePosition({ | ||
x: event.clientX, | ||
y: event.clientY | ||
}); | ||
}, []); | ||
|
||
const handleMouseEnter = useCallback(() => { | ||
setInView(true); | ||
}, []); | ||
|
||
const handleMouseLeave = useCallback(() => { | ||
setInView(false); | ||
}, []); | ||
|
||
useEffect(() => { | ||
document.addEventListener("mousemove", handleMouseMove); | ||
document.addEventListener("mouseenter", handleMouseEnter); | ||
document.addEventListener("mouseleave", handleMouseLeave); | ||
return () => { | ||
document.removeEventListener("mousemove", handleMouseMove); | ||
document.removeEventListener("mouseenter", handleMouseEnter); | ||
document.removeEventListener("mouseleave", handleMouseLeave); | ||
}; | ||
}, [handleMouseMove, handleMouseEnter, handleMouseLeave]); | ||
|
||
return ( | ||
enabled && | ||
inView && ( | ||
<Wrapper left={mousePosition.x + offsetX} top={mousePosition.y + offsetY}> | ||
<Loader /> | ||
</Wrapper> | ||
) | ||
); | ||
}; | ||
|
||
export default CursorStatus; | ||
|
||
const Wrapper = styled("div")<{ left: number; top: number }>( | ||
({ left, top, theme }) => ({ | ||
position: "absolute", | ||
left: `${left}px`, | ||
top: `${top}px`, | ||
pointerEvents: "none", | ||
zIndex: theme.zIndexes.editor.loading | ||
}) | ||
); | ||
|
||
const loaderKeyframes = keyframes` | ||
100%{transform: rotate(1turn)} | ||
`; | ||
|
||
const loaderColor = "#ccc"; | ||
|
||
const Loader = styled("div")(() => ({ | ||
width: 24, | ||
aspectRatio: 1, | ||
borderRadius: "50%", | ||
background: `radial-gradient(farthest-side,${loaderColor} 100%,#0000) top/6px 6px no-repeat, conic-gradient(#0000 30%,${loaderColor})`, | ||
WebkitMask: "radial-gradient(farthest-side,#0000 calc(100% - 6px),#000 0)", | ||
animation: `${loaderKeyframes} 1s infinite linear` | ||
})); |
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
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
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
Oops, something went wrong.