11import {
22 Box ,
33 Code ,
4+ Drawer ,
5+ DrawerBody ,
6+ DrawerCloseButton ,
7+ DrawerContent ,
8+ DrawerHeader ,
9+ DrawerOverlay ,
410 Heading ,
511 Icon ,
12+ IconButton ,
613 Spinner ,
714 Stack ,
815 Stat ,
916 StatLabel ,
1017 StatNumber ,
1118 Text ,
19+ Tooltip ,
1220} from '@chakra-ui/react' ;
13- import { CopyIcon } from '@chakra-ui/icons' ;
21+ import { ArrowRightIcon , CheckIcon , CopyIcon } from '@chakra-ui/icons' ;
1422import { usePeerId } from './usePeerId' ;
1523import { usePeers } from './usePeers' ;
1624import { useRateIn } from './useRateIn' ;
@@ -21,6 +29,7 @@ import { useIsIpfsInstalled } from './useIsIpfsInstalled';
2129import { useIsFollowerInstalled } from './useIsFollowerInstalled' ;
2230import { useFollowerInfo } from './useFollowerInfo' ;
2331import { SYNTHETIX_IPNS } from '../../const' ;
32+ import React from 'react' ;
2433
2534function handleCopy ( text : string ) {
2635 if ( text ) {
@@ -65,9 +74,11 @@ export function Ipfs() {
6574 hostingSize,
6675 } ) ;
6776
77+ const [ peersOpened , setPeersOpened ] = React . useState ( false ) ;
78+
6879 return (
6980 < Box pt = "3" >
70- < Box flex = "1" p = "0" >
81+ < Box flex = "1" p = "0" whiteSpace = "nowrap" >
7182 < Stack direction = "row" spacing = { 6 } justifyContent = "center" mb = "2" >
7283 < Stat >
7384 < StatLabel mb = "0" opacity = "0.8" >
@@ -89,11 +100,74 @@ export function Ipfs() {
89100 </ StatLabel >
90101 < StatNumber > { rateIn ? rateIn : '-' } </ StatNumber >
91102 </ Stat >
92- < Stat >
103+ < Stat cursor = "pointer" onClick = { ( ) => setPeersOpened ( true ) } >
93104 < StatLabel mb = "0" opacity = "0.8" >
94- Peers
105+ Cluster peers{ ' ' }
106+ < IconButton
107+ aria-label = "Open online peers"
108+ size = "xs"
109+ icon = { < ArrowRightIcon /> }
110+ onClick = { ( ) => setPeersOpened ( true ) }
111+ />
95112 </ StatLabel >
96- < StatNumber > { peers ? peers : '-' } </ StatNumber >
113+
114+ < StatNumber >
115+ { peers ? peers . length : '-' } { ' ' }
116+ < Drawer
117+ isOpen = { peersOpened }
118+ placement = "right"
119+ onClose = { ( ) => setPeersOpened ( false ) }
120+ >
121+ < DrawerOverlay />
122+ < DrawerContent maxWidth = "26em" >
123+ < DrawerCloseButton />
124+ < DrawerHeader > Online peers</ DrawerHeader >
125+ < DrawerBody >
126+ < Stack direction = "column" margin = "0" overflow = "scroll" >
127+ { peers . map ( ( peer : { id : string } , i : number ) => (
128+ < Code
129+ key = { peer . id }
130+ fontSize = "10px"
131+ display = "block"
132+ backgroundColor = "transparent"
133+ whiteSpace = "nowrap"
134+ >
135+ { `${ i } ` . padStart ( 3 , '0' ) } .{ ' ' }
136+ < Tooltip
137+ hasArrow
138+ placement = "top"
139+ openDelay = { 200 }
140+ fontSize = "xs"
141+ label = {
142+ peer . id === peerId
143+ ? 'Your connected Peer ID'
144+ : 'Copy Peer ID'
145+ }
146+ >
147+ < Text
148+ as = "span"
149+ borderBottom = "1px solid green.400"
150+ borderBottomColor = {
151+ peer . id === peerId ? 'green.400' : 'transparent'
152+ }
153+ borderBottomStyle = "solid"
154+ borderBottomWidth = "1px"
155+ cursor = "pointer"
156+ onClick = { ( ) => handleCopy ( peer . id ) }
157+ >
158+ { peer . id }
159+ </ Text >
160+ </ Tooltip > { ' ' }
161+ { peer . id === peerId ? (
162+ < CheckIcon color = "green.400" />
163+ ) : null }
164+ </ Code >
165+ ) ) }
166+ </ Stack >
167+ </ DrawerBody >
168+ </ DrawerContent >
169+ </ Drawer >
170+ </ StatNumber >
97171 </ Stat >
98172 </ Stack >
99173 < Box bg = "whiteAlpha.200" pt = "4" px = "4" pb = "4" mb = "3" >
0 commit comments