Webdev 8458 migrate item navigator#64
Open
iisa wants to merge 6 commits into
Open
Conversation
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>
|
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WEBDEV-8458 Migrate item-navigator into elements
Migrates
@internetarchive/iaux-item-navigatorinto the elements repo as aproduction component (
ia-item-navigator), upgraded to the elements CSSconvention, 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: namedheader/mainslots for host content, a collapsible drawer driven by a
menuContentsprovider array, a minimized
menuShortcutsrail, 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-filesmenu (scrollable volume list, active-file highlighting, PDF flagging,
tri-state title sort).
ia-share-panel— social share links + copyable iframe/bbcode embedsnippets.
Lives at
src/elements/ia-item-navigator/; the navigator and itsconsumer-facing menus are exported from
src/elements/index.ts.Key decisions
ia-*convention across all elements (tags +IA*class names). Upstream used a mix ofiaux-*, un-prefixed(
menu-button), and Lit-2Ia*casing.modal-managerandshared-resize-observerwere type-only imports upstream, so they're replaced with local interfaces
(
interfaces/service-interfaces.ts) — zero runtime deps. The only new runtimedependency is
@internetarchive/metadata-service(^1.0.6), which isgenuinely used (
new MetadataResponse(...)in theitemattributeconverter). All 11 icons are inlined as Lit templates instead of pulling
in the
@internetarchive/icon-*packages.--item-navigator-*with component-private
--x--aliases and inline defaults;themeStylesisimported per component; hardcoded colors that map to the shared palette now
use tokens. Truly-internal styles stay plain CSS, per the styles guide.
(
--item-navigator-base-font-size, default10px) withemunits, ratherthan 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
@click=${this.toggleMenu}, passing theclick event as the
forceValueargument and settingmenuOpenedto aPointerEvent(it only "worked" because the object is truthy). Now wrapped somenuOpenedstays boolean.execCommand('copy')upgraded to the async Clipboard API in the sharepanel, with an
execCommandfallback only where the async API is missing.ia-sort-files-buttonsorts a copy rather than mutating the reactivefileListRawprop in place.Demo
Added an
ia-item-navigatorstory (auto-discovered, Production-Ready). Folds inthe useful examples from the upstream demo, kept self-contained (no
metadata-service fetch or external image hotlinks):
driving the viewable-files panel, with a long wrapping title and PDF entries;
header/mainslots in use;
toggles (fullscreen renders an in-frame "Exit fullscreen" control).
Testing
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.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
@internetarchive/elements/ia-item-navigator/ia-item-navigator.slots the theater into
slot="main"and supplies menu panel bodies asTemplateResults, so no heavy viewer dependencies come along.share → promote to elements → enrich demo → anchor sizing); happy to squash
before merge if preferred.