Skip to content

feat(theme): align the card recipes with Open Components - #377

Merged
alexgrozav merged 3 commits into
align-component-styles-uxf-487from
align-card-recipes-uxf-493
Oct 29, 2026
Merged

alexgrozav merged 3 commits into
align-component-styles-uxf-487from
align-card-recipes-uxf-493

Conversation

@alexgrozav

@alexgrozav alexgrozav commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Brings the card, card-header, card-body and card-footer recipes in line with the Open Components Card page's stylesheet rules, and adds a card-media recipe (useCardMediaRecipe) for the media rules.

  • Stretched link. A link in a heading inside the card header stretches over the whole card, border included, with its ::after. Links, buttons and fields elsewhere in the card sit above it (position: relative, z-index: 1).
  • Focus. When that link has keyboard focus, the card shows a 2px solid color.focus outline, 2px outside its border (:has(a[href]:focus-visible)). It falls back to color.primary when a project defines no color.focus, like the global focus default.
  • Hover. Inside @media (hover: hover), the border gets stronger and the heading is underlined, only while the pointer is over the part of the card that follows the link.
  • More contrast and forced colours. The border is drawn in currentColor with prefers-contrast: more (on hover too) and in CanvasText in forced colours mode. The ring switches to Highlight.
  • Resizing. The card drops overflow: hidden, wraps long words with overflow-wrap: break-word and sets min-width: 0.
  • Right to left. The header, body and footer pad their inline sides with paddingInline. The media rounds its start corners with logical radii.
  • Media. card-media shows above the header with order: -1, so the heading comes first in the DOM, and keeps a 16 / 9 aspect ratio that its image fills.
  • Tests. One test per rule, named after its rule id, and cardContrast.test.ts checks text at 4.5:1 for every colour × variant in both themes, and the ring at 3:1 against the page.
  • Storybook and docs. The preview components render an <article> and an <h3>, inline styles are gone, and there are Linked, Focused, WithActions, WithMedia and LongContent stories. The docs page has a rewritten Accessibility section and documents the media part.

No recipe name, axis, value or default changes. The changeset is minor for the new export.

Related issue

Part of the work to align Styleframe's component styles with Open Components.

Type of change

  • 🐞 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior)
  • 📖 Documentation
  • ♻️ Refactor / internal (no functional change)
  • 🔧 Build / tooling / CI

Checklist

  • My commits follow Conventional Commits with a package scope (e.g. feat(theme): …)
  • I ran pnpm build:nodocs && pnpm lint && pnpm typecheck && pnpm test and everything passes
  • I added a changeset (pnpm changeset) for changes to publishable packages, or this change only touches docs/storybook/app/playground/tests
  • I added or updated tests where relevant
  • I updated documentation where relevant
  • I did not edit generated files (dist/, .styleframe/)
  • My PR targets main and stays focused in scope

Notes / screenshots

  • Checks. pnpm build:nodocs, pnpm lint (217 warnings, as on the base), pnpm typecheck and the theme tests (3690) pass. pnpm test fails only in @styleframe/playground's test/theme.test.ts (8 tests, localStorage.clear is undefined under Node 26), which fails the same way on the base branch.
  • Target. This PR targets the integration branch, not main.
  • More contrast. The contrast-more modifier's class is emitted before the colour compounds' border classes and loses the cascade, so the more-contrast and forced-colours borders sit in a .card.card.card setup selector instead, which beats both the compound and the dark-theme classes.
  • Actions above the link. The lift rule is wrapped in :where(), so a recipe or utility class that positions its own element, like the slider thumb, keeps its position inside a card.
  • Media corners. They're rounded calc(<card radius> - 1px), since border-width.thin is the thin keyword, which calc() can't use.
  • Contrast boundaries. cardContrast.test.ts checks text and the focus ring, not the card border (1.45 to 1.69:1). The Card page's card/contrast asks only for those two and calls the border decoration, since the heading says what the card is.
  • Stretched link inset. It uses -1px rather than the border-width.thin token, which is the thin keyword that calc() can't negate.
  • Declined rules. None. The media rules (card/media-ratio, card/text-below-media, card/heading-first) are met by the new card-media part.
  • Axe. Every card story has 0 violations in light and dark, except the WithActions story in dark, where the shared Button's own text contrast fails. That's the Button recipe's work, not the card's.

Stretch the heading's link over the card, keep actions above it, and draw the focus ring around the card in color.focus. Hover only on hover-capable devices, full-strength borders with more contrast, system colours in forced colours mode, logical padding, and no clipping. Add a card-media part for the media rules.
Keep the card recipe working when a project defines no color.focus, stretch the link over the border, draw the forced-colours border from the setup selector, and add a focused story.
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
styleframe-dev Ready Ready Preview Oct 29, 2026 7:17pm UTC
styleframe-dev-storybook Ready Ready Preview Oct 29, 2026 7:17pm UTC

Request Review

…d actions in place

Subtract 1px from the media radius, since border-width.thin is the thin keyword that calc() can't use, wrap the actions-above selector in :where() so a recipe that positions its own element still wins, and pin the card's hover border in a test.
@alexgrozav
alexgrozav merged commit 6361b01 into align-component-styles-uxf-487 Oct 29, 2026
3 checks passed
@alexgrozav
alexgrozav deleted the align-card-recipes-uxf-493 branch October 29, 2026 19:36

This branch was successfully deployed

2 active deployments
Preview – styleframe-dev — b8b2e2d0 Deployed Oct 29, 2026 by vercel[bot]
Preview – styleframe-dev-storybook — b8b2e2d0 Deployed Oct 29, 2026 by vercel[bot]
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