mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 05:14:12 +03:00
Fixed up getInitials helper
This commit is contained in:
parent
9e445b8307
commit
5479993c96
@ -25,7 +25,7 @@ class Comment extends React.Component {
|
|||||||
|
|
||||||
getInitials() {
|
getInitials() {
|
||||||
const comment = this.props.comment;
|
const comment = this.props.comment;
|
||||||
return this.getInitials(comment.member.name);
|
return getInitials(comment.member.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -39,7 +39,7 @@ class Comment extends React.Component {
|
|||||||
<div className="flex mb-2 space-x-4 justify-start items-center">
|
<div className="flex mb-2 space-x-4 justify-start items-center">
|
||||||
<figure className="relative w-10 h-10">
|
<figure className="relative w-10 h-10">
|
||||||
<div className="flex justify-center items-center w-10 h-10 rounded-full bg-black">
|
<div className="flex justify-center items-center w-10 h-10 rounded-full bg-black">
|
||||||
<p className="text-white font-sans font-semibold">{ getInitials() }</p>
|
<p className="text-white font-sans font-semibold">{ this.getInitials() }</p>
|
||||||
</div>
|
</div>
|
||||||
<img className="absolute top-0 left-0 w-10 h-10 rounded-full" src={comment.member.avatar_image} alt="Avatar"/>
|
<img className="absolute top-0 left-0 w-10 h-10 rounded-full" src={comment.member.avatar_image} alt="Avatar"/>
|
||||||
</figure>
|
</figure>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import AppContext from '../AppContext';
|
import AppContext from '../AppContext';
|
||||||
|
import {getInitials} from '../utils/helpers';
|
||||||
|
|
||||||
class Form extends React.Component {
|
class Form extends React.Component {
|
||||||
static contextType = AppContext;
|
static contextType = AppContext;
|
||||||
@ -54,17 +55,7 @@ class Form extends React.Component {
|
|||||||
if (!this.context.member || !this.context.member.name) {
|
if (!this.context.member || !this.context.member.name) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
const parts = this.context.member.name.split(' ');
|
return getInitials(this.context.member.name);
|
||||||
|
|
||||||
if (parts.length === 0) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parts.length === 1) {
|
|
||||||
return parts[0].substring(0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return parts[0].substring(0, 1) + parts[parts.length - 1].substring(0, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
Loading…
Reference in New Issue
Block a user