Skip to content

Conversation

@lokesh
Copy link
Collaborator

@lokesh lokesh commented Jan 8, 2026

Continuation of the work done in #11666

This PR finishes replacing all instances of the Read More feature with the new web component. It also removes the code related to the old component.

Technical

Extends usage to additional locations:

  • Table of Contents and Work description in edition view
  • Chapter highlights in search results

Removes old Read More implementation:

  • Deleted openlibrary/macros/ReadMore.html macro
  • Deleted static/css/components/read-more.less styles
  • Deleted openlibrary/plugins/openlibrary/js/readmore.js component
  • Deleted tests/unit/js/readmore.test.js tests

Testing

  1. Navigate to an edition page with a long description (e.g., /books/OL...)
  • Verify description is truncated to ~4 lines with "Read More" button
  • Click to expand/collapse, confirm toggle works
  1. Navigate to an edition page with a Table of Contents
  • Verify TOC is truncated with "Read More" button when content exceeds 200px
  • Toggle to expand/collapse

Screenshot

Frame 427318911

Stakeholders

@RayBB @mekarpeles @cdrini @jimchamp

lokesh and others added 17 commits January 5, 2026 13:05
…e and package.json; update package-lock.json to include lit dependencies.
- Introduced a new web component, OLReadMore, that supports height-based and line-based truncation.
- Updated index.js to import the new component for registration as a custom element.
- Included the new OL components script in the footer for enhanced functionality.
- Replaced the existing book description implementation with the OLReadMore component for better user experience with expandable/collapsible content.
- Changed 'Read more' and 'Read less' to 'Read More' and 'Read Less' for uniformity in capitalization.
- Removed unnecessary margin-left style from the chevron icon.
- Changed 'Read more' and 'Read less' to 'Read More' and 'Read Less' for uniformity in capitalization in the book description section.
…oved accessibility and functionality

- Replaced button elements with <details> and <summary> for better semantic structure.
- Updated styles for toggle behavior and chevron icon.
- Simplified the logic for handling content expansion and truncation.
- Enhanced user experience by managing scroll behavior when collapsing content.
- Changed the Vite configuration file reference in the Makefile and package.json from `lit-vite.config.js` to `vite-lit.config.mjs`.
- Removed the obsolete `lit-vite.config.js` file.
- Updated the new Vite configuration file to include a comment indicating its purpose for Vue components.
…ling

- Replaced <details> and <summary> elements with button elements for improved control over expansion and collapse.
- Updated CSS class names for clarity and consistency.
- Simplified event handling for toggling content visibility.
- Enhanced button styles and added hover effects for better user interaction.
…ttribute to chevron icon

- Updated the chevron SVG icon in the OLReadMore component to include the aria-hidden attribute for improved screen reader compatibility.
…experience

- Updated the Table of Contents section to use the ol-read-more component for better expansion and collapse functionality.
- Adjusted CSS styles for toc entries, including font size and padding for enhanced readability.
- Improved the visual appearance of the toc__dots with a more defined border color.
… component

- Replaced the previous work description structure with the ol-read-more component for improved readability and user interaction.
- Adjusted the maximum lines displayed and updated the text for expanding and collapsing the description.
…mponent

- Replaced the existing chapter display structure with the ol-read-more component for improved readability and user interaction.
- Maintained functionality for displaying chapter links and pagination while enhancing the overall user experience.
- Deleted the ReadMore.html macro and its corresponding CSS styles from the project.
- Updated LESS files to remove references to the read-more component, streamlining the codebase.
- Deleted the ReadMoreComponent and its related JavaScript and CSS files to streamline the codebase.
- Updated the index.js file to remove conditional loading of read-more components.
- Adjusted HTML templates to eliminate references to the read-more functionality, enhancing overall clarity and maintainability.
lokesh added 3 commits January 8, 2026 13:54
…template

- Deleted the ReadMore entry from bundlesize.config.json to streamline bundle size checks.
- Updated the edition view template to remove the ReadMore class from excerpts, enhancing clarity and maintainability.
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.

2 participants