Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDS-1897: feat(component-carousel): added functionality to check screen width for modified perview value #1406

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

juanmitriatti
Copy link
Contributor

Added functionality to check screen width for modified perview items value and to decide whether to show action buttons.

UDS-1897

Description

Links

FOR APPROVERS

…or modified perview value

Added functionality to check screen width for modified perview items value and to decide whether to
show action buttons.

UDS-1897
@juanmitriatti juanmitriatti requested a review from a team as a code owner November 14, 2024 17:12
let perViewValue;
switch (perView) {
case "3":
perViewValue = screenWidth > 1024 ? 3 : screenWidth > 768 ? 2 : 1;
Copy link
Contributor

@davidornelas11 davidornelas11 Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking this out to separate if, else statements will fix the build issue. We usually try to avoid nested ternaries.
Ex: if (screenWidth > 1024) { perViewValue = 3; } else if (screenWidth > 768) { perViewValue = 2; } else { perViewValue = 1; }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved this build issue

case "2":
perViewValue = screenWidth < 768 ? 1 : 2;
break;
case "1":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed as the default will take care of everything not mentioned above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if statement is necessary to render only one card on mobile when the carousel previously displayed two items per view.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I think I commented on the wrong line, I meant the case "1" can be removed since the default is right under it and it's just gonna default if its not "2" or "3"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misunderstood. I thought you were referring to the second ternary case.

@davidornelas11
Copy link
Contributor

Just another suggestion but not required, assigning the 1024 and 768 numbers to constants at the top of the file will make it a bit cleaner to read.

@juanmitriatti
Copy link
Contributor Author

juanmitriatti commented Nov 15, 2024

Good suggestion, I added the constants

Copy link
Member

@mlsamuelson mlsamuelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juanmitriatti
Copy link
Contributor Author

Is this duplicating the code that's already set up to do this check? https://github.com/ASU/asu-unity-stack/blob/UDS-1897/packages/component-carousel/src/core/components/BaseCarousel/glide/glide.setup.js#L10-L40 ?

Hi Michael,
They are different checks. One calculates how many cards are displayed, and the other calculates the carousel pages.

@mlsamuelson
Copy link
Member

@juanmitriatti Let's hold on this PR until we hear back from Kathy about the other Carousel issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants