-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: rework Avatar, User and UserLabel components (#1991)
- Loading branch information
Showing
53 changed files
with
893 additions
and
704 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
export const getAvatarDisplayText = (text: string) => { | ||
const words = text.split(/\s+/); | ||
const result = | ||
words.length > 1 ? [words[0][0], words[1][0]].filter(Boolean).join('') : text.slice(0, 2); | ||
import type {AvatarSize} from '../types/common'; | ||
|
||
return result.toUpperCase(); | ||
export const getAvatarDisplayText = (text: string, size: AvatarSize) => { | ||
if (size === '3xs') { | ||
return text[0].toUpperCase(); | ||
} | ||
|
||
const words = text.split(/[^a-zA-Z]+/); | ||
|
||
if (words.length <= 1) { | ||
return text.slice(0, 2).toUpperCase(); | ||
} | ||
|
||
return [words[0][0], words[1][0]].filter(Boolean).join('').toUpperCase(); | ||
}; |
Oops, something went wrong.