feat(SPA): profile page, display name and the new account menu
This commit is contained in:
1 parent
55525c06d6
commit
b0f7b7892b
29 files changed
+3166
-469
No files matched your search
@@ -0,0 +1,22 @@
|
||||
const WHITESPACE = /\s+/
|
||||
|
||||
function firstCharacters(value: string, count: number) {
|
||||
return Array.from(value).slice(0, count).join('')
|
||||
}
|
||||
|
||||
export function accountName(username: string, displayName?: string | null) {
|
||||
return displayName ? displayName : username
|
||||
}
|
||||
|
||||
export function accountInitials(username: string, displayName?: string | null) {
|
||||
const words = (displayName ?? '').trim().split(WHITESPACE).filter(Boolean)
|
||||
if (words.length >= 2) {
|
||||
return words
|
||||
.slice(0, 2)
|
||||
.map((word) => firstCharacters(word, 1))
|
||||
.join('')
|
||||
.toUpperCase()
|
||||
}
|
||||
const source = words[0] ?? username
|
||||
return firstCharacters(source, 2).toUpperCase()
|
||||
}
|
||||
Reference in new issue
Block a user