Skip to content

Adopt ol-chip for subject tags, author page, and publisher page#12261

Merged
lokesh merged 7 commits intointernetarchive:masterfrom
linhkhanhhoang:12158/adopt_ol_chip
Apr 16, 2026
Merged

Adopt ol-chip for subject tags, author page, and publisher page#12261
lokesh merged 7 commits intointernetarchive:masterfrom
linhkhanhhoang:12158/adopt_ol_chip

Conversation

@linhkhanhhoang
Copy link
Copy Markdown
Contributor

@linhkhanhhoang linhkhanhhoang commented Apr 2, 2026

Closes #12158

This PR adopted the ol-chip component into the SubjectTags macro, the Author page — subjects by author, the Publisher page — common subjects, Search result subject highlights, WorkInfo macro, Tag page, and List page subjects.

Technical

For the SubjectTags macro, we didn't use because when we did, it messed up the expand/clamp part, and it wouldn't show any subjects unless you clicked the toggle.

Also, we didn't know how to test for the WorkInfo macro, Tag page, and List page subjects changes because we couldn't find where they are located.

Testing

Screenshot

SubjectTags macro
Screenshot 2026-04-01 at 10 46 31 PM
The Author page — subjects by author
Screenshot 2026-04-01 at 10 47 01 PM
the Publisher page — common subjects
Screenshot 2026-04-02 at 11 13 25 AM
Search result subject highlights
Screenshot 2026-04-08 at 9 11 23 PM

Stakeholders

@lokesh

Co-author-by: Evelyn Pham <phamphuonglinh250104@gmail.com>
Copilot AI review requested due to automatic review settings April 2, 2026 02:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adopts the ol-chip web component for subject-tag displays to align UI/UX with existing chip usage (e.g., search facets / related subjects) and improve consistency across book, author, and publisher pages.

Changes:

  • Updated SubjectTags macro to render subjects as <ol-chip> elements.
  • Updated author and publisher templates to render subject facets as <ol-chip> within <ol-chip-group>.
  • Added CSS intended to improve header alignment in clamped link-box layouts.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
static/css/components/link-box.css Adds styling meant for clamped link-box headers.
openlibrary/templates/type/author/view.html Renders “subjects by author” facets using ol-chip-group + ol-chip.
openlibrary/templates/publishers/view.html Renders “common subjects” using ol-chip-group + ol-chip.
openlibrary/macros/SubjectTags.html Renders work/edition subject tags using ol-chip.

Comment thread static/css/components/link-box.css Outdated
Comment thread openlibrary/macros/SubjectTags.html
@lokesh lokesh self-requested a review April 2, 2026 03:27
@lokesh lokesh self-assigned this Apr 2, 2026
@lokesh lokesh removed their request for review April 2, 2026 03:27
@linhkhanhhoang linhkhanhhoang marked this pull request as draft April 2, 2026 15:08
…e subjects

Co-authored-by: Evelyn Pham <phamphuonglinh250104@gmail.com>
@linhkhanhhoang linhkhanhhoang marked this pull request as ready for review April 9, 2026 03:10
Comment thread openlibrary/macros/WorkInfo.html Outdated
@lokesh
Copy link
Copy Markdown
Collaborator

lokesh commented Apr 13, 2026

Everything looks great, thanks for your help with this. 🙏

Also, we didn't know how to test for the WorkInfo macro, Tag page, and List page subjects changes because we couldn't find where they are located.

I've started a Manual Testing section in our wiki which should help with this: https://docs.openlibrary.org/developers/tools/testing.html#manual-testing

There are still some challenging in building up local data so the testing better reflects the live site experience.

lokesh and others added 2 commits April 13, 2026 14:41
… in link-box

- Use composedPath() in clampers.js so clicks on elements inside
  anchor tags (e.g. ol-chip inside <a>) are correctly detected
- Add Chip Group section to the design page with gap and wrapping demos
- Add spacing for ol-chip inside .link-box .clamp

clamper.addEventListener('click', (event) => {
if (event.target instanceof HTMLAnchorElement) {
if (event.composedPath().some(el => el instanceof HTMLAnchorElement)) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This prevents the clamper from toggling when a link is clicked, even if it is clicked in the shadow dom.

</script>
</section>
</article>
<article class="design-pattern" id="chip-group">
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Added ol-chip-group examples for future devs. They will be visible at: https://openlibrary.org/developers/design

@evelynpham04
Copy link
Copy Markdown
Contributor

evelynpham04 commented Apr 16, 2026

Testing Summary

I completed manual testing for the WorkInfo macro, Tag page, and List page subjects changes in this PR with the following approach:

1. WorkInfo Macro:

  • To validate the changes, I temporarily enabled it by adding a hook in openlibrary/templates/type/edition/view.html
$if query_param('legacy_workinfo'):
    $:macros.WorkInfo(work)
  • Then accessed: http://localhost:8080/works/OL893415W?legacy_workinfo=1
a09105e6-361e-4804-8f40-bd16fc79cc64

2. Tag Page:

  • Created a sample tag test-tag for testing
  • Then accessed: http://localhost:8080/tags/OL1T/test-chip
Screen Shot 2026-04-15 at 10 02 25 PM

3. List Page:

  • The subject section is currently disabled behind a conditional if False in openlibrary/templates/type/list/view_body.html (line ~166)
  • To test, I temporarily changed
if False → if True
be95c6c5-375b-45ba-a227-16dcb8d8f8c8

All testing completed. Ready for review. @lokesh

@lokesh
Copy link
Copy Markdown
Collaborator

lokesh commented Apr 16, 2026

@evelynpham04 thanks for all the testing from your side. I actually added the Needs: Testing tag as a reminder to myself to put it on the open library testing server and verify before deploying. Which I have since done. Everything looks great!

Sorry for the confusion about the testing tag, though more testing never hurts. Should go out with the next deploy next week.

@lokesh lokesh merged commit f3839bb into internetarchive:master Apr 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adopt ol-chip component for subject tag displays across the site

4 participants