34 lines
852 B
TypeScript
34 lines
852 B
TypeScript
import React, { ReactElement } from 'react'
|
|
import styles from './index.module.css'
|
|
import useNetworkMetadata, {
|
|
getNetworkDataById,
|
|
getNetworkDisplayName
|
|
} from '@hooks/useNetworkMetadata'
|
|
import { NetworkIcon } from './NetworkIcon'
|
|
|
|
export default function NetworkName({
|
|
networkId,
|
|
minimal,
|
|
className
|
|
}: {
|
|
networkId: number
|
|
minimal?: boolean
|
|
className?: string
|
|
}): ReactElement {
|
|
const { networksList } = useNetworkMetadata()
|
|
const networkData = getNetworkDataById(networksList, networkId)
|
|
const networkName = getNetworkDisplayName(networkData)
|
|
|
|
return (
|
|
<span
|
|
className={`${styles.network} ${minimal ? styles.minimal : null} ${
|
|
className || ''
|
|
}`}
|
|
title={networkName}
|
|
>
|
|
<NetworkIcon name={networkName} />{' '}
|
|
<span className={styles.name}>{networkName}</span>
|
|
</span>
|
|
)
|
|
}
|