Skip to content

OXY-158: composable media-query support in the stylesheet DSL - #302

Merged
Kalin-Rudnicki merged 1 commit into
mainfrom
OXY-158
Aug 15, 2026
Merged

OXY-158: composable media-query support in the stylesheet DSL#302
Kalin-Rudnicki merged 1 commit into
mainfrom
OXY-158

Conversation

@Kalin-Rudnicki

Copy link
Copy Markdown
Owner

OXY-158 — Media query support in the stylesheet DSL

Ticket: https://kr-oxygen.atlassian.net/browse/OXY-158

Problem

Oxygen has a nice, composable stylesheet DSL, but media queries were a raw-string one-off: MediaCSS + hand-written @media { ... } blocks (ColumnsStyle, HolyGrail.responsiveSheet, inline strings in Motion/Tooltip) that bypass the DSL entirely. StyleSheet.compile had no @media support at all.

What this does

Makes responsive styles first-class — written with the same selector DSL as everything else.

  • MediaQuery (create/MediaQuery.scala): composable condition type — minWidth/maxWidth/minHeight/maxHeight, breakpoint helpers (smUp/mdUp/lgUp/xlUp, below*, between), prefersDark/prefersLight, portrait/landscape, reducedMotion, canHover/pointer, screen/print, &&/and, ||/or, and a raw escape hatch.
  • media(query){ ... } (create/media.scala): DSL block that tags every rule emitted inside with the query (scoped MutableAdder); nests/composes with existing selectors — nested blocks AND together.
  • StyleSheet.compile now threads Option[MediaQuery] through the leaf model and emits correct @media (...) { selector { ... } }, merging consecutive same-query rules into one block.
  • Dogfooded: OxygenStyleSheet h1 shrinks below md; new showcase page (MediaQueryPage) built entirely with the DSL (reflow + responsive visibility), wired into the example app nav.
  • Back-compat: MediaCSS stays functional with a scaladoc pointer to the new DSL (repo builds with -Werror -deprecation, so its live raw call sites can't carry @deprecated). No existing call site changed.

Emitted CSS (from tests)

.mq-test-box { display: flex; flex-direction: column; }
@media (min-width: 768px) { .mq-test-box { flex-direction: row; } }
@media (min-width: 768px) and (orientation: landscape) { .mq-test-box { gap: 8px; } }

Verification

  • oxygen-ui-web/compile ✓, example-ui-web/compile ✓, oxygen-ui-web/test ✓ (48 passed, 3 new)

🤖 Generated with Claude Code

https://claude.ai/code/session_011YxWKdsz97QT9BD7AdpSq6

Media queries were a raw-string one-off (MediaCSS + hand-written @media blocks)
that bypassed the stylesheet DSL. This makes responsive styles first-class:

- MediaQuery: composable condition type (min/max width/height, breakpoint
  helpers, prefers-dark/light, orientation, reduced-motion, hover/pointer,
  screen/print, &&/||, raw escape hatch).
- media(query){ ... }: DSL block tagging every rule with the query; nests and
  composes with existing selectors.
- StyleSheet.compile threads Option[MediaQuery] through the leaf model and emits
  @media (...) { selector { ... } }, merging consecutive same-query rules.
- Dogfooded in OxygenStyleSheet + new MediaQueryPage showcase; MediaCSS kept as
  a functional shim with a scaladoc pointer to the new DSL.

Also in this change:
- scripts/run-example-web.sh: one-command local run of the example web server
  (docker db + webComp + server as two sbt invocations, so run is not consumed
  by webComp's input-task arg parser).
- build.sbt: exclude unused sbt-git keys from sbt 2's lintUnusedKeysOnLoad
  (was ~84 warnings on every load).
- docs + scripts/build.sh: fix stale example config path
  (src/main/resources/local.json -> config/local.yaml).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Kalin-Rudnicki
Kalin-Rudnicki merged commit f592a81 into main Aug 15, 2026
7 checks passed
@Kalin-Rudnicki
Kalin-Rudnicki deleted the OXY-158 branch August 15, 2026 03:51
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