Skip to content

Commit

Permalink
fix(dashboard-viewer): fix trimester opacity
Browse files Browse the repository at this point in the history
  • Loading branch information
lsagetlethias committed Feb 16, 2022
1 parent c20ecb7 commit e4c32d8
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/renderer/utils/dashboard-viewer.ts
Expand Up @@ -31,19 +31,17 @@ const opacities = {
[MONTHS_NB.MARCH]: 0.45,
[MONTHS_NB.JUNE]: 0.65,
[MONTHS_NB.SEPT]: 0.85,
default: 1,
};
const DEFAULT_OPACITY = 1;
export const getColorFromTrimester = (
node: Omit<ComputedDatum<MailViewerObject<string>>, "color" | "fill">
): number => {
const month = node.data.email.receivedDate?.getMonth() ?? 1; // January

const opacityMonthKey = Object.keys(opacities).find((monthOpa) =>
month > MONTHS_NB.SEPT
? opacities.default
: month <= opacities[monthOpa]
)!;
return opacities[opacityMonthKey];
const opacityMonthKey = Object.keys(opacities).find(
(monthOpa) => month <= monthOpa
);
return opacityMonthKey ? opacities[opacityMonthKey] : DEFAULT_OPACITY;
};

// const getDeleteColor = (
Expand Down

0 comments on commit e4c32d8

Please sign in to comment.