UNPKG

onboardsync-react-native

Version:

Expo SDK for OnboardSync - Remote onboarding configuration platform with A/B testing

33 lines 986 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ColorUtils = void 0; class ColorUtils { static hexToRgb(hex) { const cleanHex = hex.replace('#', ''); if (!/^[0-9A-Fa-f]{6}$/.test(cleanHex)) { return null; } const bigint = parseInt(cleanHex, 16); return { r: (bigint >> 16) & 255, g: (bigint >> 8) & 255, b: bigint & 255, }; } static isColorDark(hex) { const rgb = this.hexToRgb(hex); if (!rgb) { return false; } const luminance = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255; return luminance < 0.5; } static isDarkColor(hex) { return this.isColorDark(hex); } static getContrastColor(backgroundColor) { return this.isColorDark(backgroundColor) ? '#FFFFFF' : '#000000'; } } exports.ColorUtils = ColorUtils; //# sourceMappingURL=colorUtils.js.map