Skip to content

feat(a2ui-playground): container queries + mobile share sheet#2731

Merged
Huxpro merged 1 commit into
lynx-family:mainfrom
Huxpro:Huxpro/a2ui-preview-adaptive-layout
May 27, 2026
Merged

feat(a2ui-playground): container queries + mobile share sheet#2731
Huxpro merged 1 commit into
lynx-family:mainfrom
Huxpro:Huxpro/a2ui-preview-adaptive-layout

Conversation

@Huxpro
Copy link
Copy Markdown
Collaborator

@Huxpro Huxpro commented May 27, 2026

Summary

Refactors the A2UI playground preview panel so its layout reacts to the panel's own width instead of the viewport. Dragging the JSON/preview resize handle now correctly collapses the split when the panel itself can no longer fit it — previously only viewport size triggered the collapse, so resizing did nothing.

Also adds a mobile bottom sheet for the Components stack and Web/Native Preview cards on narrow panels, so the phone mockup can dominate the available space.

Container queries

  • .examplesPreviewWrap is the new container host (container-name: previewPanel). Split → stacked threshold drops from @media (max-width: 1280px) to @container previewPanel (max-width: 660px), matching the grid's natural floor (360 phone min + 280 controls min).
  • .previewQrSection is its own container (container-name: previewQr) so QR card layouts respond to their own column width (description hides in narrow examples columns).

QR section polish

  • Top-aligns title with the QR thumbnail (was align-items: center, which left short text floating mid-QR).
  • Adds a QR unavailable / URL too long to encode placeholder (128×128, matching the QR slot) for live drafts whose URLs can't be encoded. Keeps create and example panels structurally aligned (both cards now have a right-side slot).

Mobile share sheet

  • Adds vaul@^1.1.2.
  • On panels narrower than 660px, the Components stack and URL/QR cards collapse out of the panel and into a bottom sheet, opened by a phone-icon button in the panel header.
  • A single renderExtras() closure feeds both the inline (via display: contents on .previewPanelExtras) and sheet renderings, so Copy state stays in sync between them.

Test plan

  • Demos page at wide viewport: drag the JSON/preview resize handle to shrink the preview panel past ~660px → it should collapse from split (phone | controls) to a vertical stack. Drag wider → split returns.
  • Mobile-width viewport / narrow preview panel: phone-icon button appears in the panel header; tapping slides up a sheet with Components + Web/Native Preview cards. Swipe down / tap overlay / press Esc dismisses.
  • Create (AIChat) page: each preview card shows a dashed QR unavailable placeholder in place of the QR; visual rhythm aligns with the example page's QR cards.
  • Example page wide: QR card title/URL+Copy top-align with the 128px QR (no longer centered).
  • Light + dark themes: sheet, placeholder, and panel split all render correctly.

Summary by CodeRabbit

  • New Features

    • Added mobile preview share sheet with a new "Open this preview on a phone" button in the preview panel header for streamlined mobile device testing and preview sharing workflows.
  • Improvements

    • Enhanced responsive design architecture with improved mobile and tablet layout handling, featuring refined content spacing, intelligent visibility controls, and better adaptive behavior across varying device widths.

Review Change Stack

Refactors the preview panel so layout reacts to the panel's own width
instead of the viewport, and adds a bottom sheet for surfacing the
Components + URL/QR cards on narrow panels.

Container queries:
- .examplesPreviewWrap hosts a 'previewPanel' container; split → stacked
  threshold drops from @media (max-width: 1280px) to @container (max-width:
  660px), matching the grid floor (360 phone min + 280 controls min).
  Dragging the JSON/preview resize handle now correctly collapses the
  split when the panel itself can no longer fit it.
- .previewQrSection hosts a 'previewQr' container so QR card layouts
  respond to their own column width (description hides in narrow columns).

QR section polish:
- Top-aligns title with the QR thumbnail (was center, which left short
  text floating mid-QR).
- Adds a 'QR unavailable' placeholder (128×128, matching the QR slot)
  for live drafts whose URLs are too long to encode — keeps the create
  and example panels structurally aligned (both cards have a right slot).

Mobile share sheet:
- Adds vaul@^1.1.2.
- On panels narrower than 660px the Components stack and Web/Native
  Preview cards collapse into a bottom sheet, opened by a phone-icon
  button in the panel header.
- A single renderExtras() closure feeds both the inline (display:
  contents) and sheet renderings, so Copy state stays in sync.
Copilot AI review requested due to automatic review settings May 27, 2026 17:02
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 27, 2026

⚠️ No Changeset found

Latest commit: b3e4c4a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The PR adds a mobile-friendly "Preview info" share sheet to the playground's preview panel using the vaul drawer library, refactors preview extras rendering into a reusable helper, and converts the entire responsive layout from viewport-based media queries to container query-driven behavior for superior responsive control.

Changes

Mobile Preview Share Sheet with Container Queries

