code cleanups

This commit is contained in:
Igor Zinken
2026-01-31 16:43:17 +01:00
parent 11c586b76d
commit 717d50254d
2 changed files with 2 additions and 4 deletions

View File

@@ -59,9 +59,7 @@ export const hexToRGBA = ( hex: string ): RGBA => {
];
};
export const RGBAtoHex = ( rgba: RGBA ): string => {
const [ r, g, b, a ] = rgba;
export const RGBAtoHex = ( [ r, g, b, a ]: RGBA ): string => {
const rgbHex = `#${intToHex(r)}${intToHex(g)}${intToHex(b)}`;
return a === 255 ? rgbHex : `${rgbHex}${intToHex(a)}`;

View File

@@ -3,7 +3,7 @@ import { hexToRGBA, RGBAtoHex } from "@/utils/color-util";
describe( "Color utilities", () => {
describe( "when converting hex to RGBA", () => {
it( "should convert hex a hex value without transparency to be fully opaque", () => {
it( "should convert a hex value without transparency to a fully opaque RGBA value", () => {
expect( hexToRGBA( "#FF0000" )).toEqual([ 255, 0, 0, 255 ]);
});