Spaces:
Running
Running
Commit ·
f817984
1
Parent(s): 584945d
fix(canvas): align tooltips perfectly using pure CSS group hover transitions
Browse files1234515 unmodified lines21222324252627282930313233343536375 unmodified lines4344454647484950515253545556575859606162import React, { useState } from 'react';import { motion, AnimatePresence } from 'framer-motion';import { useTranslation } from 'react-i18next';import {Sparkles,15 unmodified lines} from 'lucide-react';const TooltipButton = ({ children, tooltip, onClick, disabled = false, className = "", active = false }) => {const [hovered, setHovered] = useState(false);return (<div className="relative flex items-center"><motion.buttonwhileHover={{ scale: disabled ? 1 : 1.05 }}whileTap={{ scale: disabled ? 1 : 0.95 }}onClick={onClick}disabled={disabled}onMouseEnter={() => setHovered(true)}onMouseLeave={() => setHovered(false)}className={`p-1.5 rounded-xl transition-all relative border-2 flex items-center justify-center ${active? 'bg-primary text-white border-primary shadow-[2px_2px_0px_0px_var(--color-primary)]'5 unmodified lines{children}</motion.button><AnimatePresence>{hovered && (<motion.divinitial={{ opacity: 0, x: -10, y: "-50%" }}animate={{ opacity: 1, x: 0, y: "-50%" }}exit={{ opacity: 0, x: -10, y: "-50%" }}transition={{ duration: 0.15 }}className="absolute left-full top-1/2 -translate-y-1/2 ml-3 px-3 py-1.5 bg-primary text-on-primary font-bold text-xs rounded-md shadow-lg border border-primary/20 whitespace-nowrap z-50 pointer-events-none">{tooltip}<div className="absolute right-full top-1/2 -translate-y-1/2 border-8 border-transparent border-r-primary"></div></motion.div>)}</AnimatePresence></div>);};1234515 unmodified lines212223242526272829303132335 unmodified lines394041424344454647484950import React from 'react';import { motion } from 'framer-motion';import { useTranslation } from 'react-i18next';import {Sparkles,15 unmodified lines} from 'lucide-react';const TooltipButton = ({ children, tooltip, onClick, disabled = false, className = "", active = false }) => {return (<div className="relative flex items-center group"><motion.buttonwhileHover={{ scale: disabled ? 1 : 1.05 }}whileTap={{ scale: disabled ? 1 : 0.95 }}onClick={onClick}disabled={disabled}className={`p-1.5 rounded-xl transition-all relative border-2 flex items-center justify-center ${active? 'bg-primary text-white border-primary shadow-[2px_2px_0px_0px_var(--color-primary)]'5 unmodified lines{children}</motion.button>{!disabled && (<div className="absolute left-full top-1/2 -translate-y-1/2 ml-3 px-3 py-1.5 bg-primary text-on-primary font-bold text-xs rounded-md shadow-lg border border-primary/20 whitespace-nowrap z-50 pointer-events-none opacity-0 translate-x-2 group-hover:opacity-100 group-hover:translate-x-0 transition-all duration-150 ease-out">{tooltip}<div className="absolute right-full top-1/2 -translate-y-1/2 border-8 border-transparent border-r-primary"></div></div>)}</div>);};
src/features/canvas/components/CanvasToolbar.jsx+9-21