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

Using book cover sizes to prevent layout shifting #10145

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

anna-ayn
Copy link

@anna-ayn anna-ayn commented Dec 13, 2024

Closes #9739

feature

Technical

  • Added width and height methods to the Image class in openlibrary/core/models.py to retrieve image dimensions.
  • Modified the OLCarousel.vue component to include a cover-container div and set default cover image dimensions. Also added responsive styles for different screen sizes.
  • Updated the createActiveShowcaseItem function in ShowcaseItem.js to accept a desiredHeight parameter and set image dimensions dynamically based on the aspect ratio.
  • Adjusted the book.less and listLists.less styles to set fixed dimensions for cover images, ensuring consistent layout across different components.
  • Modified the search-result-item.less to remove the .bookcover class and ensure consistent image sizing.
  • Updated index.less to remove the max-width constraint on images within the content body.
  • Updated the book_cover.html template to calculate and set the height of the cover image dynamically based on its aspect ratio.
  • Adjusted the lists/home.html template to calculate and set the height of the cover image dynamically based on its aspect ratio.

Testing

  1. Navigate to pages where book covers are displayed.
  2. Verified that the book covers load with the correct dimensions.
  3. Ensured that the layout remains stable and does not shift when the images are loaded.
  4. Tested the changes on various devices and screen sizes to confirm responsiveness.

Screenshot

We have make videos demonstrating the changes and comparing with the real website of OpenLibrary;
https://drive.google.com/file/d/1RrzodyWAFDAS--mk5Y222Hjk95FYgMla/view?usp=sharing
https://drive.google.com/file/d/1BF7YWPcys6Ny2EuJ9ahkiIexsC1JjmCH/view?usp=sharing
https://drive.google.com/file/d/1UU0nRT32Oa0Bu_27FD6cN8tQES-QUqpQ/view?usp=sharing
https://drive.google.com/file/d/1qe68bcZtBNh2cbOEbi93z4s2u9XHgDtD/view?usp=sharing
https://drive.google.com/file/d/1rOheT5PNJi6iveGhcGpb589YsG9uEqXb/view?usp=drive_link

Stakeholders

@cdrini

anna-ayn and others added 20 commits December 5, 2024 16:38
…adjust image height to covers in already-lists
…-covers-in-lists

Added width and height to image elements for covers in lists
…diciones

Fixes the height of the cover in editions main page
Estandarización de tamaños de las portadas de libros en carruseles
…e-libros-en-el-explorador-de-biblioteca

A new container is added and the size of the covers is standardized
…static/css/components/search-result-item.less file.
Removal of the property 'width' from the .bookcover component in the …
@anna-ayn anna-ayn marked this pull request as ready for review December 13, 2024 12:26
@anna-ayn
Copy link
Author

Hi @RayBB and @cdrini,

We have completed the modifications to standardize the sizes of book covers and prevent layout shifting in various sections of the site.

We would greatly appreciate your review and feedback on these changes. Thank you!

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

Successfully merging this pull request may close these issues.

Utilize cover height and width to prevent page layout shifting
5 participants