Layer / File(s) Summary
Vaul drawer library dependency
packages/genui/a2ui-playground/package.json
Adds vaul (^1.1.2) as a dependency to provide drawer and bottom-sheet UI primitives.
PreviewPanel mobile share sheet and extras refactor
packages/genui/a2ui-playground/src/components/PreviewPanel.tsx
Imports Drawer from vaul and adds shareOpen state. Extracts previously inline "extras" rendering (streamed components, QR placeholder, or QR/link cards) into a renderExtras() function that serves both the inline panel display and the drawer content. A conditional header button ("Open this preview on a phone") toggles the share sheet when hasExtras is true. The Drawer wraps the extras with overlay, content, title, and description.
Container query responsive layout and DOM restructuring
packages/genui/a2ui-playground/src/pages/DemosPage.tsx, packages/genui/a2ui-playground/src/pages/DemosPage.css, packages/genui/a2ui-playground/src/styles.css
Wraps the preview panel in a new examplesPreviewWrap container div that receives previewPanelStyle (moved from the PreviewPanel component). Converts responsive layout from viewport media queries to container queries: .previewPanel becomes a container host that hides .previewPanelExtras and shows .previewInfoBtn under @container previewPanel (max-width: 660px); .previewQrSection becomes its own container host with overrides for QR spacing and description visibility. DemosPage.css adds .examplesPreviewWrap container setup, split-to-stack breakpoint, and updates small-screen styling. styles.css adds container query rules, mobile share sheet UI styles (overlay, bottom sheet, handle, title, scrollable body), and a .previewQrUnavailable placeholder for layout alignment when QR encoding fails.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • lynx-family/lynx-stack#2704: Overlapping refactor of previewQrSection styling and QR layout behavior in the preview panel.
  • lynx-family/lynx-stack#2690: Shared modifications to preview panel and QR section responsive styling in packages/genui/a2ui-playground/src/styles.css.

Suggested reviewers

  • HuJean
  • Sherry-hue

Poem

A drawer slides in from the mobile phone,
Extras rendered once, in two places shown—
Container queries replace viewport's old way,
Responsive and graceful, come what may! 📱✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding container queries for responsive layout and a mobile share sheet component.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Huxpro Huxpro merged commit 0aa3465 into lynx-family:main May 27, 2026
12 of 14 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@Huxpro Huxpro review requested due to automatic review settings May 27, 2026 17:24
@coderabbitai coderabbitai Bot mentioned this pull request May 28, 2026
3 tasks
HuJean pushed a commit that referenced this pull request May 29, 2026
## Summary

Reworks the A2UI playground for phones (≤720px) so the **preview** isn't
permanently pushed below the fold. Each page now has two full-screen
panes — **Chat/Code** and **Preview** — toggled by a bottom tab bar.
Everything else around the input/code area gets tightened. Desktop
layout is untouched.

### Tab bar

- New `<MobileTabBar />` renders **Edit** + **Preview** tabs with
`role=tablist`, accent-underline active state, icon + label. Always
rendered; CSS shows it only at `≤720px` via `.mobileTabBar` rules in
`styles.css`.
- `AIChatPage` and `DemosPage` each hold an `activeMobileTab` state and
apply it as `data-active-tab` on their page root. CSS hides the
non-active pane and the `PanelResizeHandle`. Tab switching is pure CSS —
state (chat draft, scroll position, code edits, simulation speed) is
preserved across tabs.

### Chrome compaction (`≤720px`)

- **`Lynx GenUI Playground` wordmark drops** on phones (was truncating
to `Lynx GenUI Playg…`). Logo alone carries the brand.
- **Send button** no longer forced to `width: 100%`; stays a compact
38px pill next to the model selector.
- **Conversation panel** collapses into a 52px horizontal strip: `+ New
Chat` as a 36px icon button, conversations as single-line chips with the
desktop active-bar indicator. `Edit/Del` revealed only on the **active**
chip (matches desktop hover behavior — was force-shown on every card
before).
- **Scenarios sidebar** collapses the same way: back-icon on the left,
scenarios as one-line chips scrolling horizontally on the right.
`SCENARIOS` heading dropped (redundant when chips are the only content).
- **Create page header** (`Create` / `Online Agent` / `Describe the
UI…`) dropped on mobile — the input area itself communicates the same
thing and this band was eating ~120px.
- **`A2UI Messages` title** gets `white-space: nowrap` (was wrapping to
two lines), JSON badge hidden, toolbar buttons tighter, code panel
`flex: 1` so the editor fills the freed space.

## Test plan

- [ ] Resize browser to ≤720px (or use mobile device toolbar). Bottom
tab bar should appear on Create and Examples → demo detail pages.
- [ ] **Tab switching** preserves state — type in the chat input, switch
to Preview, switch back: text still there. Same for the JSON editor on
Examples.
- [ ] **Create page Edit tab**: conversation strip = ~52px tall, `+`
icon button + horizontal chip list. `Edit/Del` only visible on the
active chip.
- [ ] **Examples page Edit tab**: back-arrow icon + horizontal scenario
chips. JSON editor fills the rest of the viewport.
- [ ] **Preview tab on both pages**: phone preview takes full viewport
(minus top nav + bottom tab bar). `Open on phone` sheet trigger from
#2731 still works.
- [ ] Resize back ≥720px → desktop side-by-side layout returns
unchanged; bottom tab bar disappears.
- [ ] Light + dark themes both render cleanly.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Mobile tab navigation for narrow screens: tappable Edit/Preview tabs
with customizable edit label; integrated into chat and demos pages to
preserve active pane.

* **Style**
* Wide mobile responsive overhaul (max-width: 720px): single-pane views,
collapsed conversation strip, icon-only controls, tightened toolbars,
hidden header text for logo-only layout.
* Adjusted preview fullscreen behavior for specific narrow-width range.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/lynx-family/lynx-stack/pull/2753?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

1 participant