1- import { Box , Tooltip , Typography } from "@mui/material" ;
2- import React , { useMemo } from "react" ;
1+ import { Box , ClickAwayListener , Tooltip , Typography } from "@mui/material" ;
2+ import React , { useMemo , useState } from "react" ;
33import { useGameData } from "../providers/GameDataProvider" ;
44import { useDraggable , useDroppable } from "@dnd-kit/core" ;
55
@@ -13,46 +13,51 @@ const Joker = ({ sx, joker, id }) => {
1313 } ) ;
1414 const { attributes : dropLeftAttr , listeners : dropLeftList , setNodeRef : setNodeRefDropLeft } = useDroppable ( { id : `${ id } -left` , data : { accepts : 'joker' } } ) ;
1515 const { attributes : dropRightAttr , listeners : dropRightList , setNodeRef : setNodeRefDropRight } = useDroppable ( { id : `${ id } -right` , data : { accepts : 'joker' } } ) ;
16+ const [ ttipOpen , setTtipOpen ] = useState ( false ) ;
1617
1718 return (
1819 < Box
19- className = { shopOpen ? 'joker-hover' : '' }
20+ className = { [ shopOpen ? 'joker-hover' : '' , 'draggable' ] . join ( ' ' ) }
2021 id = { id }
2122 ref = { setNodeRef }
2223 { ...attributes }
2324 { ...listeners }
2425 key = { id }
2526 sx = { { boxSizing : 'border-box' , m : '3px' , width : '44px' , height : '44px' , borderRadius : '4px' , fontSize : '24px' , display : 'flex' , justifyContent : 'center' , alignItems : 'center' , position : 'relative' , zIndex : 3 , ...joker . style } }
2627 >
27- < Box sx = { { position : 'absolute' , top : 0 , right : 0 , fontSize : '10px' , color : 'white' , backgroundColor : [ '' , '#7abf1f' , '#34249c' , '#b0102b' ] [ joker . rarity ] , px : '3px' , borderRadius : '2px 4px 2px 2px' } } >
28- { [ 'C' , 'U' , 'R' , 'S' ] [ joker . rarity ] }
29- </ Box >
30- < Tooltip arrow placement = "bottom" title = { activeJoker ?. props ?. id !== id ? (
31- < Box sx = { { fontSize : 12 , color : 'white' , borderRadius : '4px' , display : 'flex' , flexDirection : 'column' , alignItems : 'center' , zIndex : 2 } } >
32- < Typography variant = 'overline' sx = { { fontFamily : 'Orbitron' } } > { joker . name } </ Typography >
33- < Typography variant = 'body2' sx = { { textAlign : 'center' } } > { joker . description } </ Typography >
34- < Typography variant = 'overline' sx = { { fontFamily : 'Orbitron' , fontSize : 8 } } > { [ 'Common' , 'Uncommon' , 'Rare' , 'Shiny' ] [ joker . rarity ] } </ Typography >
28+ < ClickAwayListener onClickAway = { ( ) => setTtipOpen ( false ) } >
29+ < Box sx = { { height : '100%' , width : '100%' } } onClick = { ( ) => setTtipOpen ( ! ttipOpen ) } >
30+ < Box sx = { { position : 'absolute' , top : 0 , right : 0 , fontSize : '10px' , color : 'white' , backgroundColor : [ '' , '#7abf1f' , '#34249c' , '#b0102b' ] [ joker . rarity ] , px : '3px' , borderRadius : '2px 4px 2px 2px' } } >
31+ { [ 'C' , 'U' , 'R' , 'S' ] [ joker . rarity ] }
3532 </ Box >
36- ) : null } >
37- { joker . text }
38- < Box ref = { setNodeRefDropLeft } { ...dropLeftList } { ...dropRightAttr } sx = { { height : '100%' , width : '45%' , position : 'absolute' , left : 0 } } />
39- < Box sx = { { height :'100%' , width : '45%' , position : 'absolute' , right : 0 } } ref = { setNodeRefDropRight } { ...dropRightList } { ...dropLeftAttr } />
40- </ Tooltip >
41- < Tooltip arrow open = { ! ! ( scoringTile . score || scoringTile . newMoney || scoringTile . text || scoringTile . newMoney === 0 ) } title = { (
42- < Box sx = { { display : 'flex' , flexDirection : 'column' , alignItems : 'center' } } >
43- { ( scoringTile . score !== 0 || scoringTile . newMoney === 0 ) && ( < span style = { { fontFamily : 'Orbitron' , fontSize : 16 , color : scoringTile . score < 0 ? '#ff9ca7' : '#b3faaa' } } >
44- { scoringTile . score >= 0 ? '+' : '' } { scoringTile . score ?? '' }
45- </ span > ) }
46- { scoringTile . newMoney !== 0 && ( < span style = { { fontFamily : 'Orbitron' , fontSize : 16 , color : '#fffb80' } } >
47- { scoringTile . newMoney >= 0 ? '+' : '' } { scoringTile . newMoney ?? '' }
48- </ span > ) }
49- { scoringTile . text && ( < span style = { { fontFamily : 'Orbitron' , fontSize : 16 , color : '#b3faaa' } } >
50- { scoringTile . text }
51- </ span > ) }
33+ < Tooltip open = { ttipOpen } onClose = { ( ) => setTtipOpen ( false ) } disableFocusListener disableHoverListener disableTouchListener arrow placement = "bottom" title = { activeJoker ?. props ?. id !== id ? (
34+ < Box sx = { { fontSize : 12 , color : 'white' , borderRadius : '4px' , display : 'flex' , flexDirection : 'column' , alignItems : 'center' , zIndex : 2 } } >
35+ < Typography variant = 'overline' sx = { { fontFamily : 'Orbitron' } } > { joker . name } </ Typography >
36+ < Typography variant = 'body2' sx = { { textAlign : 'center' } } > { joker . description } </ Typography >
37+ < Typography variant = 'overline' sx = { { fontFamily : 'Orbitron' , fontSize : 8 } } > { [ 'Common' , 'Uncommon' , 'Rare' , 'Shiny' ] [ joker . rarity ] } </ Typography >
38+ </ Box >
39+ ) : null } >
40+ { joker . text }
41+ < Box ref = { setNodeRefDropLeft } { ...dropLeftList } { ...dropRightAttr } sx = { { height : '100%' , width : '45%' , position : 'absolute' , left : 0 } } />
42+ < Box sx = { { height :'100%' , width : '45%' , position : 'absolute' , right : 0 } } ref = { setNodeRefDropRight } { ...dropRightList } { ...dropLeftAttr } />
43+ </ Tooltip >
44+ < Tooltip arrow open = { ! ! ( scoringTile . score || scoringTile . newMoney || scoringTile . text || scoringTile . newMoney === 0 ) } title = { (
45+ < Box sx = { { display : 'flex' , flexDirection : 'column' , alignItems : 'center' } } >
46+ { ( scoringTile . score !== 0 || scoringTile . newMoney === 0 ) && ( < span style = { { fontFamily : 'Orbitron' , fontSize : 16 , color : scoringTile . score < 0 ? '#ff9ca7' : '#b3faaa' } } >
47+ { scoringTile . score >= 0 ? '+' : '' } { scoringTile . score ?? '' }
48+ </ span > ) }
49+ { scoringTile . newMoney !== 0 && ( < span style = { { fontFamily : 'Orbitron' , fontSize : 16 , color : '#fffb80' } } >
50+ { scoringTile . newMoney >= 0 ? '+' : '' } { scoringTile . newMoney ?? '' }
51+ </ span > ) }
52+ { scoringTile . text && ( < span style = { { fontFamily : 'Orbitron' , fontSize : 16 , color : '#b3faaa' } } >
53+ { scoringTile . text }
54+ </ span > ) }
55+ </ Box >
56+ ) } placement = "bottom" >
57+ < Box sx = { { width : '100%' , height : '100%' , pointerEvents : 'none' , position : 'absolute' } } />
58+ </ Tooltip >
5259 </ Box >
53- ) } placement = "bottom" >
54- < Box sx = { { width : '100%' , height : '100%' , pointerEvents : 'none' , position : 'absolute' } } />
55- </ Tooltip >
60+ </ ClickAwayListener >
5661 </ Box >
5762 ) ;
5863} ;
0 commit comments