@@ -6,29 +6,29 @@ import { ChatContext } from "./context/ChatContext";
66
77export function Widget ( ) {
88 // const [isOpen, setIsOpen] = useState(false);
9- const { profile, token } = useContext ( AuthContext ) ;
9+ const { profile, token, notifications } = useContext ( AuthContext ) ;
1010 const { toggleChat, isOpen} = useContext ( ChatContext ) ;
11-
11+ const unreadChats = notifications . filter ( n => n . type === 1 ) . length ;
1212 // const toggleChat = () => {
1313 // setIsOpen(!isOpen);
1414 // };
1515
16- return (
16+ return (
1717 < >
1818 { token && (
1919 < div className = "fixed bottom-8 right-8 z-50" >
2020 < div className = "relative" >
2121 { /* Panel */ }
2222 < div
23- className = { ` z-60
24- absolute -bottom-4 -right-6 sm:bottom-16 sm:right-10 w-[95dvw] h-[95dvh] md:right-8 sm:w-[320px] sm:h-[500px]
23+ className = { `z-60
24+ absolute -bottom-4 -right-6 sm:bottom-16 sm:right-10 w-[95dvw] h-[95dvh] md:right-8 sm:w-[320px] sm:h-[500px]
2525 bg-neutral-70 rounded-2xl shadow-2xl border border-neutral-60 overflow-hidden
2626 transform origin-bottom-right
2727 transition duration-500 ease-in-out
2828 ${ isOpen ? 'scale-100 opacity-100' : 'scale-0 opacity-0 pointer-events-none' }
2929 ` }
3030 style = { {
31- boxShadow : '0 50px 50px rgba(0, 0, 0, 0.8)' // más profunda
31+ boxShadow : '0 50px 50px rgba(0, 0, 0, 0.8)'
3232 } }
3333 >
3434 < ChatPanel onClose = { toggleChat } user = { profile } />
@@ -42,9 +42,14 @@ export function Widget() {
4242 } }
4343 className = "
4444 w-14 h-14 rounded-full text-white flex items-center justify-center shadow-2xl hover:brightness-90
45- transition transform active:scale-90 duration-150 ease-out"
45+ transition transform active:scale-90 duration-150 ease-out relative "
4646 >
4747 < PiChat size = { 28 } />
48+ { unreadChats > 0 && (
49+ < span className = "absolute -top-2 -right-2 bg-red-500 text-white text-xs px-2 py-0.5 rounded-full animate-pulse min-w-[22px] text-center" >
50+ { unreadChats }
51+ </ span >
52+ ) }
4853 </ button >
4954 </ div >
5055 </ div >
0 commit comments