Skip to content

Commit

Permalink
refactoring changing 'let' variables with 'const'
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
  • Loading branch information
BigSamu committed Nov 5, 2023
1 parent 422df63 commit a5ac107
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/components/breadcrumbs/breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,16 @@ export const OuiBreadcrumbs: FunctionComponent<OuiBreadcrumbsProps> = ({
// The max property collapses any breadcrumbs past the max quantity.
// This is the same behavior we want for responsiveness.
// So calculate the max value based on the combination of `max` and `responsive`
let calculatedMax: OuiBreadcrumbsProps['max'] = max;
// Set the calculated max to the number associated with the currentBreakpoint key if it exists
if (responsive && responsiveObject[currentBreakpoint as OuiBreakpointSize]) {
calculatedMax = responsiveObject[currentBreakpoint as OuiBreakpointSize];
}
// Final check is to make sure max is used over a larger breakpoint value
if (max && calculatedMax) {
calculatedMax = max < calculatedMax ? max : calculatedMax;
}

// First, calculate the responsive max value
const responsiveMax =
responsive && responsiveObject[currentBreakpoint as OuiBreakpointSize]
? responsiveObject[currentBreakpoint as OuiBreakpointSize]
: null;

// Second, if both max and responsiveMax are set, use the smaller of the two. Otherwise, use the one that is set.
const calculatedMax: OuiBreadcrumbsProps['max'] =
max && responsiveMax ? Math.min(max, responsiveMax) : max;

const limitedBreadcrumbs = calculatedMax
? limitBreadcrumbs(breadcrumbElements, calculatedMax, breadcrumbs)
Expand Down

0 comments on commit a5ac107

Please sign in to comment.