fix: upgrade tip when player open

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei
2024-08-02 12:22:17 +08:00
parent fc5075139f
commit 033831bdab
2 changed files with 39 additions and 2 deletions
@@ -1,8 +1,10 @@
import { usePlayerAtomSelector } from "@renderer/atoms/player"
import { setUpdaterStatus, useUpdaterStatus } from "@renderer/atoms/updater"
import { softBouncePreset } from "@renderer/components/ui/constants/spring"
import { tipcClient } from "@renderer/lib/client"
import { cn } from "@renderer/lib/utils"
import { handlers } from "@renderer/tipc"
import { m } from "framer-motion"
import { m, useMotionTemplate, useMotionValue } from "framer-motion"
import { useCallback, useEffect } from "react"
export const AutoUpdater = () => {
@@ -22,16 +24,47 @@ export const AutoUpdater = () => {
tipcClient?.quitAndInstall()
}, [])
const playerIsShow = usePlayerAtomSelector((s) => s.show)
const mouseX = useMotionValue(0)
const mouseY = useMotionValue(0)
const radius = useMotionValue(0)
const handleMouseMove = useCallback(
({ clientX, clientY, currentTarget }: React.MouseEvent) => {
const bounds = currentTarget.getBoundingClientRect()
mouseX.set(clientX - bounds.left)
mouseY.set(clientY - bounds.top)
radius.set(Math.hypot(bounds.width, bounds.height) * 1.3)
},
[mouseX, mouseY, radius],
)
const background = useMotionTemplate`radial-gradient(${radius}px circle at ${mouseX}px ${mouseY}px, var(--a) 0%, transparent 65%)`
if (!updaterStatus) return null
return (
<m.div
className="absolute inset-x-3 bottom-3 rounded-lg bg-theme-modal-background py-3 text-center text-sm shadow backdrop-blur"
onMouseMove={handleMouseMove}
className={cn(
"group absolute inset-x-3 bottom-3 cursor-pointer overflow-hidden rounded-lg bg-theme-modal-background py-3 text-center text-sm shadow backdrop-blur",
playerIsShow && "bottom-28",
)}
onClick={handleClick}
initial={{ y: 50, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
transition={softBouncePreset}
>
<m.div
layout
className="absolute inset-0 opacity-0 duration-500 group-hover:opacity-5"
style={
{
background,
} as any
}
/>
<div className="font-medium">
{APP_NAME}
{" "}
+4
View File
@@ -50,6 +50,10 @@
}
}
:root {
--a: theme("colors.theme.accent.DEFAULT");
}
@layer base {
* {
@apply border-border;