From a7eaadf3aad346fa9d038a306c6a6282c0a80925 Mon Sep 17 00:00:00 2001 From: Manumartin95 Date: Fri, 6 Oct 2023 09:56:31 +0200 Subject: [PATCH 1/2] feat: update start and normal width calc --- .../availability-table/absence-item/absence-item.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/features/binnacle/features/availability/ui/components/availability-table/absence-item/absence-item.tsx b/src/features/binnacle/features/availability/ui/components/availability-table/absence-item/absence-item.tsx index 97934ebf..7db3c01f 100644 --- a/src/features/binnacle/features/availability/ui/components/availability-table/absence-item/absence-item.tsx +++ b/src/features/binnacle/features/availability/ui/components/availability-table/absence-item/absence-item.tsx @@ -22,19 +22,26 @@ export const AbsenceItem: FC = ({ absence, userName, overflowType }) => { const boxSize = isMobile ? '36px' : '48px' const durationPlusLast = duration + 1 + //The calculation of end is based on the duration of the absence plus an element to reach the end of the block, + // minus 1px for each block present due to the margin each one has, + // and subtracting the cell's padding to ensure it accounts for the same padding at the beginning and end. + if (overflowType === 'end') { return `calc(${durationPlusLast * 100}% + ${durationPlusLast - 1}px - ${cellPadding})` } + //The calc is based in total width plus 1px for each block present due to the margin each one has if (overflowType === 'both') { return `calc(${durationPlusLast * 100}% + ${durationPlusLast - 1}px)` } + //The calculation is based on the duration of the absence plus an element to reach the end of the block, minus 1px for each block present due to the margin each one has, and subtracting the padding that we lose at the beginning. if (overflowType === 'start') { - return `calc(${durationPlusLast * 100}%)` + return `calc(${durationPlusLast * 100}% + ${duration}px - ${cellPadding})` } - return `calc(${duration * 100}% + ${boxSize})` + //The calculation is based on the duration of the absence plus an element to reach the end of the block, minus 1px for each block present due to the margin each one has, and adding the block size without padding. + return `calc(${duration * 100}% + ${boxSize} + ${duration}px)` } const getBorderRadius = () => { From 9acb32f74f2fa91408804356717dcd6046c90a24 Mon Sep 17 00:00:00 2001 From: Manumartin95 Date: Fri, 6 Oct 2023 10:01:09 +0200 Subject: [PATCH 2/2] refactor: update end and both calc variable --- .../availability-table/absence-item/absence-item.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/features/binnacle/features/availability/ui/components/availability-table/absence-item/absence-item.tsx b/src/features/binnacle/features/availability/ui/components/availability-table/absence-item/absence-item.tsx index 7db3c01f..47305cb6 100644 --- a/src/features/binnacle/features/availability/ui/components/availability-table/absence-item/absence-item.tsx +++ b/src/features/binnacle/features/availability/ui/components/availability-table/absence-item/absence-item.tsx @@ -27,12 +27,12 @@ export const AbsenceItem: FC = ({ absence, userName, overflowType }) => { // and subtracting the cell's padding to ensure it accounts for the same padding at the beginning and end. if (overflowType === 'end') { - return `calc(${durationPlusLast * 100}% + ${durationPlusLast - 1}px - ${cellPadding})` + return `calc(${durationPlusLast * 100}% + ${duration}px - ${cellPadding})` } //The calc is based in total width plus 1px for each block present due to the margin each one has if (overflowType === 'both') { - return `calc(${durationPlusLast * 100}% + ${durationPlusLast - 1}px)` + return `calc(${durationPlusLast * 100}% + ${duration}px)` } //The calculation is based on the duration of the absence plus an element to reach the end of the block, minus 1px for each block present due to the margin each one has, and subtracting the padding that we lose at the beginning.