forked from mystiq/hydrogen-web
only use 1 letter for avatar initial
This commit is contained in:
parent
404e6f8b87
commit
b5e7131050
1 changed files with 4 additions and 11 deletions
|
@ -15,18 +15,11 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function avatarInitials(name) {
|
export function avatarInitials(name) {
|
||||||
let words = name.split(" ");
|
let firstChar = name.charAt(0);
|
||||||
if (words.length === 1) {
|
if (firstChar === "!" || firstChar === "@" || firstChar === "#") {
|
||||||
words = words[0].split("-");
|
firstChar = name.charAt(1);
|
||||||
}
|
}
|
||||||
words = words.slice(0, 2);
|
return firstChar.toUpperCase();
|
||||||
return words.reduce((i, w) => {
|
|
||||||
let firstChar = w.charAt(0);
|
|
||||||
if (firstChar === "!" || firstChar === "@" || firstChar === "#") {
|
|
||||||
firstChar = w.charAt(1);
|
|
||||||
}
|
|
||||||
return i + firstChar.toUpperCase();
|
|
||||||
}, "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue