openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Replace the Share modal with an ol-popover menu

Open lokesh opened this issue 2 months ago • 8 comments

Summary

The Share link opens an old jQuery colorbox modal: a row of large PNG/SVG logos with captions underneath. Replace it with an <ol-popover> that shows a compact menu. Style each row like the simple links in the Browse popover in the site header: a small, muted icon with the label to its right.

Related: #13651 (the same change for the Wikipedia citation dialog)

Image

Where it's used

  • Book page: next to the title and author (openlibrary/templates/type/edition/title_and_author.html), and in the sidebar links on desktop and mobile (macros/databarWork.html → type/edition/modal_links.html)
  • Public My Books pages: reading log shelves, lists and the main My Books page (openlibrary/templates/account/view.html). This version passes show_embed=False.

Current implementation

  • Markup: openlibrary/macros/ShareModal.html
  • JS: initShareModal in openlibrary/plugins/openlibrary/js/modals/index.js (colorbox and the Copy URL toast), wired up in js/main.js
  • Share URLs: set_share_links() in openlibrary/plugins/upstream/utils.py (Facebook, Twitter, Pinterest)
  • Other menu items: Embed (uses prompt() with the iframe code), Copy URL and QR Code
  • Images: static/images/{facebook,twitter,pinterest}.svg, embed.png, copy_url.png, qr_code.png

Reference implementation

  • Browse popover: openlibrary/templates/lib/browse_popover.html. Look at .browse-popover__links / .browse-popover__link, which use macros.icon(..., size="sm") followed by the label.
  • Styles: static/css/components/header-bar.css
  • Popover component: openlibrary/components/lit/OlPopover.js. The first example under Popover on the Components design page is a bare <ol-popover> holding a short list of links, which is the shape this menu should take.
  • Toast: for the Copy URL feedback, use showToast() from openlibrary/components/lit/OlToastRegion.js. See the "Imperative use" example under Toast.
  • Icon system: see the Icons design page, especially "Adding an icon".

Icons

Use macros.icon() for every row instead of the current images. Lucide has generic glyphs for Copy URL (link or copy), Embed (code) and QR Code (qr-code). Lucide deliberately doesn't ship brand logos, so get the brand icons from Tabler Icons (MIT license), e.g. brand-facebook, brand-x, brand-pinterest:

  1. Add the SVGs to a new static/icons/src/tabler/ folder. Tabler uses the same 24×24 currentColor stroke format.
  2. Add a Tabler license section to static/icons/ATTRIBUTION.md.
  3. Run make icons.

Acceptance criteria

  • [ ] Clicking "Share" opens an <ol-popover> anchored to the trigger, and a bottom tray on mobile.
  • [ ] Each item is a menu row with a small muted icon and a label, matching the Browse popover links.
  • [ ] Share links still open in a new tab, and every data-ol-link-track="Share|…" attribute is kept.
  • [ ] Copy URL still copies and shows the toast, and closes the popover.
  • [ ] Embed stays hidden when show_embed=False.
  • [ ] Brand icons are added from Tabler with attribution. The old share images and colorbox wiring are removed if nothing else uses them (check with grep first).
  • [ ] Works on every surface listed above, including when both book-page triggers render on the same page.
  • [ ] Keyboard works end to end: open, move through the items, Escape closes and focus returns to the trigger.
  • [ ] Strings stay translatable, following docs/ai/i18n.md.

Getting started

  • Read docs/ai/design.md and docs/ai/web-components.md first.
  • Test on a local edition page, e.g. http://localhost:8080/books/OL6M, and on a public reading log shelf.

lokesh avatar Sep 16 '26 22:09 lokesh

Context (from codebase research)

  • Reference implementation is real and current: openlibrary/templates/lib/browse_popover.html already renders an ol-popover with icon + label rows exactly as this issue describes — https://github.com/internetarchive/openlibrary/blob/fbec386500c9872beedbe7d8dd30595b19ff7be1/openlibrary/templates/lib/browse_popover.html#L46-L71 (see .browse-popover__link + macros.icon(..., size="sm")). That template shipped in #12917 ("Browse menu: redesign as a popover with featured destinations"), authored by @lokesh — same pattern, same author, good precedent to copy from directly.
  • Current markup confirmed at openlibrary/macros/ShareModal.html (83 lines) — https://github.com/internetarchive/openlibrary/blob/fbec386500c9872beedbe7d8dd30595b19ff7be1/openlibrary/macros/ShareModal.html#L1-L83. It is a Templetor (.html) macro, not Jinja.
  • initShareModal / addShareModalButtonListeners in modals/index.js are share-specific, but the file's displayModal() (colorbox) is shared with initNotesModal and initObservationsModal — https://github.com/internetarchive/openlibrary/blob/fbec386500c9872beedbe7d8dd30595b19ff7be1/openlibrary/plugins/openlibrary/js/modals/index.js#L379-L396. So the acceptance criterion "remove colorbox wiring if nothing else uses it" applies only to the Share-specific functions/images — the jquery-colorbox dependency itself must stay for Notes/Observations.
  • set_share_links() still labels the third link "Twitter" (used for both the display text and the data-ol-link-track="Share|Twitter" tag) — https://github.com/internetarchive/openlibrary/blob/fbec386500c9872beedbe7d8dd30595b19ff7be1/openlibrary/plugins/upstream/utils.py#L594-L621. The issue asks for the Tabler brand-x glyph but doesn't say whether the label/track tag should become "X" — flagged below.
  • Confirmed static/icons/src/ currently only has lucide/ and custom/ subfolders — no tabler/ yet, matching the issue's ask to create one, with ATTRIBUTION.md following the existing per-folder license section pattern.
  • The three call sites build the trigger markup differently: title_and_author.html and modal_links.html each define their own local icon_link() macro, while account/view.html builds the trigger as a raw HTML string with macros.icon() inline (https://github.com/internetarchive/openlibrary/blob/fbec386500c9872beedbe7d8dd30595b19ff7be1/openlibrary/templates/account/view.html#L72-L77). None of these are unified — worth knowing before wiring the ol-popover trigger slot on all three surfaces.
  • No open or in-flight PR currently touches ShareModal.html (checked via an in:files PR search) — no conflicting work.

Issue Assessment

Open questions

  • Should the share label/analytics tag for the "Twitter" row become "X" to match the new brand-x icon, or should the icon change while the label/tracking string stays "Twitter" for continuity with existing Matomo history? set_share_links() currently drives both from the same string.
  • Should the duplicated icon_link() trigger helpers in title_and_author.html / modal_links.html, and the inline trigger markup in account/view.html, be unified as part of this conversion, or is keeping them separate (just swapping in ol-popover per-site) acceptable for this issue's scope?

🔔 Stakeholders No additional cc needed — @lokesh is both the issue author and the assigned Lead: @lokesh, and is also the author of the precedent PR (#12917) this issue points to.


Full triage checklist
  • [x] Triage — correct labels applied or removed
  • [x] Problem / opportunity — problem is clear, audience identified, actionable
  • [x] Scope — issue is well-scoped; does not try to do too many things
  • [x] Justification — reasoning and impact stated; sufficient for leads to prioritize
  • [x] Success & testing criteria — defines what "done" looks like, verifiable by a contributor
  • [x] Proposal & breakdown — concrete plan present; checklist actionable for a contributor
  • [ ] If bug: environment & repro steps — not applicable, this is a refactor, not a bug
  • [x] Risks, concerns, open questions — identified and surfaced above
  • [x] Richy context — relevant code, commits, PRs reviewed; no duplicate or conflicting PR found
  • [x] References — screenshot, reference implementation, and design page linked

[!NOTE] This comment was automatically generated by Richy (https://github.com/internetarchive/openlibrary/blob/master/.github/workflows/issue_enrichment.md), Open Library's issue enrichment assistant, on behalf of @mekarpeles. This is NOT a sign-off. This issue needs lead review before work begins.

openlibrary-bot avatar Sep 16 '26 22:09 openlibrary-bot

Hi @lokesh I would like to work on this issue if it's not resolved yet.

sh011 avatar Sep 17 '26 08:09 sh011

Hey @lokesh, I’d like to contribute to this repo as I’m a beginner in open source. Could you guide me on where I can start, or let me know if there’s a channel/community I can join for guidance?

Also, if possible, could this issue be assigned to me? I’d love to work on it and contribute to the project.

MohitSAGAR11 avatar Sep 17 '26 17:09 MohitSAGAR11

@sh011 I'll assign to you. Please let me know if you need any additional guidance.

@MohitSAGAR11 I'll sign one of the other similar issues to you. Thanks to both of you.

lokesh avatar Sep 17 '26 17:09 lokesh

Hi @lokesh I have created the PR and resolved all Copilot recommendations. Please have a look and do let me know if anything is missing. Happy to contribute!

sh011 avatar Sep 19 '26 13:09 sh011

Hi @lokesh,

I’d like to contribute to this repository, as I’m a beginner in open source and looking to get started. Could you please guide me on where I should begin, or let me know if there’s a community/channel where I can connect with others for guidance?

Also, if the issue is suitable for a beginner, would it be possible to assign it to me? I’d be happy to work on it and make my first contribution to the project.

Thank you! Looking forward to contributing. 🙌

KARTHIK-BAIREDDY avatar Sep 20 '26 07:09 KARTHIK-BAIREDDY

Hi! @lokesh I’d like to work on this issue as my first contribution to Open Library. I’ve gone through the description and the referenced ol-popover implementation, and I’d like to take this up.

Is it okay if I work on this issue and submit a PR?

raunakk-singh avatar Sep 21 '26 08:09 raunakk-singh

Hi @raunakk-singh @KARTHIK-BAIREDDY, the issue is already assigned to me, the PR is already created and waiting to be merged.

Hope you understand the flow of open source contribution.

sh011 avatar Sep 21 '26 08:09 sh011