IO-1722 adjusted background colors

This commit is contained in:
swtmply
2023-05-06 03:34:22 +08:00
parent 3988386c79
commit 12fa270a1a
2 changed files with 16 additions and 7 deletions

View File

@@ -2,12 +2,21 @@ import { Col, List, Space, Typography } from "antd";
import React from "react";
import { useTranslation } from "react-i18next";
const CardColorLegend = ({ bodyshop, cardSettings }) => {
const CardColorLegend = ({ bodyshop }) => {
const { t } = useTranslation();
const data = bodyshop.ssbuckets.map((size) => ({
label: size.label,
color: size.color?.hex ?? "white",
}));
const data = bodyshop.ssbuckets.map((bucket) => {
let color = { r: 255, g: 255, b: 255 };
if (bucket.color.rgb) {
color = bucket.color.rgb;
}
color = bucket.color; // default to white
return {
label: bucket.label,
color,
};
});
return (
<Col>
@@ -24,7 +33,7 @@ const CardColorLegend = ({ bodyshop, cardSettings }) => {
style={{
width: "1.5rem",
aspectRatio: "1/1",
backgroundColor: item.color,
backgroundColor: `rgba(${item.color.r},${item.color.g},${item.color.b},${item.color.a})`,
}}
></div>
<div>{item.label}</div>

View File

@@ -28,7 +28,7 @@ const cardColor = (ssbuckets, totalHrs) => {
return bucket.color.rgb;
}
return bucket.color;
return bucket.color ?? { r: 255, g: 255, b: 255 }; // default to white
};
function getContrastYIQ(bgColor) {