feat: Add 'Read More' - PART 2#11682
Conversation
…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.
for more information, see https://pre-commit.ci
…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.
…library into feat/web-component-read-more
- 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.
for more information, see https://pre-commit.ci
…of dots for improved visual consistency
…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.
…t-read-more-part-2
cdrini
left a comment
There was a problem hiding this comment.
Seeing some blocking issues for the TOC on the search page:
https://testing.openlibrary.org/search?q=java+tree&mode=everything
Before:
I like the idea of making the leader dots in the TOC lighter; it makes the overall page look much cleaner! There's still something a bit funny about this UX; it's causing my eyes to strain when I see it; causing a kind of funny visual banding effect on desktop. It's a bit more accentuated now that the font size is smaller and the lines are fainter. Not sure what solution is! Not a blocker.
|
@cdrini the Search ToC primary issue that you are referring to is the background color of the new Read More component? |
|
Yes exactly! It should look like the original designs, the change in colours/font size/padding make it look broken currently. TOC in search is a new feature that was just recently released, so we need to be more mindful of regressions, to make sure we lead with our best foot forward. It's also a great case-study in some of the difficulties that web component CSS isolation causes ; we do want our web components to support being styled to match their context. We should be able to achieve the same UI with adding some |
- Added new properties: background-color, label-size, and padding-left for improved customization of the OLReadMore component. - Updated the component's internal styles and logic to accommodate these new properties. - Modified example usage in SearchResultsWork.html to demonstrate the new attributes.
I've added additional properties to support this variant of the component. In general, I'd lean into properties over exposing |
cdrini
left a comment
There was a problem hiding this comment.
Nice lgtm! Merging as-is, but I think we might want to brainstorm about the styling interface during our call a bit. Also there's one small non-blocking bug with the TOC in search when in librarian mode, where clicking "show more" causes the search item card to become selected. I think the code was previously ignoring clicks on anchor elements.
This looks great!! 🥳 Love all the deleted/DRY'd up code!
| backgroundColor: { type: String, attribute: 'background-color' }, | ||
| labelSize: { type: String, attribute: 'label-size' }, | ||
| paddingLeft: { type: String, attribute: 'padding-left' }, |
There was a problem hiding this comment.
I'm not keen on these being separate properties on the web component (eg <ol-read-more padding-left="4px">); that's a pattern I haven't seen anywhere before. It blurs the separation between styling and html content, and adds a decent amount of JS for stuff like parsing values, and creates a syntax slightly separate from CSS that consumers have to learn per-component. Not a blocker, but I think this is something we might want to discuss on Friday to get folks' thoughts on. CC @RayBB
Patterns I have seen elsewhere (eg PrimeVue, webawesome) are:
CSS custom properties are the public interface
<ol-read-more style="--ol-read-more-pading-left: 4px"></ol-read-more>Or
ol-read-more {
--ol-read-more-padding-left: 4px;
}CSS parts are the public interface
ol-read-more::part(toggle-btn) {
padding-left: 4px;
}I'm partial to using custom properties for themeing/styling that applies everywhere, and exposing every "chunk" of a component as a ::part for further config. I think that strikes a good compromise between having controlled interfaces where we can easily make updates to a component's internals without having to maintain a huge public API / breaking clients, while also allowing clients to configure the component without them having to modify the component every time a new use case pops up to expose new hooks. A balance of flexibility and rigidity/brittleness.
There was a problem hiding this comment.
@cdrini thanks for sharing alternative directions as it illuminates the deficiencies with the padding left property. I think the css ::part is prob the right approach.
I'll get a PR ready ahead of our meeting week, it will also be a good opportunity to discuss our strategy for when to expose these css hooks . Our strategy doesn't have be to perfect, as web component usage is minimal in the codebase, and we have time to dial it in as we learn through experience. Thanks again for the feedback.
|
@lokesh what a huge win! I love seeing a PR like this knocking out hundreds of old lines of code. Excited to see what's next! |
* Enhance build process by adding support for lit-components in Makefile and package.json; update package-lock.json to include lit dependencies. * Add OLReadMore component for expandable/collapsible content - 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. * Add OL components and update book description rendering - 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. * Update OLReadMore component text for consistency - 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. * Update capitalization of OLReadMore component text for consistency - Changed 'Read more' and 'Read less' to 'Read More' and 'Read Less' for uniformity in capitalization in the book description section. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Refactor OLReadMore component to use <details> and <summary> for improved 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. * Update build configuration for Lit components - 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. * Refactor OLReadMore component to enhance toggle functionality and styling - 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. * Enhance accessibility of OLReadMore component by adding aria-hidden attribute to chevron icon - Updated the chevron SVG icon in the OLReadMore component to include the aria-hidden attribute for improved screen reader compatibility. * Refactor Table of Contents display in edition view for improved user 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. * Refactor work description display in edition view to use ol-read-more 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. * Refactor chapter display in search results to utilize ol-read-more component - 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. * Remove ol-read-more component and associated styles - 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. * Remove ReadMore component and associated functionality - 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. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Remove commented line for line-height in Table of Contents styles * Update Table of Contents styles to use a lighter grey for the border of dots for improved visual consistency * Remove ReadMore functionality from bundlesize configuration and HTML 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. * feat: Enhance OLReadMore component with new properties - Added new properties: background-color, label-size, and padding-left for improved customization of the OLReadMore component. - Updated the component's internal styles and logic to accommodate these new properties. - Modified example usage in SearchResultsWork.html to demonstrate the new attributes. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Enhance build process by adding support for lit-components in Makefile and package.json; update package-lock.json to include lit dependencies. * Add OLReadMore component for expandable/collapsible content - 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. * Add OL components and update book description rendering - 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. * Update OLReadMore component text for consistency - 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. * Update capitalization of OLReadMore component text for consistency - Changed 'Read more' and 'Read less' to 'Read More' and 'Read Less' for uniformity in capitalization in the book description section. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Refactor OLReadMore component to use <details> and <summary> for improved 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. * Update build configuration for Lit components - 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. * Refactor OLReadMore component to enhance toggle functionality and styling - 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. * Enhance accessibility of OLReadMore component by adding aria-hidden attribute to chevron icon - Updated the chevron SVG icon in the OLReadMore component to include the aria-hidden attribute for improved screen reader compatibility. * Refactor Table of Contents display in edition view for improved user 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. * Refactor work description display in edition view to use ol-read-more 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. * Refactor chapter display in search results to utilize ol-read-more component - 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. * Remove ol-read-more component and associated styles - 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. * Remove ReadMore component and associated functionality - 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. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Remove commented line for line-height in Table of Contents styles * Update Table of Contents styles to use a lighter grey for the border of dots for improved visual consistency * Remove ReadMore functionality from bundlesize configuration and HTML 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. * feat: Enhance OLReadMore component with new properties - Added new properties: background-color, label-size, and padding-left for improved customization of the OLReadMore component. - Updated the component's internal styles and logic to accommodate these new properties. - Modified example usage in SearchResultsWork.html to demonstrate the new attributes. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

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:
Removes old Read More implementation:
Testing
Screenshot
Stakeholders
@RayBB @mekarpeles @cdrini @jimchamp