Skip to content

feat(layout): LayoutPanel hideBelow responsive visibility prop (#3339) - #4593

Draft
jiunshinn wants to merge 1 commit into
meta:mainfrom
jiunshinn:feat/3339-layoutpanel-hidebelow
Draft

jiunshinn wants to merge 1 commit into
meta:mainfrom
jiunshinn:feat/3339-layoutpanel-hidebelow

Conversation

@jiunshinn

Copy link
Copy Markdown
Contributor

Fixes #3339
Refs #4476

Summary

Adds hideBelow?: 'sm' | 'md' | 'lg' | 'xl' to LayoutPanel, implementing the spec from #3339: the panel hides itself below the given viewport-width breakpoint with a compile-time CSS @media (max-width: ...) { display: none } toggle in StyleX. No useMediaQuery, no runtime measurement, no hydration flash: the panel stays mounted and server-rendered HTML matches the client.

// Panel hides itself below the lg breakpoint. No useMediaQuery in page code.
<LayoutPanel width={340} padding={0} hideBelow="lg">
  {threadPanel}
</LayoutPanel>

How breakpoints are consumed in StyleX

StyleX cannot read var() inside at-rule conditions, so the media queries must be compile-time values. I followed the existing repo precedent (FormLayout's HORIZONTAL_LABELS_COLLAPSE = '@media (max-width: 480px)' literal used as a condition key) rather than introducing a new stylex.defineConsts() token file, since there is no defineConsts precedent in the repo yet and Phase 9 of the issue leaves the breakpoint token set pending sign-off.

Values align with AppShell's BREAKPOINT_VALUES (sm: 640, md: 768, lg: 1024) plus an xl: 1280 step, and match the exact max-width queries the templates hand-rolled ((max-width: 768px) = md, (max-width: 1024px) = lg), so template migration is a drop-in replacement.

Changes

  • packages/core/src/Layout/LayoutPanel.tsx: hideBelow prop, four hideBelowStyles media-query display toggles, wired into stylex.props before xstyle so consumers can still override.
  • packages/core/src/Layout/LayoutPanel.doc.mjs: prop documented in docs, docsZh, and docsDense (inlined literal union per the docPropLiterals guard).
  • packages/core/src/Layout/__tests__/hideBelow.test.tsx: per-breakpoint assertions that the injected CSS rule for the panel's class is a display: none toggle under exactly that breakpoint's max-width query; default (no prop) emits no hide class; distinct classes per breakpoint; composition with width/hasDivider; SSR test that renderToString markup contains the mounted panel and its class list matches the client render.
  • apps/storybook/stories/Layout.stories.tsx: Responsive Hidden Panels story mirroring the messaging-shell case (start panel hideBelow="md", end panel hideBelow="lg").
  • .changeset/layoutpanel-hidebelow.md: [feat] patch for @astryxdesign/core.

Explicitly out of scope (follow-up after merge)

Template adoption is deliberately not included: the four hand-rolled useMediaQuery panel-hide sites in incident-console (#3316), messaging-shell (#3323), and deployment-detail (#3330) will be migrated to hideBelow in a follow-up once this API lands, per the issue's migration use case.

Open questions (Phase 8/9 arbitration, flagged for sign-off)

  1. Naming symmetry. Implemented as hideBelow per the issue title (Chakra-aligned). Should hideFrom / showBelow land alongside it for symmetry, or wait for demand?
  2. Breakpoint token set. sm/md/lg reuse AppShell's values; xl: 1280 is new (Tailwind-aligned). Is this the blessed system-wide set, and should it graduate to a shared breakpoints.stylex.ts via stylex.defineConsts() that AppShell/FormLayout also consume? Happy to do that here or as a follow-up.
  3. Boundary semantics. Hide applies at widths <= the breakpoint value (max-width: Npx), matching AppShell's collapse behavior and the templates' existing queries. If "below" should mean strictly < N, the queries can switch to max-width: (N - 0.02)px.

Verification

  • pnpm exec vitest run packages/core/src/Layout plus the doc guards (docPropLiterals, docPropReferences): 111 tests pass, including the 9 new hideBelow tests.
  • Full @astryxdesign/core ui suite: 234 files, 5721 tests pass.
  • tsc --noEmit clean for packages/core (src + docs project) and apps/storybook.
  • check:sync, check:changesets, check:package-boundaries, eslint (pre-commit hooks): clean.
  • pnpm -F @astryxdesign/core build succeeds; dist/astryx.css contains all four generated rules, e.g. @media (max-width: 1024px){....{display:none}}.
  • astryx component LayoutPanel --dense now lists hideBelow with breakpoint values.

@vercel

vercel Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 3, 2026 11:33pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 31, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Jul 31, 2026
@github-actions

github-actions Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

15 of 420 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Chat Full AI Chat probe light 155,733
Chat Full AI Chat probe dark 155,005
Chat Default neutral dark 33,205
Chat Default neutral light 32,876
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,229
Chat With Attachments probe dark 11,065
SideNav Resizable in AppShell probe dark 3,208
Markdown Default probe dark 897
Markdown Default probe light 897
Markdown Default neutral dark 882
Markdown Default neutral light 858

Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Jul 31, 2026
@jiunshinn
jiunshinn marked this pull request as ready for review July 31, 2026 11:54

@astracat-bot astracat-bot Bot 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.

This change adds a useful CSS-only hideBelow option to LayoutPanel, with documentation, a story, and tests, and existing callers are unchanged when the prop is omitted.

Approval is waiting on a maintainer decision: please provide or identify the governing spec for this addition. That spec needs to settle the hideBelow name (and whether symmetric options are needed), the breakpoint token set and its owner — including the new xl value and whether the values become a shared system token — the inclusive boundary meaning of "below", and the mounted-subtree behavior (including how an adjacent resize handle is handled when a panel hides).

No concrete code defect was found in this review; the hold is only about establishing that public contract before it is released.

[Automated review]

@jiunshinn
jiunshinn force-pushed the feat/3339-layoutpanel-hidebelow branch from e1a040b to 32b6dba Compare October 3, 2026 23:27
@jiunshinn

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (73a6506d60). The Layout suites pass all 116 tests; strict lint/repository checks and the full package build also pass.

@cixzhang Please review the updated head and settle the proposed public contract: hideBelow?: 'sm' | 'md' | 'lg' | 'xl', the breakpoint values and ownership, inclusive max-width semantics, and mounted-subtree/adjacent-resize-handle behavior. The previous review identified no concrete code defect, so this update preserves the proposed implementation rather than inventing an API decision. Please provide or identify the governing current record before release.

The formal review-request API rejects my account's permissions in this repository, so this comment is the re-review/maintainer-decision request; existing reviewer assignments are retained.

@astracat-bot astracat-bot Bot 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.

Approval is waiting on a maintainer decision: a maintainer needs to provide or identify the governing spec for responsive hiding on LayoutPanel, settling whether LayoutPanel should own it at all and, if so, how a hidden but still-mounted panel interacts with Layout's spacing and an adjacent ResizeHandle. If the addition is accepted, these also need to change before approval:

  • Use the five shared width-point names, including 2xl, resolved from the active theme as AppShell does, instead of a local 640/768/1024/1280 table.
  • Treat "below" as exclusive (width < N) so the panel stays visible at exactly the named width, and update the docs, story text and tests to match.
  • Keep LayoutContent's padding correct when a panel is hidden; today it keeps the inner inset at the edge the panel vacated, which shows when Layout has padding={0}.
  • Do not leave an adjacent ResizeHandle focusable and operable for a hidden panel, or stop documenting resizable with hideBelow as a supported combination.

[Automated review]

This branch was successfully deployed

1 active deployment
Preview — 32b6dba4 Deployed Oct 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LayoutPanel: responsive hideBelow prop (replace hand-rolled useMediaQuery panel hiding in templates)

1 participant