Skip to content

Commit

Permalink
Merge pull request #183 from autentia/bugfix/resolve_item_absence_calc
Browse files Browse the repository at this point in the history
feat: update start and normal width calc
  • Loading branch information
Manumartin95 authored Oct 6, 2023
2 parents 46f1f47 + 9acb32f commit 490e8f4
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,26 @@ export const AbsenceItem: FC<Props> = ({ 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})`
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.
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 = () => {
Expand Down

0 comments on commit 490e8f4

Please sign in to comment.