Skip to content

feat(theme): export the compact definition (AST-012 FR9) - #8301

Merged
cixzhang merged 1 commit into
mainfrom
feat/theme-compact-definition
Oct 24, 2026
Merged

cixzhang merged 1 commit into
mainfrom
feat/theme-compact-definition

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

User need

Components that pick a presentation by screen size each keep their own size numbers. Today Selector, MultiSelector, ContextMenu and DropdownMenu use (max-width: 768px) and (pointer: coarse), and new touch work proposes other numbers. As a result, the same phone can get a bottom sheet from one component and a popover from another, and a landscape phone (wide but short) gets a popover where it has no room for one. spec:AST-012 FR9 says compact has one definition that the theme exports and every resolver uses. Without the export, each resolver still has to restate the numbers.

Problem and solution fit

This PR adds the one exported definition and nothing else. Moving each resolver onto it is its own change, with its own release note.

Current specification

  • spec:AST-012 FR9 (current): a screen is compact while its viewport width is below the effective md point or its height is below 500, with the same numbers on every platform. The theme exports this one definition, and a resolver that also needs a coarse pointer ANDs that with compact.
  • spec:AST-012 DEC-6 (current).
  • architecture:public-component-api INV17 (current): a component that chooses a presentation by screen size uses the theme's compact definition and keeps no compact numbers of its own.

Public delta and caller burden

New exports from @astryxdesign/core/theme:

import {compactDefinition, DEFAULT_COMPACT_DEFINITION} from '@astryxdesign/core/theme';

DEFAULT_COMPACT_DEFINITION.query;
// '(width < 768px), (height < 500px)'
DEFAULT_COMPACT_DEFINITION.coarsePointerQuery;
// '(width < 768px) and (pointer: coarse), (height < 500px) and (pointer: coarse)'

// A theme that moves md moves compact with it:
compactDefinition(theme.__adaptations.widthBreakpoints).widthBelow; // its md
  • CompactDefinition holds widthBelow (the effective md), heightBelow (500), query and coarsePointerQuery, and is frozen.
  • No behavior, default or CSS changes. Callers have nothing to decide.

Design and alternatives

  • The definition lives beside the width points in themeAdaptations.ts, so its width edge is the theme's own md and never a second copy.
  • The query strings use the same range syntax the adaptation compiler already writes (width < Npx).
  • Rejected by DEC-6: mapping compact to platform size classes.

Evidence

  • Unit tests:
    • the default definition (768 and 500, both queries);
    • a theme that moves md to 800 gets widthBelow 800 with the height edge unchanged;
    • the shared definition is frozen.
  • All 24 theme test files pass, 1,510 tests.

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

  • pnpm exec vitest run --project ui packages/core/src/theme: 24 files, 1,510 tests pass.
  • Core typecheck: no errors in the changed files.
  • Strict ESLint, Prettier and pnpm check:changesets pass.

A screen is compact while its viewport is narrower than the theme's
effective md point or shorter than 500 (spec:AST-012 FR9). The theme now
exports that one definition: compactDefinition(widthBreakpoints?) and
DEFAULT_COMPACT_DEFINITION carry both edges and the media queries with and
without a coarse pointer, so presentation resolvers read one shared
definition instead of keeping size numbers of their own. No consumer moves
in this change; behavior is unchanged.
@vercel

vercel Bot commented Oct 24, 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 24, 2026 9:19pm UTC

Request Review

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

astracat-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 24, 2026, 9:37 PM UTC

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

Previews ready: Storybook and Sandbox were built with this PR's docsite. CI evidence will be added when available.

View Storybook for this PR · View Sandbox for this PR

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

No blocking issues found: compactDefinition and DEFAULT_COMPACT_DEFINITION match spec:AST-012 FR9, with exclusive edges at the theme's md width and at 500 tall, and the tests pin both the default and an overridden md. No changes are needed here; moving the adaptive resolvers onto the definition stays with the follow-up changes the description names.

[Automated review]

@cixzhang
cixzhang merged commit 2763bcc into main Oct 24, 2026
69 checks passed
@cixzhang
cixzhang deleted the feat/theme-compact-definition branch October 24, 2026 21:54

This branch was successfully deployed

1 active deployment
Preview — af8d072d Deployed Oct 24, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant