Skip to content

Webdev 8458 migrate item navigator#64

Open
iisa wants to merge 6 commits into
mainfrom
WEBDEV-8458-migrate-item-navigator
Open

Webdev 8458 migrate item navigator#64
iisa wants to merge 6 commits into
mainfrom
WEBDEV-8458-migrate-item-navigator

Conversation

@iisa

@iisa iisa commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

WEBDEV-8458 Migrate item-navigator into elements

Migrates @internetarchive/iaux-item-navigator into the elements repo as a
production component (ia-item-navigator), upgraded to the elements CSS
convention, with a demo and tests.

Ticket: https://webarchive.jira.com/browse/WEBDEV-8458

What's included

The full upstream package — the navigator shell and both bundled menus:

  • ia-item-navigator — the fullscreen-capable frame: named header/main
    slots for host content, a collapsible drawer driven by a menuContents
    provider array, a minimized menuShortcuts rail, responsive overlay/shift,
    loading spinner, and no-theater placeholder.
  • ia-menu-slider, ia-menu-button, ia-itemnav-loader,
    ia-no-theater-available
    — the shell's internal pieces.
  • ia-viewable-files-panel + ia-sort-files-button — the viewable-files
    menu (scrollable volume list, active-file highlighting, PDF flagging,
    tri-state title sort).
  • ia-share-panel — social share links + copyable iframe/bbcode embed
    snippets.

Lives at src/elements/ia-item-navigator/; the navigator and its
consumer-facing menus are exported from src/elements/index.ts.

Key decisions

  • Naming: adopted the elements ia-* convention across all elements (tags +
    IA* class names). Upstream used a mix of iaux-*, un-prefixed
    (menu-button), and Lit-2 Ia* casing.
  • Dependencies — minimized: modal-manager and shared-resize-observer
    were type-only imports upstream, so they're replaced with local interfaces
    (interfaces/service-interfaces.ts) — zero runtime deps. The only new runtime
    dependency is @internetarchive/metadata-service (^1.0.6), which is
    genuinely used (new MetadataResponse(...) in the item attribute
    converter). All 11 icons are inlined as Lit templates instead of pulling
    in the @internetarchive/icon-* packages.
  • CSS convention: public theming vars are exposed as --item-navigator-*
    with component-private --x-- aliases and inline defaults; themeStyles is
    imported per component; hardcoded colors that map to the shared palette now
    use tokens. Truly-internal styles stay plain CSS, per the styles guide.
  • Sizing: the component is anchored to a self-contained 10px base
    (--item-navigator-base-font-size, default 10px) with em units, rather
    than depending on the consumer's root font-size. This reproduces petabox's
    10px scale — which the upstream demo assumed via a document-root font-size —
    without forcing a 10px root on the rest of the elements demo.

Notable changes vs. the source

  • Bug fix: the menu toggle bound @click=${this.toggleMenu}, passing the
    click event as the forceValue argument and setting menuOpened to a
    PointerEvent (it only "worked" because the object is truthy). Now wrapped so
    menuOpened stays boolean.
  • execCommand('copy') upgraded to the async Clipboard API in the share
    panel, with an execCommand fallback only where the async API is missing.
  • ia-sort-files-button sorts a copy rather than mutating the reactive
    fileListRaw prop in place.
  • Dropped a dead, never-rendered method from the viewable-files panel.

Demo

Added an ia-item-navigator story (auto-discovered, Production-Ready). Folds in
the useful examples from the upstream demo, kept self-contained (no
metadata-service fetch or external image hotlinks):

  • a realistic multi-volume item (the "Master Book of American Folk Song")
    driving the viewable-files panel, with a long wrapping title and PDF entries;
  • a slotted header bar and a styled theater mock, showing the header/main
    slots in use;
  • the share panel and a populated shortcut rail;
  • live theming controls plus loaded / view-available / header / fullscreen
    toggles (fullscreen renders an in-frame "Exit fullscreen" control).

Testing

  • 47 Vitest browser-mode tests across the component (full repo suite: 211).
  • Covers: drawer open/close + toggle-button behavior, provider rendering,
    responsive overlay↔shift, no-theater state, slot-change and fullscreen
    events, menu selection/escape handling, file listing + PDF flags + URL
    building, sort cycling, share-option population + embed snippets + copy note.
  • npm run build, npm run lint, and the madge circular check all pass.
  • Verified live in the demo (renders under Production-Ready, drawer toggles,
    viewable-files sorts, share links resolve, embed copy works, icon/text sizes
    measured at the intended 10px-base scale), with no console errors.

Notes for reviewers

  • Consumers import via
    @internetarchive/elements/ia-item-navigator/ia-item-navigator.
  • The navigator is a shell — it doesn't render any specific viewer; the host
    slots the theater into slot="main" and supplies menu panel bodies as
    TemplateResults, so no heavy viewer dependencies come along.
  • The branch is 5 logically-scoped commits (migrate shell+viewable-files → add
    share → promote to elements → enrich demo → anchor sizing); happy to squash
    before merge if preferred.

iisa and others added 3 commits July 20, 2026 12:50
Port @internetarchive/iaux-item-navigator into src/labs/ia-item-navigator,
adopting the elements CSS convention, with a demo and tests.

Scope: the navigator shell (ia-item-navigator + ia-menu-slider,
ia-menu-button, ia-itemnav-loader, ia-no-theater-available) and the
viewable-files menu (ia-viewable-files-panel + ia-sort-files-button). The
bundled social share panel is left as a follow-up.

- Rename to the ia-* convention (tag ia-item-navigator, class IAItemNavigator);
  sub-elements prefixed likewise.
- Loosen deps: modal-manager and shared-resize-observer were type-only imports,
  now local interfaces (interfaces/service-interfaces.ts) — zero runtime dep.
  Keep @internetarchive/metadata-service (real runtime use in the item
  converter). Inline all icons (ellipses, collapse-sidebar, viewable-files,
  sort) instead of adding icon-package deps.
- CSS convention: public theming vars become --item-navigator-* with --x--
  private aliases and inline defaults; themeStyles imported per component;
  palette tokens replace hardcoded colors where they map.
- Fix a latent toggle bug: the menu button bound @click=${this.toggleMenu},
  passing the event as forceValue; now wrapped so menuOpened stays boolean.
- ia-sort-files-button sorts a copy rather than mutating the reactive prop
  in place; sort icons use currentColor so they theme with the icon fill var.
- Demo story (labs, auto-discovered) wires the real viewable-files panel as a
  menu provider with the sort button as its action; live style settings.
- Vitest browser-mode tests (42) covering drawer, provider rendering,
  responsive mode, no-theater state, menu selection, file listing, PDF
  flagging, URL building and sort cycling.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Complete the migration by porting the social share panel (from
iaux-in-share-panel) as ia-share-panel, so the item-navigator's bundled menus
are fully migrated.

- Rename to ia-share-panel / IASharePanel; export shareIcon as the provider
  icon.
- Inline all 7 social/link icons (share, twitter, facebook, tumblr, pinterest,
  email, link) as .fill-color templates in menus/share-icons.ts — no
  icon-package deps.
- Upgrade the deprecated document.execCommand('copy') to the async Clipboard
  API, falling back to execCommand only where the async API is unavailable;
  track the copy-note timeout per note via a WeakMap.
- CSS convention: theming vars become --item-navigator-* with --x-- aliases and
  inline defaults; base-font-family from themeStyles replaces the hardcoded
  font stack.
- Wire the share panel into the demo as a menu provider.
- 5 Vitest tests: option population, share-URL building, embed snippets,
  header toggle, and the copy-note flash.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Move src/labs/ia-item-navigator to src/elements/ia-item-navigator now that the
migration is complete, treat it as a production-ready component:

- Drop the `labs` flag from the story so it lists under Production-Ready and
  its import/usage snippets use the @internetarchive/elements/ia-item-navigator
  path (no /labs segment).
- Export the navigator and its consumer-facing menus (viewable-files panel,
  sort-files button, share panel) from src/elements/index.ts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

🚀 View preview at
https://internetarchive.github.io/elements/pr/pr-64/

Built to branch ghpages at 2026-07-20 21:14 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@codecov-commenter

codecov-commenter commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.60870% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.81%. Comparing base (cd1ffd3) to head (cd3b373).

Files with missing lines Patch % Lines
...rc/elements/ia-item-navigator/ia-item-navigator.ts 68.80% 30 Missing and 4 partials ⚠️
src/elements/ia-item-navigator/ia-menu-slider.ts 86.44% 1 Missing and 7 partials ⚠️
...ia-item-navigator/menus/ia-viewable-files-panel.ts 82.14% 4 Missing and 1 partial ⚠️
...elements/ia-item-navigator/menus/ia-share-panel.ts 94.87% 1 Missing and 1 partial ⚠️
...ts/ia-item-navigator/menus/ia-sort-files-button.ts 90.47% 0 Missing and 2 partials ⚠️
...ments/ia-item-navigator/ia-no-theater-available.ts 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #64      +/-   ##
==========================================
+ Coverage   78.62%   79.81%   +1.19%     
==========================================
  Files          17       27      +10     
  Lines         697      996     +299     
  Branches      189      250      +61     
==========================================
+ Hits          548      795     +247     
- Misses        100      136      +36     
- Partials       49       65      +16     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

iisa and others added 3 commits July 20, 2026 13:34
Fold the useful examples from the upstream demo into the story:

- Realistic multi-file item (the "Master Book of American Folk Song" volumes)
  for the viewable-files panel, including a deliberately long title (wrapping)
  and PDF entries (PDF flag), with one active file.
- A slotted header bar (brand + item title link) and a styled theater mock in
  slot="main", so the shell's host-content slots are shown in use.
- A populated minimized shortcut rail (menuShortcuts) alongside the drawer.
- Header, view-available, and fullscreen toggles; fullscreen renders an
  in-frame "Exit fullscreen" control so the demo can't trap the viewer.
- Size shortcut-rail icons consistently with the toggle button, and give
  viewableFilesIcon the shared .ia-icon class so it themes/sizes like the rest.

Kept self-contained: no metadata-service fetch or external image hotlinks.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The components' internal sizing was in rem, calibrated for petabox's 10px root
font-size (which the upstream demo set on the document). In the elements demo
(default 16px root) everything — icons especially — rendered ~1.6x too large.

Make the navigator self-contained instead of depending on the consumer's root:

- Set font-size: var(--item-navigator-base-font-size, 10px) on each component's
  :host and convert internal rem units to em, so sizing resolves against the
  component's own base. Consumers can override the var to rescale everything.
- Normalize buttons with `font: inherit` (and reset the header/social icon
  wrappers), since form controls don't inherit font-size — otherwise em icons
  resolved against the browser's default button font-size.
- Move menu-button text sizing off the flex container onto the label so the
  icon box isn't compounded.

Verified in the demo: toggle/shortcut icons 24px, menu icon box 42px, labels
16px, close/sort/share icons ~20px — matching the upstream 10px-base scale.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The provider icons inside the open drawer weren't explicitly sized, so they
filled the 42px icon box instead of matching the 24px minimized-rail shortcuts.
Size the glyph within the menu-button icon box to --item-navigator-icon-width--
(the same var the rail uses) and drop the hardcoded 100% inline size on the
demo's placeholder icon so CSS controls it. Drawer icons now render 24px, in
line with the shortcuts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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