feat(F0Box): add hoverBackground prop with semantic hover tokens#3738
feat(F0Box): add hoverBackground prop with semantic hover tokens#3738
Conversation
✅ No New Circular DependenciesNo new circular dependencies detected. Current count: 0 |
There was a problem hiding this comment.
Pull request overview
This PR extends F0Box’s styling API to support semantic hover background tokens from @factorialco/f0-core, allowing consumers to use hover background states declaratively through a new hoverBackground prop.
Changes:
- Added a new
HoverBackgroundTokenunion type to represent supported hover background tokens. - Added a
hoverBackgroundCVA variant mapping tokens tohover:bg-f1-background-*-hoverclasses (withtransition-colors). - Wired
hoverBackgroundthroughF0Boxso it’s applied viaboxVariants.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/react/src/components/F0Box/utils/background.ts | Adds hoverBackground variant mappings for hover background tokens. |
| packages/react/src/components/F0Box/types.ts | Introduces HoverBackgroundToken type for the new prop. |
| packages/react/src/components/F0Box/F0Box.tsx | Passes hoverBackground into the CVA variant resolver. |
| /** Hover background tokens mapped to the f1 theme hover states */ | ||
| export type HoverBackgroundToken = | ||
| | "default" | ||
| | "secondary" | ||
| | "accent-bold" | ||
| | "promote" | ||
| | "selected" | ||
| | "selected-bold" |
There was a problem hiding this comment.
HoverBackgroundToken is introduced as part of the public F0Box token surface, but it isn’t re-exported from components/F0Box/index.tsx (that file explicitly enumerates exported token types). As a result, consumers can’t import this token type the same way they do BackgroundToken, BorderColorToken, etc. Please add HoverBackgroundToken to the token type re-export list in index.tsx to keep the public API consistent.
| // Background | ||
| background, | ||
| hoverBackground, | ||
| // Border |
There was a problem hiding this comment.
hoverBackground is wired into the main CVA variants, but it can’t be set via the responsive overrides (sm/md/lg/xl) because ResponsiveStyleProps only exposes background (not hoverBackground). If this prop is intended to behave like other style props, consider adding it to ResponsiveStyleProps and ensuring any needed responsive safelist entries exist for sm:hover:* classes.
| hoverBackground: { | ||
| default: "hover:bg-f1-background-hover transition-colors", | ||
| secondary: "hover:bg-f1-background-secondary-hover transition-colors", | ||
| "accent-bold": "hover:bg-f1-background-accent-bold-hover transition-colors", | ||
| promote: "hover:bg-f1-background-promote-hover transition-colors", | ||
| selected: "hover:bg-f1-background-selected-hover transition-colors", | ||
| "selected-bold": | ||
| "hover:bg-f1-background-selected-bold-hover transition-colors", |
There was a problem hiding this comment.
The hoverBackground variant strings repeat transition-colors for every token. This is a small maintainability issue (harder to adjust transition behavior consistently later). Consider factoring transition-colors out so it’s applied once when hoverBackground is set (e.g., via a shared constant, base class, or compound variant).
📦 Alpha Package Version PublishedUse Use |
🔍 Visual review for your branch is published 🔍Here are the links to: |
Coverage Report for packages/react
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@AngelMsaa I've opened a new pull request, #3739, to work on those changes. Once the pull request is ready, I'll request review from you. |
Add a new `hoverBackground` prop to F0Box that exposes the 6 hover background tokens defined in @factorialco/f0-core but previously missing from the component API: - default (bg hover) - secondary (bg secondary hover) - accent-bold (bg accent bold hover) - promote (bg promote hover) - selected (bg selected hover) - selected-bold (bg selected bold hover) Each value applies the corresponding `hover:bg-f1-background-*-hover` Tailwind class along with `transition-colors` for smooth state changes.
5eb9059 to
0591663
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| grow, | ||
| shrink, | ||
| }), | ||
| hoverBackground && "transition-colors", |
There was a problem hiding this comment.
Missing transition-colors for responsive-only hoverBackground usage
Medium Severity
The transition-colors class is only applied when the direct hoverBackground prop is set. If a consumer uses hoverBackground exclusively through a responsive breakpoint prop (e.g., sm={{ hoverBackground: "default" }}), the top-level hoverBackground is undefined, so transition-colors is never added. The hover color change will then be instant rather than smoothly animated, which is inconsistent with the direct-prop behavior. The check needs to also consider whether any breakpoint override includes a hoverBackground value.


What?
Add a new
hoverBackgroundprop toF0Boxthat exposes the 6 hover background tokens defined in@factorialco/f0-corebut previously missing from the component API.Why?
The core token system defines hover variants for backgrounds (
background.hover,background.secondary.hover, etc.) butF0Boxhad no way to use them declaratively. Consumers had to manually apply Tailwind hover classes, bypassing the design system's token abstraction.How?
HoverBackgroundTokentype with 6 values:default,secondary,accent-bold,promote,selected,selected-boldhoverBackgroundCVA variant mapping each token tohover:bg-f1-background-*-hover+transition-colorsF0BoxUsage
Checklist
Note
Low Risk
Low risk UI-only change that adds optional hover styling tokens and corresponding Tailwind safelisted classes; primary risk is missing/incorrect token-to-class mappings causing unexpected hover colors.
Overview
F0Boxnow supports an optionalhoverBackgroundprop that maps a small set of semantic hover background tokens tohover:bg-*Tailwind classes, and automatically addstransition-colorswhen used.This change threads the new token through the component API/exports, extends
backgroundVariantsandResponsiveStylePropsto handle responsive hover overrides, and expands the responsive Tailwind safelist to ensure hover classes are generated at build time.Written by Cursor Bugbot for commit 0591663. This will update automatically on new commits. Configure here.