Skip to content

feat(layer): per-edge viewport inset custom properties for a persistent bar floating over the viewport - #6686

Closed
vjeux wants to merge 4 commits into
meta:mainfrom
vjeux:layer-viewport-inset
Closed

vjeux wants to merge 4 commits into
meta:mainfrom
vjeux:layer-viewport-inset

Conversation

@vjeux

@vjeux vjeux commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

User need

An app that keeps a persistent bar floating over one viewport edge — a phone navigation bar fixed over the bottom, a docked toolbar — has no way to tell Astryx layers the bar is there. The bar contributes no layout height, so a Popover or DropdownMenu the browser has correctly fitted to the viewport (spacing-4 + env(safe-area-inset-*) gutter) still ends underneath it, and the rows nearest the bottom are covered. The gutter is a fixed constant in three components; the only out is a theme override of each component's max-size expression, which drops the safe-area term and repeats the bar on every surface.

Problem and solution fit

  • Primary: four app-level custom properties — --astryx-layer-inset-block-end, --astryx-layer-inset-block-start, --astryx-layer-inset-inline-start, --astryx-layer-inset-inline-end — each added to the existing gutter for its edge and reading 0px unless set. The app declares the bar once, on :root.
  • Supporting: one shared Layer/layerViewportInset.stylex.ts holds the gutter expressions (StyleX inlines cross-file values only from a .stylex.ts); Popover, DropdownMenu and DropdownMenuSubMenu read it in place of their three identical copies, so "every fitted layer" is true rather than Popover-only. Tests, docs, a changeset, contract text.
  • Removed as a tagalong: a layerInsetVars barrel export of the property names — the properties are the whole contract.

Current specification

component:Popover (Popover.spec.md, authority: current) FR3/ORD3 settle viewport and safe-area fitting but no app-declared inset; architecture:layer-runtime (current) owns anchor geometry and places viewport sizing with Popover. This PR adds FR8 and DEC-4 to the Popover record and the owning-code line to the architecture record, both marked pending owner review — the one unresolved owner decision.

Public delta and caller burden

  • New: the four custom properties above. Semantics per edge: gutter = max(--spacing-4, env(safe-area-inset-*)) + var(--astryx-layer-inset-*, 0px). Unset → released geometry, byte for byte.
  • No prop, type, or default changes on Popover, usePopover, useLayer or DropdownMenu.
  • The properties are app declarations, not theme-target vars: nothing on a component target class carries them, so they are documented in the Layer usage text and the Popover contract rather than theming.vars.
/* once */
:root { --astryx-layer-inset-block-end: var(--app-nav-bar-height, 0px); }

Design and alternatives

  • Custom property rather than a per-surface prop: the runtime authors no gutter of its own, and a bar is a fact about the app shell; a prop would be repeated on every layer and let two surfaces disagree about where the viewport ends.
  • Logical edge names follow the layers' own 100dvb / 100vi sizing; the safe-area env() terms stay physical as before.

Evidence

  • layerViewportInset.test.ts: one property per edge; each gutter adds its inset to the safe-area term and reads 0px unset; the paint-time inline gutter reserves the larger inline inset; env()-less fallbacks keep the insets.
  • Popover.test.tsx: the block-size cap subtracts both block insets; a side placement's block margin and the aligned inline gutter carry their insets; existing min-width contract strings updated.
  • DropdownMenu / DropdownMenuSubMenu tests: max-height / min-width contract strings updated.
  • Design review approved on this PR.

Scope

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Testing

rebased onto main (217f41d74e)
npx vitest run packages/core/src/{Popover,DropdownMenu,Layer} packages/core/src/theme/derivedVarRegistry.test.ts \
  packages/cli/foundation/discovery/theming-targets.test.mjs packages/core/src/docPropLiterals.test.ts
  Test Files 16 passed · Tests 587 passed (previous head; unchanged files)
pnpm test -- --maxWorkers=4 — 937 files / 20058 tests passed; 6 files failed: story-tree ×2 and
  search-return-type fail identically on main, Table.perf / build-theme --watch / build-theme.adaptations
  are timing budgets on a shared box and pass re-run alone
