@@ -7,54 +7,33 @@ import {
77 ConnectionState ,
88} from "@/lib/hooks/useResultsSubscription" ;
99import { Tooltip } from "@/components/ui/tooltip" ;
10- import { Badge , Box , Status , Text } from "@chakra-ui/react" ;
10+ import { Badge , Status , Text } from "@chakra-ui/react" ;
1111import { useT } from "@/lib/i18n/useI18n" ;
1212
1313export default function ConnectionPulse ( {
1414 connectionState,
1515} : {
1616 connectionState : ConnectionState ;
17- animationDuration ?: number ;
1817} ) {
1918 const { t } = useT ( ) ;
2019
21- const connectionColor = CONNECTION_COLORS [ connectionState ] ;
22- const mainLabel = t (
23- `competitions.live.connection.status.${ CONNECTION_TRANSLATION_KEYS [ connectionState ] } ` ,
24- ) ;
20+ const translationKey = CONNECTION_TRANSLATION_KEYS [ connectionState ] ;
21+ const isConnected = connectionState === CONNECTION_STATE_CONNECTED ;
2522
2623 return (
27- < Status . Root colorPalette = { connectionColor } display = "inline-flex" >
24+ < Status . Root
25+ colorPalette = { CONNECTION_COLORS [ connectionState ] }
26+ display = "inline-flex"
27+ >
2828 < Tooltip
29- content = { t (
30- `competitions.live.connection.${ CONNECTION_TRANSLATION_KEYS [ connectionState ] } ` ,
31- ) }
29+ content = { t ( `competitions.live.connection.${ translationKey } ` ) }
3230 showArrow
3331 openDelay = { 200 }
3432 >
3533 < Badge variant = "solid" display = "inline-flex" gap = { 2 } size = "sm" >
36- < Box
37- boxSize = { { base : "1.5" , sm : "2" } }
38- borderRadius = "full"
39- bg = "colorPalette.contrast"
40- animationName = {
41- connectionState === CONNECTION_STATE_CONNECTED
42- ? "pulse"
43- : undefined
44- }
45- animationDuration = "1.5s"
46- animationTimingFunction = "ease-in-out"
47- animationIterationCount = "infinite"
48- animationDirection = "alternate"
49- />
50- < Text
51- as = "span"
52- fontSize = "inherit"
53- fontWeight = "medium"
54- textTransform = "uppercase"
55- lineHeight = "1"
56- >
57- { mainLabel }
34+ < Status . Indicator animation = { isConnected ? "pulse" : undefined } />
35+ < Text >
36+ { t ( `competitions.live.connection.status.${ translationKey } ` ) }
5837 </ Text >
5938 </ Badge >
6039 </ Tooltip >
0 commit comments