From fbfe04401deb7a08da03502282531364aa25d511 Mon Sep 17 00:00:00 2001 From: Paul Slaughter Date: Wed, 1 Aug 2018 19:43:50 +0000 Subject: Add vanilla JS avatar_helper and update existing avatar helpers --- app/assets/javascripts/lib/utils/text_utility.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app/assets/javascripts/lib') diff --git a/app/assets/javascripts/lib/utils/text_utility.js b/app/assets/javascripts/lib/utils/text_utility.js index 5f25c6ce1ae..2be3c97bd95 100644 --- a/app/assets/javascripts/lib/utils/text_utility.js +++ b/app/assets/javascripts/lib/utils/text_utility.js @@ -75,6 +75,20 @@ export function capitalizeFirstCharacter(text) { return `${text[0].toUpperCase()}${text.slice(1)}`; } +/** + * Returns the first character capitalized + * + * If falsey, returns empty string. + * + * @param {String} text + * @return {String} + */ +export function getFirstCharacterCapitalized(text) { + return text + ? text.charAt(0).toUpperCase() + : ''; +} + /** * Replaces all html tags from a string with the given replacement. * -- cgit v1.2.1