@@ -401,62 +401,58 @@ export const applyComponentTheme = (element: HTMLElement): void => {
401401} ; 
402402
403403/** 
404-  * Converts a hex color to RGB comma-separated values 
405-  * @param  hex Hex color (e.g., '#ffffff' or '#fff') 
406-  * @returns  RGB string (e.g., '255, 255, 255') 
404+  * Parses a hex color string and returns RGB values as an array. 
405+  * 
406+  * @param  hex Hex color (e.g. `'#ffffff'` or `'#fff'`) 
407+  * 
408+  * @returns  RGB values as `[r, g, b]` array 
407409 */ 
408- export   const  hexToRgb  =  ( hex : string ) : string  =>  { 
410+ const  parseHex  =  ( hex : string ) : [ number ,   number ,   number ]  =>  { 
409411  const  cleanHex  =  hex . replace ( '#' ,  '' ) ; 
410412
411-   let  r : number ,  g : number ,  b : number ; 
412- 
413+   // Short hex format like 'fff' → expand to 'ffffff' 
413414  if  ( cleanHex . length  ===  3 )  { 
414-     // Short hex format like 'fff' → expand to 'ffffff' 
415-     r   =  parseInt ( cleanHex [ 0 ]  +  cleanHex [ 0 ] ,  16 ) ; 
416-     g   =  parseInt ( cleanHex [ 1 ]  +  cleanHex [ 1 ] ,  16 ) ; 
417-     b   =  parseInt ( cleanHex [ 2 ]  +  cleanHex [ 2 ] ,  16 ) ; 
418-   }   else   { 
415+     return   [ 
416+        parseInt ( cleanHex [ 0 ]  +  cleanHex [ 0 ] ,  16 ) , 
417+        parseInt ( cleanHex [ 1 ]  +  cleanHex [ 1 ] ,  16 ) , 
418+        parseInt ( cleanHex [ 2 ]  +  cleanHex [ 2 ] ,  16 ) , 
419+      ] ; 
419420    // Full hex format like 'ffffff' 
420-     r  =  parseInt ( cleanHex . substr ( 0 ,  2 ) ,  16 ) ; 
421-     g  =  parseInt ( cleanHex . substr ( 2 ,  2 ) ,  16 ) ; 
422-     b  =  parseInt ( cleanHex . substr ( 4 ,  2 ) ,  16 ) ; 
421+   }  else  { 
422+     return  [ 
423+       parseInt ( cleanHex . substring ( 0 ,  2 ) ,  16 ) , 
424+       parseInt ( cleanHex . substring ( 2 ,  4 ) ,  16 ) , 
425+       parseInt ( cleanHex . substring ( 4 ,  6 ) ,  16 ) , 
426+     ] ; 
423427  } 
428+ } ; 
424429
430+ /** 
431+  * Converts a hex color to a string of RGB comma-separated values. 
432+  * 
433+  * @param  hex Hex color (e.g. `'#ffffff'` or `'#fff'`) 
434+  * 
435+  * @returns  RGB string (e.g. `'255, 255, 255'`) 
436+  */ 
437+ export  const  hexToRgb  =  ( hex : string ) : string  =>  { 
438+   const  [ r ,  g ,  b ]  =  parseHex ( hex ) ; 
425439  return  `${ r }  , ${ g }  , ${ b }  ` ; 
426440} ; 
427441
428442/** 
429-  * Mixes two hex colors by a given weight percentage 
430-  * @param  baseColor Base color (e.g., '#0054e9') 
431-  * @param  mixColor Color to mix in (e.g., '#000000' or '#fff') 
432-  * @param  weight Weight percentage as string - how much of mixColor to mix into baseColor (e.g., '12%') 
433-  * @returns  Mixed hex color 
443+  * Mixes two hex colors by a given weight percentage and returns 
444+  * it as a hex color. 
445+  * 
446+  * @param  baseColor Base color (e.g. `'#0054e9'`) 
447+  * @param  mixColor Color to mix in (e.g. `'#000000'` or `'#fff'`) 
448+  * @param  weight Weight percentage as string - how much of mixColor to mix into baseColor (e.g. `'12%'`) 
449+  * 
450+  * @returns  Mixed hex color (e.g. `'#004acd'`) 
434451 */ 
435452export  const  mix  =  ( baseColor : string ,  mixColor : string ,  weight : string ) : string  =>  { 
436453  // Parse weight percentage 
437454  const  w  =  parseFloat ( weight . replace ( '%' ,  '' ) )  /  100 ; 
438455
439-   // Parse hex colors 
440-   const  parseHex  =  ( hex : string ) : [ number ,  number ,  number ]  =>  { 
441-     const  cleanHex  =  hex . replace ( '#' ,  '' ) ; 
442- 
443-     // Short hex format like 'fff' → expand to 'ffffff' 
444-     if  ( cleanHex . length  ===  3 )  { 
445-       return  [ 
446-         parseInt ( cleanHex [ 0 ]  +  cleanHex [ 0 ] ,  16 ) , 
447-         parseInt ( cleanHex [ 1 ]  +  cleanHex [ 1 ] ,  16 ) , 
448-         parseInt ( cleanHex [ 2 ]  +  cleanHex [ 2 ] ,  16 ) , 
449-       ] ; 
450-       // Full hex format like 'ffffff' 
451-     }  else  { 
452-       return  [ 
453-         parseInt ( cleanHex . substr ( 0 ,  2 ) ,  16 ) , 
454-         parseInt ( cleanHex . substr ( 2 ,  2 ) ,  16 ) , 
455-         parseInt ( cleanHex . substr ( 4 ,  2 ) ,  16 ) , 
456-       ] ; 
457-     } 
458-   } ; 
459- 
460456  // Parse both colors 
461457  const  [ baseR ,  baseG ,  baseB ]  =  parseHex ( baseColor ) ; 
462458  const  [ mixR ,  mixG ,  mixB ]  =  parseHex ( mixColor ) ; 
0 commit comments