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

Responsive scrollable filter bar #382

Merged
merged 8 commits into from
Oct 25, 2024

Conversation

JiaXinEu
Copy link
Contributor

Summary:

Fixes #377

Type of change:

  • ✨ Enhancement

Changes Made:

  • Add BreakpointObserver to observe and respond to screen size changes
  • Add private method to update styling of filter-bar
  • Put dropdown-filters in scrollable container

Screenshots:

image

image

Proposed Commit Message:

Modify responsiveness of filters to screen size change

The filter bar is cut off when screen width is reduced. We should 
make the design responsive.

Let's make filter bar scrollable when it cannot fit on screen.

Checklist:

  • I have tested my changes thoroughly.
  • I have created tests for any new code files created in this PR or provided a link to a issue/PR that addresses this.
  • I have added or modified code comments to improve code readability where necessary.
  • I have updated the project's documentation as necessary.

Copy link
Contributor

@Arif-Khalid Arif-Khalid left a comment

Choose a reason for hiding this comment

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

I see the vision and am open to the possibility of using a scrollable filters container like you have implemented.
However, I feel that the scrollbar is not very intuitive to the user, i.e., not what you would find on most other sites. It will also be quite hard to use on a small screen like a mobile screen compared to a hamburger or dropdown menu, which is the very audience this change is supposed to cater to.
I would prefer a different approach but you are free to continue working on this approach and try to apply some cosideration for mobile users who don't have that much space to scroll horizontally for example left and right scroll buttons at the ends of the scrollbar.

Comment on lines 73 to 82

this.breakpointSubscription = this.breakpointObserver.observe([Breakpoints.Small, Breakpoints.XSmall]).subscribe((result) => {
this.isSmallScreen = result.matches;
this.updateSpan();
});

this.breakpointSubscription = this.breakpointObserver.observe([Breakpoints.Medium]).subscribe((result) => {
this.isMediumScreen = result.matches;
this.updateSpan();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

While this works, would it be better to take advantage of the auto scaling capabilities of css?
We can avoid these breakpoints and corresponding values since the parent colspan of 7 scales according to screen size already, such that the children widths are always relative to the parent without changing their individual colspan or the parents.
In order to preserve the full child item being shown when the screen shrinks, consider instead using min-width/max-width css properties with media queries to shift responsiveness logic to css where possible.

overflow-x: auto;
display: flex;
justify-content: center;
scrollbar-width: 5px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be using the firefox specific styling?
It would be better to use webkit:scrollbars pseudo-class selector in addition to this to properly style scrollbars in all browsers.
See https://stackoverflow.com/questions/15420314/how-to-make-custom-scrollbars-show-in-all-browsers

margin-right: 8px;
overflow-x: auto;
display: flex;
justify-content: center;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason for justify-content and changing it when the screen is smaller? There seems to be no difference if I remove justify content in both classes in testing.

@JiaXinEu
Copy link
Contributor Author

JiaXinEu commented Aug 1, 2024

I see the vision and am open to the possibility of using a scrollable filters container like you have implemented. However, I feel that the scrollbar is not very intuitive to the user, i.e., not what you would find on most other sites. It will also be quite hard to use on a small screen like a mobile screen compared to a hamburger or dropdown menu, which is the very audience this change is supposed to cater to. I would prefer a different approach but you are free to continue working on this approach and try to apply some cosideration for mobile users who don't have that much space to scroll horizontally for example left and right scroll buttons at the ends of the scrollbar.

Thank you for a better insight of the issue. The current PR uses a togglable menu approach

Copy link
Contributor

@Arif-Khalid Arif-Khalid left a comment

Choose a reason for hiding this comment

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

Great implementation of a hamburger dropdown and I like the substitution of mat grid you made.
However, there is some redundancy and minor errors in regards to CSS to fix.
Additionally, would it be better to put the app-label-filters into the hamburger dropdown as well since on small screens at first glance it now seems to suggest it denotes something about all filters.

display: block;
position: absolute;
width: 100%;
top: calc(20% + 8px); /* 8px margin from ul */
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to use a calculation relative to the app-filter-bar? By applying a position: relative to the app filter bar you can position the child element of class filters relative to that parent when the child has position: absolute. Therefore you could then do something like top: 100%; instead on this element and it will be positioned nicely under the filter bar.
image

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you share your reasoning behind the 8px margin from ul as commented? I find it uneccessary and it would be better to associate the expansion more closely with the app-filter-bar.

Comment on lines +8 to +14
ul {
margin: 8px;
padding: 0;
display: flex;
align-items: center;
justify-content: space-between;
list-style-type: none;
Copy link
Contributor

Choose a reason for hiding this comment

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

Good substitution for the mat-grid components. Could you enforce a height of 80px so that no vertical scrollbar appears ? This was was enforced by the previous rowHeight property.

}

.dropdown-filters {
.search-bar {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this class necessary?

display: none;
cursor: pointer;

@media (max-width: 1148px) {
Copy link
Contributor

Choose a reason for hiding this comment

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

At about 1200-1300 px range there is overlapping of components
image
Would it be better to use a more standard, larger breakpoint of 1400px?
Refer to https://getbootstrap.com/docs/5.0/layout/breakpoints/ for some standard breakpoints.

display: flex;
align-items: center;

@media (max-width: 1148px) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about breakpoints

Comment on lines 58 to 65
display: inline-block;
}
}
}

.filter-item {
padding: 0 10px;
display: block;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a need for display: block and display: inline-block? Children of flexbox are automatically given display: inline-block

@JiaXinEu
Copy link
Contributor Author

Additionally, would it be better to put the app-label-filters into the hamburger dropdown as well since on small screens at first glance it now seems to suggest it denotes something about all filters.

Thank you for the feedback. I have moved label-filter into the hamburger dropdown as well, and done the minor fixes on css as suggested.

Copy link
Contributor

@Arif-Khalid Arif-Khalid left a comment

Choose a reason for hiding this comment

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

Your changes make the app a lot more usable on smaller devices. Thanks so much for your contributions!
LGTM!

@Arif-Khalid Arif-Khalid merged commit c17c4d7 into CATcher-org:main Oct 25, 2024
2 of 3 checks passed
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.

Responsiveness of filters
2 participants