forked from advplyr/audiobookshelf
-
Notifications
You must be signed in to change notification settings - Fork 0
Bookshelf refactoring
mikiher edited this page Jun 3, 2024
·
4 revisions
The refactoring addresses a number of issues found when trying to add display of an optional subtitle line:
- The book card (and other cards) width and height are passed as props
- This can (and does) cause incosistencies, where various card containers use different values. For example book cards currently have slightly different size on the home and library pages.
- The height of the card does not reflect the actual card height. the bottom book details use absolute positioning outside the card area.
- This requires complex layout computation that also happens outside the card, to make the card containers have the correct height to display both the card image and the details below.
-
sizeMultiplier
is used many times in each of the cards.- Wherever some size attribute is set, it is multiplied by
sizeMultiplier
. This clutters the code quite a bit. - The
sizeMultiplier
is computed differently in each of the cards, although the result should be the same
- Wherever some size attribute is set, it is multiplied by
-
bookCoverAspectRatio
is passed as prop- This can also be computed in a single place.
- There's is a separate itemSlider component for each card type.
- The Vue templates and code in most component are mostly duplicates.
- The bookshelf scaling of spacing and font-sizes is inconsistent
- When the scaling changes (by increasing or decreasing the cover size), some of the spacing and font-sizes change, some don't
The following bookshelf fixes and refactoring were implemented:
- The height and width of bookshelf cards is now determined by default inside the card
- The height of the card graphics (cover image or material icon) has a default.
- All other properties are computed.
- the card computed height now includes the bottom description if it has one.
- The shelf height is now determined by the computed height of the cards inside it
- In lazyBookshelf, where the height needs to be determined in advance, one dummy card of the right type is mounted in order to get its width and height.
- This makes shelf height calculation straightforward and less error-prone.
- All the itemSliders are now merged into a single component
- The card component is dynamically determined by the shelf type.
- Also fixed some small edge case slider scrolling issue, and made it not dependent on the card width
- sizeMultiplier and bookCoverAspect ratio are now obtained from the store
- The scaling and font sizes is now made consistent by changing them to relative em units
- This is mostly done transparently by changing the default tailwind definitions
- A version of the original tailwind spacing is still available (by adding r to the spacing number, e.g. right-4r)
- At the bookshelf level, the font-size is set to sizeMultiplier * 1rem
- this makes the tailwind classes inside the bookshelf reactive to the sizeMultplier (since they are now specified in em units)
- this also makes sizeMultiplier multiplication redundant in most places (by changing rem units to em), making the code less cluttered.
- Fixed some buggy booksPerFetch behavior
- When cover size is set to smallest, lazyBookshelf doesn't get enough books to fill the first page, so something like this appears: This was due to booksPerFetch having static values. It was fixed to have a value depending on the the number of books per shelf and the number of shelfs per page.