Skip to content

Commit

Permalink
Replace object tag
Browse files Browse the repository at this point in the history
  • Loading branch information
builder-247 committed Aug 23, 2024
1 parent 9592784 commit b7bb1b4
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/components/Visualizations/inflictorWithValue.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,16 @@ display: inline-block;
height: 10px;
white-space: nowrap;
object, img {
img {
height: 18px;
width: 25px;
}
}
&.neutral {
> object, > img {
> img {
height: 30px;
width: 30px;
border-radius: 15px;
object-fit: cover;
position: relative;
bottom: 1px;
}
Expand Down Expand Up @@ -169,19 +168,24 @@ class InflictorWithValue extends React.Component {

constructor(props) {
super(props);
this.state = { showTooltip: false };
this.state = { showTooltip: false, imageError: false };
}
setShowTooltip = () => {
if (!this.state.showTooltip) {
this.setState({ showTooltip: true });
}
};
setImageError = (state) => {
this.setState({ imageError: state });
}

render() {
const {
inflictor, value, type, ptooltip, abilityId, strings, charges,
} = this.props;

const { imageError } = this.state;

const resolvedInflictor = (abilityId && abilityIds && abilityIds[abilityId]) || String(inflictor);
if (resolvedInflictor) {
const ability = abilities && abilities[resolvedInflictor];
Expand Down Expand Up @@ -216,6 +220,8 @@ class InflictorWithValue extends React.Component {
tooltip = ptooltip;
}

const fallbackImage = '/assets/images/Dota2Logo.svg';

return (
<StyledDiv>
<div
Expand All @@ -225,9 +231,17 @@ class InflictorWithValue extends React.Component {
onMouseEnter={this.setShowTooltip}
>
{(!type || type === 'purchase' || type === 'backpack' || type === 'neutral') &&
<object data={image} height="27px" width={ability ? '27px' : '37px'} type="image/png">
<img src="/assets/images/Dota2Logo.svg" alt="Dota 2 Logo" style={{ filter: 'grayscale(60%)', height: '27px' }} />
</object>}
<img
src={imageError ? fallbackImage : image}
alt={imageError ? "Dota 2 Logo" : ""}
height="27px"
style={{
filter: imageError ? 'grayscale(60%)' : null
}}
width={(ability || imageError) ? '27px' : '37px'}
onError={() => this.setImageError(true)}
/>
}
{type === 'buff' &&
<div
className="buff"
Expand Down

0 comments on commit b7bb1b4

Please sign in to comment.