Skip to content

Add Lookbook preview for lazy-loaded tab panels#66

Open
joshsadam wants to merge 6 commits into
mainfrom
tabs-lazy-prev-ew
Open

Add Lookbook preview for lazy-loaded tab panels#66
joshsadam wants to merge 6 commits into
mainfrom
tabs-lazy-prev-ew

Conversation

@joshsadam

@joshsadam joshsadam commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

What does this PR do and why?

Adds a new Lookbook preview that demonstrates lazy-loaded tab panels using Pathogen::Tabs#with_lazy_panel and Turbo Frames.

The preview shows a three-tab layout where the selected panel renders immediately and the other panels fetch mocked Turbo Frame responses when their tabs become visible. To support this without adding demo-only Rails routes, the Lookbook preview layout now boots MSW (Mock Service Worker) before Turbo starts. MSW intercepts requests to /lookbook-mocks/tabs/lazy-load/:panel and returns realistic frame HTML with a short artificial delay.

Changes include:

  • New Turbo Frame Lazy Load preview under Pathogen::Tabs
  • lookbook_mocks/tabs_lazy_load.js MSW handlers and lookbook_preview.js entry point
  • mockServiceWorker.js in demo/public/ for browser interception
  • MSW added as a dev dependency (package.json, pnpm-lock.yaml)
  • ESLint config updated to allow MSW imports in demo JavaScript
  • Minor copy updates in the Advanced Features preview

Screenshots or screen recordings

image

Requests:
image

How to set up and validate locally

  1. Update dependencies in root folder bin/setup
  2. cd demo & bin/dev
  3. Open http://localhost:3001/lookbook
  4. Navigate to Pathogen::Tabs → Turbo Frame Lazy Load
  5. Confirm the Summary tab content is visible on load
  6. Click Metrics and Timeline — each panel should show a brief loading state, then render mocked content with a green Loaded by MSW badge
  7. Optionally review Advanced Features for updated lazy-loading documentation copy

PR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

@joshsadam joshsadam self-assigned this Jun 8, 2026
@joshsadam joshsadam changed the title Add tab lazy load previews Add Lookbook preview for lazy-loaded tab panels Jun 8, 2026
@joshsadam joshsadam added dependency javascript Pull requests that update javascript code labels Jun 8, 2026
@joshsadam joshsadam force-pushed the tabs-lazy-prev-ew branch from f25e15f to 984fb1e Compare June 10, 2026 16:05
@joshsadam joshsadam requested a review from ericenns June 12, 2026 17:37
@joshsadam joshsadam force-pushed the tabs-lazy-prev-ew branch 2 times, most recently from cbed100 to 8f4d031 Compare June 17, 2026 11:57
@joshsadam joshsadam requested a review from ChrisHuynh333 June 22, 2026 15:12
@joshsadam joshsadam force-pushed the tabs-lazy-prev-ew branch 5 times, most recently from 2dcd848 to a6b81ed Compare July 7, 2026 16:19
MSW intercepts Turbo Frame requests in the Lookbook preview
without adding demo-only Rails routes.
Lookbook previews now start MSW before Turbo boots so lazy tab
panels can fetch mocked frame responses without demo routes.
Lookbook previews use type token classes outside the Tailwind
scan path. Inline @source keeps those utilities in the artifact.
Reorder examples, drop redundant advanced_features preview, align
surfaces with the design contract, and render preview chrome through
Pathogen typography helpers.
…ration

Modified the Procfile to use the PORT environment variable for the web server and updated the default port in the dev script to 3001. Cleared the hosts configuration in development.rb to facilitate secure port forwarding with VSCode.
Copilot AI review requested due to automatic review settings July 10, 2026 16:26
@joshsadam joshsadam force-pushed the tabs-lazy-prev-ew branch from a6b81ed to 0e4b7c5 Compare July 10, 2026 16:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Lookbook preview demonstrating Pathogen::Tabs#with_lazy_panel with Turbo Frames, using Mock Service Worker (MSW) in the demo app to intercept lazy-frame requests without adding demo-only Rails routes. The PR also refreshes existing Tabs previews to use Pathogen view helpers/typography tokens and adjusts demo wiring to load MSW before Turbo boots.

Changes:

  • Add a new “Turbo Frame Lazy Load” preview and MSW handlers/entrypoint to mock /lookbook-mocks/tabs/lazy-load/:panel frame responses.
  • Update the demo Lookbook preview layout/importmap and add the MSW service worker asset; add turbo-rails to the demo app.
  • Modernize Tabs preview templates (headings, supporting text, lists, typography tokens) and add a LazyPanel fallback test + helper method.

Reviewed changes

Copilot reviewed 22 out of 24 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/components/previews/pathogen/tabs_preview/url_sync.html.erb Updates preview copy/layout to use Pathogen helpers and new typography tokens.
test/components/previews/pathogen/tabs_preview/turbo_frame_lazy_load.html.erb Adds the new Lookbook preview demonstrating lazy-loaded panels via Turbo Frames + with_lazy_panel.
test/components/previews/pathogen/tabs_preview/orientations.html.erb Refactors orientation demos and adds a “Many tabs” example using Pathogen helpers.
test/components/previews/pathogen/tabs_preview/keyboard_and_accessibility.html.erb Converts headings/descriptive text to Pathogen helpers and adjusts typography tokens.
test/components/previews/pathogen/tabs_preview/integration_examples.html.erb Refreshes integration examples and trims/reshapes sections using Pathogen helpers.
test/components/previews/pathogen/tabs_preview/basic_usage.html.erb Reworks “Overview” content, adds custom default tab + single-tab edge case examples.
test/components/previews/pathogen/tabs_preview/advanced_features.html.erb Removes the old “Advanced Features” preview content (moved/reshaped elsewhere).
test/components/previews/pathogen/tabs_preview.rb Reorganizes preview groups/labels and includes Pathogen::ViewHelper for helper usage.
test/components/pathogen/tabs/lazy_panel_test.rb Adds coverage for LazyPanel rendering fallback when turbo-rails helpers are unavailable.
app/components/pathogen/tabs/lazy_panel.rb Adds render_turbo_frame helper method to support environments with/without turbo_frame_tag.
app/components/pathogen/tabs/lazy_panel.html.erb Uses render_turbo_frame for eager and lazy branches.
demo/app/javascript/lookbook_preview.js New entrypoint that starts MSW before importing the main application (Turbo).
demo/app/javascript/lookbook_mocks/tabs_lazy_load.js MSW handlers that return realistic Turbo Frame HTML with a small artificial delay.
demo/app/views/layouts/lookbook_preview.html.erb Loads a Lookbook-specific importmap entrypoint so MSW can start before Turbo.
demo/public/mockServiceWorker.js Adds the generated MSW service worker used for browser interception.
demo/config/importmap.rb Pins the new JS entrypoints and MSW ESM URLs.
demo/Gemfile Adds turbo-rails to support Turbo helpers in the demo Rails app.
demo/config/environments/development.rb Changes host authorization configuration for dev (currently disables it).
demo/Procfile.dev Adjusts dev server bind/port behavior.
demo/bin/dev Defaults PORT to 3001 for the demo dev script.
eslint.config.js Adds an ESLint config block for demo JavaScript files (browser/module context).
package.json Adds MSW as a dev dependency and configures MSW worker output directory.
pnpm-lock.yaml Locks MSW and its transitive dependencies.
app/assets/stylesheets/pathogen.tailwind.css Anchors new Tailwind arbitrary length utilities used by updated previews.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +45 to +46
# the following settings allow us to forward ports securely using vscode remote port forwarding
config.hosts.clear
Comment thread demo/Procfile.dev
@@ -1,3 +1,3 @@
web: bin/rails server -p 3001
web: bin/rails server -p $PORT -b 0.0.0.0
Comment thread package.json
"eslint-config-prettier": "^10.0.0",
"globals": "^17.7.0",
"jsdom": "^29.1.1",
"msw": "^2.14.6",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependency javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants