1+ /**
2+ * Converts a hex color string to RGB values.
3+ *
4+ * @param hex - Hex color string (e.g., "#FF5733")
5+ * @returns Object with r, g, b numeric values
6+ */
17function hexToRGB ( hex : string ) {
28 const r = parseInt ( hex . slice ( 1 , 3 ) , 16 ) ;
39 const g = parseInt ( hex . slice ( 3 , 5 ) , 16 ) ;
410 const b = parseInt ( hex . slice ( 5 , 7 ) , 16 ) ;
511 return { r, g, b } ;
612}
713
14+ /**
15+ * Converts RGB values to a hex color string.
16+ *
17+ * @param r - Red value (0-255)
18+ * @param g - Green value (0-255)
19+ * @param b - Blue value (0-255)
20+ * @returns Hex color string (e.g., "#FF5733")
21+ */
822function rgbToHex ( r : number , g : number , b : number ) {
923 return '#' + ( ( 1 << 24 ) + ( r << 16 ) + ( g << 8 ) + b ) . toString ( 16 ) . slice ( 1 ) ;
1024}
1125
26+ /**
27+ * Blends two hex colors by a specified step amount.
28+ *
29+ * @param colorA - First hex color
30+ * @param colorB - Second hex color
31+ * @param step - Blend ratio (0 = colorA, 1 = colorB)
32+ * @returns Blended hex color
33+ */
1234function mixColors ( colorA : string , colorB : string , step : number ) {
1335 const colorARGB = hexToRGB ( colorA ) ;
1436 const colorBRGB = hexToRGB ( colorB ) ;
@@ -23,6 +45,15 @@ function mixColors(colorA: string, colorB: string, step: number) {
2345const NEURAL_WHITE = '#FFFFFF' ;
2446const NEURAL_BLACK = '#0F161F' ;
2547
48+ /**
49+ * Generates a complete shade palette from a base color.
50+ *
51+ * Creates lighter (W10-W100) and darker (B10-B100) variations by mixing
52+ * the base color with neural white and black at different ratios.
53+ *
54+ * @param color - Base hex color to generate shades from
55+ * @returns Object mapping shade keys to hex color values
56+ */
2657export const generateShades = ( color : string ) => {
2758 const shades : { [ key : string ] : string } = { '0' : color } ;
2859 for ( let i = 1 ; i <= 9 ; i ++ ) {
0 commit comments