UNPKG

@elsikora/x-captcha-react

Version:

React components for X-Captcha service

35 lines (32 loc) 1.43 kB
'use strict'; /* eslint-disable @elsikora/typescript/no-magic-numbers */ /** * Calculate hover background color for a button * @param {string} baseColor - Base color to darken * @returns {string} The hover background color */ const GetHoverBackgroundColor = (baseColor) => { // For simplicity, just slightly darken whatever the base color is if (baseColor === "#f8f8f8") return "#f0f0f0"; if (baseColor.startsWith("#") && baseColor.length === 7) { // Basic darkening for hex colors - reduce each RGB component by about 8% try { const r = Number.parseInt(baseColor.slice(1, 3), 16); const g = Number.parseInt(baseColor.slice(3, 5), 16); const b = Number.parseInt(baseColor.slice(5, 7), 16); const darkenValue = 20; // Darken by this amount const newR = Math.max(0, r - darkenValue); const newG = Math.max(0, g - darkenValue); const newB = Math.max(0, b - darkenValue); return `#${newR.toString(16).padStart(2, "0")}${newG.toString(16).padStart(2, "0")}${newB.toString(16).padStart(2, "0")}`; } catch { // Fallback if parsing fails return "#f0f0f0"; } } return "#f0f0f0"; // Default fallback if not a hex color }; exports.GetHoverBackgroundColor = GetHoverBackgroundColor; //# sourceMappingURL=get-hover-background-color.utility.js.map