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

Feat: Grid tiles automatically size to fill grid #186

Merged
merged 51 commits into from
Sep 27, 2024

Conversation

hudson-newey
Copy link
Member

@hudson-newey hudson-newey commented Sep 18, 2024

Feat: Grid tiles automatically size to fill grid

A short description of the pull request

Changes

Features

  • The verification grid now uses a display: grid layout
  • You can now specify the number of rows and columns in the verification grid through the --rows and --columns css variables (e.g. <oe-verification-grid style="--rows: 6; --collumns: 3;" /> (this comes for free and required no extra effort)
  • The verification grid no longer allows you to create a verification grid that would not fit inside the verification container
  • The verification grid now always fills its container
  • The verification controls are now always at the bottom of the oe-verification-grid element
  • The verification grid now has a default size for desktop and mobile
  • oe-verification-grid-tile components can now advertise if they are overflowing from the verification grid

Bug Fixes

  • Fix a bug where the axes svg would be larger than the spectrogram component, causing overflow
  • Replaces the intersection observer with a predicates to assert that the grid tiles will fit in the grid. This fixes all issues related to the intersection observer
  • When virtually measuring the axes component, it now adds padding to both sides of the label, better reflecting the real browser implementation. This fixes a bug where the axes labels could appear to be too close together (does not fix a similar font-measuring bug on Chrome)

Code Quality

  • The axes component's chrome is now overlayed on top of the wrapped element (spectrogram) instead of wrapping it. This allows the wrapped element/spectrogram to grow independently of the axes' size
  • Changes the oe-verification-grid's container to be a flex column instead of flex row. Better reflecting it's function of a container with elements of variable height
  • Inadvertently correctly fixes the bug in playwright that would cause the spectrograms to infinately expand. This was done because the oe-verification-grid container is now a flex column instead of flex row
  • Adds snapshot tests showing how the verification grid looks on different device types

Visual Changes

Screenshots of the verification grid at different device sizes can be found here

image

Related Issues

Fixes: #167
Fixes: #150
Fixes: #146
Fixes: #147
Fixes: #165

Final Checklist

  • All commits messages are semver compliant
  • Added relevant unit tests for new functionality
  • Updated existing unit tests to reflect changes
  • Code style is consistent with the project guidelines
  • Documentation is updated to reflect the changes (if applicable)
  • Link issues related to the PR
  • Assign labels if you have permission
  • Assign reviewers if you have permission
  • Ensure that CI is passing
  • Ensure that pnpm lint runs without any errors
  • Ensure that pnpm test runs without any errors

@hudson-newey hudson-newey self-assigned this Sep 18, 2024
@hudson-newey hudson-newey force-pushed the dynamic-grid-tile-sizes branch from 7f2940a to b1baefc Compare September 19, 2024 00:00
Copy link

github-actions bot commented Sep 19, 2024

hudson-newey and others added 9 commits September 19, 2024 11:19
Previously axes elements would use absolute positioning, and the svg
container would not effect sizing. This caused issues with dynamic grid
tile sizes and caused the verification grid to overflow its container
creating scrollbars on the host application
Copy link
Contributor

@atruskie atruskie left a comment

Choose a reason for hiding this comment

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

while reviewing I checked out the code and did some interactive testing. It's hard to describe what is going on, but on more than one occasion I managed to cause the tab to lock up (in i'm assuming what was an infinite loop of some kind).

We also need some indication to the user that their desired grid size is being ignored. I.e. if I set grid-size to 32 a but am only showed 12 items then that's confusing. One way to do this would be to set a maximum (and maybe issue a notice) on the grid-size ui. Another way could be to show the desired size and the current limit on the slider (again with a warning about not being able to show the requested amount).

This is some really great work, but we need another pass for reliability and edge cases.

src/components/axes/axes.ts Outdated Show resolved Hide resolved
src/components/axes/axes.ts Outdated Show resolved Hide resolved
src/components/axes/css/style.css Show resolved Hide resolved
src/components/axes/css/style.css Outdated Show resolved Hide resolved
src/components/axes/css/style.css Outdated Show resolved Hide resolved
src/components/verification-grid/verification-grid.ts Outdated Show resolved Hide resolved
src/components/verification-grid/verification-grid.ts Outdated Show resolved Hide resolved
src/components/verification-grid/verification-grid.ts Outdated Show resolved Hide resolved
src/components/verification-grid/verification-grid.ts Outdated Show resolved Hide resolved
src/components/verification-grid/verification-grid.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@atruskie atruskie left a comment

Choose a reason for hiding this comment

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

Close. So close.

We talked offline about how this does not handle scenarios where the aspect ratio looks terrible, but the next candidate is not triggered because everything fits and target grid size in the only thing considered.

src/components/verification-grid-tile/css/style.css Outdated Show resolved Hide resolved
Comment on lines +159 to +160
this.intersectionObserver.observe(this.slotWrapper);
this.intersectionObserver.observe(this.contentsWrapper);
Copy link
Contributor

Choose a reason for hiding this comment

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

why observing both?

Copy link
Member Author

@hudson-newey hudson-newey Sep 26, 2024

Choose a reason for hiding this comment

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

Discussed offline and added a code comment

image

src/helpers/controllers/dynamic-grid-sizes.ts Outdated Show resolved Hide resolved
src/helpers/controllers/dynamic-grid-sizes.ts Outdated Show resolved Hide resolved
src/components/verification-grid/verification-grid.ts Outdated Show resolved Hide resolved
src/helpers/controllers/dynamic-grid-sizes.ts Show resolved Hide resolved
@hudson-newey hudson-newey merged commit 182224e into main Sep 27, 2024
6 checks passed
@hudson-newey hudson-newey deleted the dynamic-grid-tile-sizes branch September 27, 2024 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment