Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[avatar] Resize initials when size is changed #174

Merged
merged 1 commit into from
Sep 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,20 @@ function createAvatarComponent({ sources = [] }) {
whiteSpace: 'nowrap'
};

// Ensure the text node is updated and scaled when any of these
// values changed by calling the `_scaleTextNode` method using
// the correct `ref`.
const key = [
this.state.value,
this.props.size
].join('');

return (
<div className={className + ' sb-avatar__text'}
style={initialsStyle}>
<div style={tableStyle}>
<span style={spanStyle}>
<span ref={this._scaleTextNode} key={this.state.value}>
<span ref={this._scaleTextNode} key={key}>
{this.state.value}
</span>
</span>
Expand Down