1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

accessibility tweaks

This commit is contained in:
Matthias Kretschmann 2020-07-09 12:39:21 +02:00
parent 970624e652
commit 39fb280666
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -1,5 +1,4 @@
import React from 'react' import React from 'react'
import Button from '../../atoms/Button'
import styles from './Account.module.css' import styles from './Account.module.css'
import { useWeb3, useOcean } from '@oceanprotocol/react' import { useWeb3, useOcean } from '@oceanprotocol/react'
import { toDataUrl } from 'ethereum-blockies' import { toDataUrl } from 'ethereum-blockies'
@ -12,25 +11,33 @@ function accountTruncate(account: string) {
return truncated return truncated
} }
const Blockies = ({ account }: { account: string | undefined }) => {
if (!account) return null
const blockies = toDataUrl(account)
return (
<img
className={styles.blockies}
src={blockies}
alt="Blockies"
aria-hidden="true"
/>
)
}
// Forward ref for Tippy.js // Forward ref for Tippy.js
// eslint-disable-next-line // eslint-disable-next-line
const Account = React.forwardRef((props, ref: any) => { const Account = React.forwardRef((props, ref: any) => {
const { account, web3Connect, ethProviderStatus } = useWeb3() const { account, web3Connect, ethProviderStatus } = useWeb3()
const { status } = useOcean() const { status } = useOcean()
const blockies = account && toDataUrl(account)
const hasSuccess = ethProviderStatus === 1 && status === 1 const hasSuccess = ethProviderStatus === 1 && status === 1
return account ? ( return account ? (
<button className={styles.button} aria-label="Account" ref={ref}> <button className={styles.button} aria-label="Account" ref={ref}>
{blockies && ( <Blockies account={account} />
<img <span className={styles.address} title={account}>
className={styles.blockies} {accountTruncate(account)}
src={blockies} </span>
alt="Blockies"
aria-hidden="true"
/>
)}
<span className={styles.address}>{accountTruncate(account)}</span>
{!hasSuccess && ( {!hasSuccess && (
<Status className={styles.status} state="warning" aria-hidden /> <Status className={styles.status} state="warning" aria-hidden />
)} )}