mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Add alt text for images in list items (#9847)
This commit is contained in:
parent
63f759e14e
commit
0315c6c20d
@ -113,6 +113,7 @@ const AssetListItem = ({
|
||||
diameter={32}
|
||||
address={tokenAddress}
|
||||
image={tokenImage}
|
||||
alt={`${primary} ${tokenSymbol}`}
|
||||
/>
|
||||
}
|
||||
midContent={midContent}
|
||||
|
@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { renderIcon } from '@download/blockies'
|
||||
|
||||
const BlockieIdenticon = ({ address, diameter }) => {
|
||||
const BlockieIdenticon = ({ address, diameter, alt }) => {
|
||||
const [dataUrl, setDataUrl] = useState(null)
|
||||
const canvasRef = useRef(null)
|
||||
|
||||
@ -19,7 +19,7 @@ const BlockieIdenticon = ({ address, diameter }) => {
|
||||
return (
|
||||
<>
|
||||
<canvas ref={canvasRef} style={{ display: 'none' }} />
|
||||
<img src={dataUrl} height={diameter} width={diameter} alt="" />
|
||||
<img src={dataUrl} height={diameter} width={diameter} alt={alt || ''} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
@ -27,6 +27,7 @@ const BlockieIdenticon = ({ address, diameter }) => {
|
||||
BlockieIdenticon.propTypes = {
|
||||
address: PropTypes.string.isRequired,
|
||||
diameter: PropTypes.number.isRequired,
|
||||
alt: PropTypes.string,
|
||||
}
|
||||
|
||||
export default BlockieIdenticon
|
||||
|
@ -21,6 +21,7 @@ export default class Identicon extends PureComponent {
|
||||
diameter: PropTypes.number,
|
||||
image: PropTypes.string,
|
||||
useBlockie: PropTypes.bool,
|
||||
alt: PropTypes.string,
|
||||
}
|
||||
|
||||
static defaultProps = {
|
||||
@ -30,23 +31,24 @@ export default class Identicon extends PureComponent {
|
||||
diameter: 46,
|
||||
image: undefined,
|
||||
useBlockie: false,
|
||||
alt: '',
|
||||
}
|
||||
|
||||
renderImage() {
|
||||
const { className, diameter, image } = this.props
|
||||
const { className, diameter, image, alt } = this.props
|
||||
|
||||
return (
|
||||
<img
|
||||
className={classnames('identicon', className)}
|
||||
src={image}
|
||||
style={getStyles(diameter)}
|
||||
alt=""
|
||||
alt={alt}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
renderJazzicon() {
|
||||
const { address, className, diameter } = this.props
|
||||
const { address, className, diameter, alt } = this.props
|
||||
|
||||
return (
|
||||
<Jazzicon
|
||||
@ -54,19 +56,20 @@ export default class Identicon extends PureComponent {
|
||||
diameter={diameter}
|
||||
className={classnames('identicon', className)}
|
||||
style={getStyles(diameter)}
|
||||
alt={alt}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
renderBlockie() {
|
||||
const { address, className, diameter } = this.props
|
||||
const { address, className, diameter, alt } = this.props
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classnames('identicon', className)}
|
||||
style={getStyles(diameter)}
|
||||
>
|
||||
<BlockieIdenticon address={address} diameter={diameter} />
|
||||
<BlockieIdenticon address={address} diameter={diameter} alt={alt} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -79,6 +82,7 @@ export default class Identicon extends PureComponent {
|
||||
diameter,
|
||||
useBlockie,
|
||||
addBorder,
|
||||
alt,
|
||||
} = this.props
|
||||
|
||||
if (image) {
|
||||
@ -88,10 +92,7 @@ export default class Identicon extends PureComponent {
|
||||
if (address) {
|
||||
const checksummedAddress = checksumAddress(address)
|
||||
|
||||
if (
|
||||
contractMap[checksummedAddress] &&
|
||||
contractMap[checksummedAddress].logo
|
||||
) {
|
||||
if (contractMap[checksummedAddress]?.logo) {
|
||||
return this.renderJazzicon()
|
||||
}
|
||||
|
||||
@ -109,7 +110,7 @@ export default class Identicon extends PureComponent {
|
||||
className={classnames('identicon__eth-logo', className)}
|
||||
src="./images/eth_logo.svg"
|
||||
style={getStyles(diameter)}
|
||||
alt=""
|
||||
alt={alt}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user