migrate-container-queries

Migrates viewport media queries to container queries in Sentry's frontend codebase.

44.7k|4.8k|Updated Aug 30, 2010
One-click install
npx skills add https://github.com/getsentry/sentry --skill migrate-container-queries
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-container-queries
Source: https://github.com/getsentry/sentry/tree/main/.agents/skills/migrate-container-queries
Command: npx skills add https://github.com/getsentry/sentry --skill migrate-container-queries

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Responsive layouts built on viewport-based @media queries, useMedia hooks, and screen:-prefixed props break when components need to respond to their own available space, and naive token swaps silently produce wrong breakpoints because the breakpoint and container scales share names but not pixel values.

Core Features & Use Cases

  • Four-rung migration ladder: Replace styled @media components with Container/Flex/Grid responsive props, swap @media to @container, convert width-based useMedia to useResponsivePropValue or useContainerBreakpoint, or leave genuine non-width media features untouched.
  • Pixel-value token mapping: Maps theme.breakpoints values to the nearest theme.container token by pixel value (e.g. breakpoints.sm at 800px maps to container.xl at 768px), avoiding the same-name mapping bug.
  • Viewport escape hatch: Routes genuine window-driven layouts to screen:-prefixed responsive props and audits existing screen: props as migration candidates.
  • Use Case: When refactoring a styled component that flips flex-direction at the sm breakpoint, delete the styled component and use a Flex primitive with direction={{xs: 'column', sm: 'row'}}, then visually verify the flip by resizing the element.

Quick Start

Ask the assistant to migrate the responsive @media and useMedia logic in a specific Sentry frontend component to container queries following this guide.

Frequently Asked Questions about migrate-container-queries

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate @media queries to container queries in React?

First try replacing the styled component with Container, Flex, or Grid responsive props. If the CSS cannot be a prop, swap @media to @container and replace theme.breakpoints tokens with theme.container tokens mapped by nearest pixel value, not by matching key name.

How do I replace useMedia with container query hooks?

Replace width-based useMedia with useResponsivePropValue({zero: true, xl: false}) for a threshold boolean, or useContainerBreakpoint() when branching on the active key itself. Keep useMedia only for non-width features like prefers-color-scheme, hover, or print.

Why does breakpoints.sm not map to container.sm?

The breakpoint and container scales share key names but have different pixel values: breakpoints.sm is 800px while container.sm is 512px. Map by nearest pixel value instead, so breakpoints.sm maps to container.xl at 768px.

When should I add container-type to a component?

Only add container-type when a subtree must respond to its own width rather than the page's, since Sentry's ContentStack already provides a query container. Use inline-size, and make it conditional with useHasContainerQuery() in reusable components.

Why is my @container query not working?

@container silently no-ops without a query-container ancestor. Confirm an ancestor sets container-type: inline-size, such as the ContentStack wrapper in Sentry's organization layout, and verify the layout by resizing the element itself.