feat: add border color customization for user profile chips and improve text contrast

This commit is contained in:
2026-03-12 22:18:05 +11:00
parent 834de012b4
commit 67f3ae4d34
8 changed files with 471 additions and 304 deletions

View File

@@ -138,3 +138,24 @@ export const splitWithSpace = (content: string): string[] => {
if (trimmedContent === '') return [];
return trimmedContent.split(' ');
};
/**
* Calculate contrasting text color (black or white) for a given background color
* @param bgColor - Hex color string (e.g., '#RRGGBB' or '#RRGGBBAA')
* @returns '#000000' for light backgrounds, '#FFFFFF' for dark backgrounds
*/
export const getContrastingTextColor = (bgColor: string): string => {
// Remove # if present
const hex = bgColor.replace('#', '');
// Parse RGB values (ignore alpha if present)
const r = parseInt(hex.substring(0, 2), 16);
const g = parseInt(hex.substring(2, 4), 16);
const b = parseInt(hex.substring(4, 6), 16);
// Calculate relative luminance using WCAG formula
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
// Return black for light backgrounds, white for dark backgrounds
return luminance > 0.5 ? '#000000' : '#FFFFFF';
};