From bd0e6638cc2142b3e0cc5dfc54bb82889f488172 Mon Sep 17 00:00:00 2001 From: protoclown Date: Sun, 25 Sep 2022 18:19:53 +0200 Subject: [PATCH] fix: clarify util name --- framework/core/js/src/common/compat.ts | 4 ++-- .../js/src/common/utils/{yiqValue.ts => getContrast.ts} | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) rename framework/core/js/src/common/utils/{yiqValue.ts => getContrast.ts} (54%) diff --git a/framework/core/js/src/common/compat.ts b/framework/core/js/src/common/compat.ts index cfadfb214..6b2df1ec7 100644 --- a/framework/core/js/src/common/compat.ts +++ b/framework/core/js/src/common/compat.ts @@ -33,7 +33,7 @@ import formatNumber from './utils/formatNumber'; import mapRoutes from './utils/mapRoutes'; import withAttr from './utils/withAttr'; import * as FocusTrap from './utils/focusTrap'; -import yiqValue from './utils/yiqValue'; +import getContrast from './utils/getContrast'; import Notification from './models/Notification'; import User from './models/User'; import Post from './models/Post'; @@ -121,7 +121,7 @@ export default { 'utils/throttleDebounce': ThrottleDebounce, 'utils/isObject': isObject, 'utils/focusTrap': FocusTrap, - 'utils/yiqValue': yiqValue, + 'utils/getContrast': getContrast, 'models/Notification': Notification, 'models/User': User, 'models/Post': Post, diff --git a/framework/core/js/src/common/utils/yiqValue.ts b/framework/core/js/src/common/utils/getContrast.ts similarity index 54% rename from framework/core/js/src/common/utils/yiqValue.ts rename to framework/core/js/src/common/utils/getContrast.ts index 3fe77a91d..56250a464 100644 --- a/framework/core/js/src/common/utils/yiqValue.ts +++ b/framework/core/js/src/common/utils/getContrast.ts @@ -1,9 +1,10 @@ /** - * The `yiqValue` utility converts a hex color to rgb, and then calcul a yiq - * contrast value. + * The `getContrast` utility converts a hex color to rgb, and then calcul a YIQ + * value in order to get the appropriate contrast value (is it dark or is it + * light?) See https://www.w3.org/TR/AERT/#color-contrast for references */ -export default function yiqValue(hexcolor: String) { +export default function getContrast(hexcolor: String) { var hexnumbers = hexcolor.replace("#", "");