pnpm -F @astryxdesign/core build — 636 dist files checked, exit 0
pnpm -F @astryxdesign/core typecheck:docs — 0 errors · pnpm lint — 0 errors (82 pre-existing warnings)
node scripts/check-knowledge.mjs — Knowledge templates and records are aligned.

@vercel

vercel Bot commented Sep 28, 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 1, 2026 2:55am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 28, 2026
@astracat-bot

astracat-bot Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Oct 1, 2026, 4:58 PM UTC

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Sep 28, 2026
github-actions Bot added a commit that referenced this pull request Sep 28, 2026
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

Popover (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 760 -
Complexity N/A Very High (82) -

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

@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.

Thanks for closing this gap — the mechanism is clean: one shared set of gutter expressions, the existing spacing-4 + safe-area part preserved, and a 0px default so nothing moves for apps that do not opt in.

Two things stand in the way of approval:

  1. A maintainer spec decision is needed first. This adds four new public custom properties (--astryx-layer-inset-block-start, --astryx-layer-inset-block-end, --astryx-layer-inset-inline-start, --astryx-layer-inset-inline-end), a new layerInsetVars export, and new gutter semantics across Popover, DropdownMenu and its submenus. No current governing spec names these properties, the export, or the additive semantics — the existing Popover contract covers viewport and safe-area capping only. Approval needs a maintainer to provide or identify the governing spec for this addition, settling the property names, the additive-over-safe-area semantics, and the Popover + DropdownMenu scope. This is not a request to remove or split the change.

  2. The new Layer theming doc breaks the docs build. The theming object added to Layer.doc.mjs declares only vars, but the doc schema requires a targets field, so typecheck:docs fails (TS2741: Property 'targets' is missing) and the Storybook and docsite builds fail with it. Giving the theming object a valid targets declaration, or moving the vars to a doc whose theming satisfies the schema, should fix it — please re-run the docs typecheck afterwards.

[Automated review]

@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.

Thanks for closing this gap — the mechanism is clean: one shared set of gutter expressions, the existing spacing-4 + safe-area part preserved, and a 0px default so nothing moves for apps that do not opt in. The docs build failure from the earlier revision is also fixed, and CI is green apart from the pending spec-owner approval.

One thing still stands in the way of approval:

A maintainer spec decision is needed first. This adds four new public custom properties (--astryx-layer-inset-block-start, --astryx-layer-inset-block-end, --astryx-layer-inset-inline-start, --astryx-layer-inset-inline-end), a new layerInsetVars export, and new gutter semantics across Popover, DropdownMenu and its submenus. No current governing spec names these properties, the export, or the additive semantics — the existing Popover contract covers viewport and safe-area capping only, and the DEC-4 / FR8 record proposed in this PR is itself marked pending owner review. Approval needs a maintainer to provide or identify the governing spec for this addition (or approve the proposed DEC-4 / FR8 as that record), settling the property names, the additive-over-safe-area semantics, the export, and the Popover + DropdownMenu scope. This is not a request to remove or split the change.

[Automated review]

@kentonquatman kentonquatman 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.

Looks good!
Tested with this code: Playground link

Christopher Chedeau added 4 commits September 30, 2026 19:35
… bar floating over the viewport is declared once
…list; DEC-4 pending owner review records the per-edge viewport inset
…ocumented in prose rather than as theme-target vars
…es are the contract; DEC-4 decider line names only the PR
@vjeux vjeux changed the title feat(layer): per-edge viewport inset custom properties — a persistent bar floating over the viewport is declared once feat(layer): per-edge viewport inset custom properties for a persistent bar floating over the viewport Oct 1, 2026
@vjeux
vjeux force-pushed the layer-viewport-inset branch from aea4ffc to c40c6e6 Compare October 1, 2026 02:47
@github-actions
github-actions Bot requested a review from kentonquatman October 1, 2026 02:48

@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.

Thanks for closing this gap — the mechanism is clean: one shared set of gutter expressions, the existing spacing-4 + safe-area part preserved, and a 0px default so nothing moves for apps that do not opt in. The docs and export issues from earlier revisions are also fixed, and CI is green apart from the pending spec-owner approval.

One thing still stands in the way of approval:

A maintainer spec decision is needed first. This adds four new public custom properties (--astryx-layer-inset-block-start, --astryx-layer-inset-block-end, --astryx-layer-inset-inline-start, --astryx-layer-inset-inline-end) and new additive gutter semantics across Popover, DropdownMenu and its submenus. No current governing spec names these properties or the additive semantics — the existing Popover contract covers viewport and safe-area capping only, and the DEC-4 / FR8 record proposed in this PR is itself marked pending owner review. Approval needs a maintainer to provide or identify the governing spec for this addition (or approve the proposed DEC-4 / FR8 as that record), settling the property names, the additive-over-safe-area semantics, the Popover + DropdownMenu scope, and documenting the properties as app-level :root declarations rather than theme-target vars. This is not a request to remove or split the change.

[Automated review]

cixzhang added a commit that referenced this pull request Oct 3, 2026
Gutter, size cap, fallback order, app-declared inset, and the Layer stories
move to the layer runtime; Popover keeps its props, styling, scrolling and
the explicit-width preference. Supersedes the component-level approach in
#6688 and places #6686's inset at the layer.
cixzhang added a commit that referenced this pull request Oct 4, 2026
* spec(AST-059): the layer runtime owns the viewport inset

Gutter, size cap, fallback order, app-declared inset, and the Layer stories
move to the layer runtime; Popover keeps its props, styling, scrolling and
the explicit-width preference. Supersedes the component-level approach in
#6688 and places #6686's inset at the layer.

* spec(AST-059): state the system, not the project

Rubric pass (docs/contributing/spec-writing.md): the Intent names the
behaviors rather than the changes that reached for them; no pull request
remains as standing content; the open-pull-request and follow-up sections
are gone (their durable facts are in the FRs; the rest is for the pull
request description); rejected alternatives are one line each.

* spec(AST-059): the app declares its floating bar on LayerProvider

FR6 and DEC-4 rewrite on the owner's ruling: LayerProvider carries the
inset, typed beside toast, with zero defaults; anchored layers and the
toast viewport read one declaration (DEC-5). toast.inset stays as the
per-edge toast override. Custom properties are the mechanism, not the API.

* spec(AST-059): the first frame is the settled frame; the layer box never exceeds the viewport

FR8: a layer MUST NOT paint at a geometry it is about to correct; every
geometry input resolves in the same frame as the render that produced it
and the runtime measures nothing after paint. FR2/FR3: the layer box never
exceeds the cap; content that cannot fit overflows inside. Verification
rows name both viewports and the first-frame comparison.

* spec(AST-059): current — approved by the owner on 2026-10-03

/approve-spec clears the merge gate; the record's own authority is written
here: authority current, approved_by cixzhang, phase accepted, DEC-2 and
DEC-5 as the owner's decisions.

* spec(AST-059): the gutter bounds position on the placement axis; a span last resort

* spec(AST-059): the placement-axis positional gutter is one value for both edges

* spec(AST-059): nested provider narrows the inset; VG1 slide-then-return
@vjeux

vjeux commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #6919 (spec:AST-059): the per-edge viewport inset shipped as the inset prop on LayerProvider (blockStart / blockEnd / inlineStart / inlineEnd), read by every anchored layer and the toast viewport. The custom properties this PR proposed are mechanism there, not API. Thanks for landing it in the runtime.

@vjeux vjeux closed this Oct 6, 2026
@vjeux
vjeux deleted the layer-viewport-inset branch October 6, 2026 15:56

This branch was successfully deployed

1 active deployment
Preview — c40c6e67 Deployed Oct 1, 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. needs:design-review Affects visuals — Design should review needs:spec-owner-review Current knowledge records await owner approval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants