Skip to content

feat(View): support inset="center" for both-axis centering#652

Open
blvdmitry wants to merge 1 commit into
canaryfrom
feat/inset-center-both-axes
Open

feat(View): support inset="center" for both-axis centering#652
blvdmitry wants to merge 1 commit into
canaryfrom
feat/inset-center-both-axes

Conversation

@blvdmitry

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #650, which added the "center" keyword to insetInline / insetBlock for single-axis centering of absolutely positioned elements.

This extends "center" to the all-sides inset prop, so the common case — centering an element on both axes — is a single value:

<View position="absolute" inset="center" />           {/* both axes */}
<View position="absolute" insetInline="center" />     {/* horizontal (from #650) */}
<View position="absolute" insetBlock="center" />      {/* vertical (from #650) */}

How it works

The all-sides inset resolver is now sugar for insetting both axes: it emits the same per-axis inline/block classes and CSS variables that insetInline/insetBlock use, which lets inset="center" reuse the existing centering classes for both directions. The now-dead all-sides rule is removed from inset.css.

Centering itself relies on the mechanism introduced in #650 — physical left/top: 50% plus a translate composed from @property-typed --rs-inset-translate-* variables — so it composes cleanly with responsive values (e.g. inset={{ s: "center", l: 4 }} centers on small and switches to a numeric inset from l up).

Testing

  • Added resolver snapshots for inset("center") and the responsive { s: "center", m: 4 } handoff.
  • Added an inset: center story to the View inset example set (visual coverage via Chromatic).
  • tsc, oxlint, stylelint, and the full test:unit project (183 tests) pass. Verified the module CSS compiles cleanly through the responsive PostCSS plugin.

🤖 Generated with Claude Code

PR #650 added the "center" keyword to insetInline/insetBlock for single-axis
centering. This extends it to the all-sides `inset` prop so `inset="center"`
centers an absolutely positioned element on both axes without manual CSS
transforms.

The all-sides `inset` resolver is now sugar for insetting both axes: it emits
the same per-axis inline/block classes and variables, letting "center" reuse
the existing centering classes for both directions. The now-dead all-sides
`inset` rule is removed from inset.css.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Library / JS 49.15 KB (-0.08% 🔽) 983 ms (-0.08% 🔽) 403 ms (+17.89% 🔺) 1.4 s
Library / CSS 23.07 KB (-0.01% 🔽) 462 ms (-0.01% 🔽) 0 ms (+100% 🔺) 462 ms
Theming / JS 7.81 KB (0%) 157 ms (0%) 133 ms (+326.43% 🔺) 289 ms
Theming with a default theme definition / JS 8.65 KB (0%) 174 ms (0%) 263 ms (+215.28% 🔺) 436 ms

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