Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 10edab0

Browse files
committed
Don't c+p the complex markup
1 parent 7484cc3 commit 10edab0

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/components/views/avatars/BaseAvatar.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -145,30 +145,30 @@ module.exports = React.createClass({
145145

146146
if (imageUrl === this.state.defaultImageUrl) {
147147
const initialLetter = this._getInitialLetter(name);
148+
const textNode = <EmojiText className="mx_BaseAvatar_initial" aria-hidden="true"
149+
style={{ fontSize: (width * 0.65) + "px",
150+
width: width + "px",
151+
lineHeight: height + "px" }}
152+
>
153+
{initialLetter}
154+
</EmojiText>;
155+
const imgNode = <img className="mx_BaseAvatar_image" src={imageUrl}
156+
alt="" title={title} onError={this.onError}
157+
width={width} height={height} />;
148158
if (onClick != null) {
149159
return (
150160
<AccessibleButton element='span' className="mx_BaseAvatar"
151161
onClick={onClick} {...otherProps}
152162
>
153-
<EmojiText className="mx_BaseAvatar_initial" aria-hidden="true"
154-
style={{ fontSize: (width * 0.65) + "px",
155-
width: width + "px",
156-
lineHeight: height + "px" }}>{initialLetter}</EmojiText>
157-
<img className="mx_BaseAvatar_image" src={imageUrl}
158-
alt="" title={title} onError={this.onError}
159-
width={width} height={height} />
163+
{textNode}
164+
{imgNode}
160165
</AccessibleButton>
161166
);
162167
} else {
163168
return (
164169
<span className="mx_BaseAvatar" {...otherProps}>
165-
<EmojiText className="mx_BaseAvatar_initial" aria-hidden="true"
166-
style={{ fontSize: (width * 0.65) + "px",
167-
width: width + "px",
168-
lineHeight: height + "px" }}>{initialLetter}</EmojiText>
169-
<img className="mx_BaseAvatar_image" src={imageUrl}
170-
alt="" title={title} onError={this.onError}
171-
width={width} height={height} />
170+
{textNode}
171+
{imgNode}
172172
</span>
173173
);
174174
}

0 commit comments

Comments
 (0)