mirror of
https://github.com/flarum/core.git
synced 2025-08-04 07:27:39 +02:00
fix: 3 char hex color is incorrectly modified to 6 (#4013)
The current logic creates `cdecde` from `cde`, it should be `ccddee`. @dsevillamartin said this is the code to use instead and chat gpt said he's brilliant so..
This commit is contained in:
@@ -17,7 +17,7 @@ export default function isDark(hexcolor: string | null): boolean {
|
||||
let hexnumbers = hexcolor.replace('#', '');
|
||||
|
||||
if (hexnumbers.length === 3) {
|
||||
hexnumbers += hexnumbers;
|
||||
hexnumbers = hexnumbers.split('').map(char => char.repeat(2)).join('');
|
||||
}
|
||||
|
||||
const r = parseInt(hexnumbers.slice(0, 2), 16);
|
||||
|
Reference in New Issue
Block a user