feat: implement React HoverCard component using @base-ui/react primitives (#93)#293
Open
rabadiyameet073 wants to merge 1 commit into
Open
feat: implement React HoverCard component using @base-ui/react primitives (#93)#293rabadiyameet073 wants to merge 1 commit into
rabadiyameet073 wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Implements a new HoverCard component for the Frappe UI React design system, built on top of @base-ui/react/preview-card primitives, and wires it into the component barrel exports alongside Storybook stories, styles, and unit tests.
Changes:
- Added
HoverCardcomponent implementation using Base UIPreviewCardprimitives, including optional arrow rendering and timing delays. - Added HoverCard-specific animation CSS and Storybook stories demonstrating common usage.
- Added initial unit tests and exported the component/types through the library’s index barrels.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/frappe-ui-react/src/components/index.ts | Exposes the new hoverCard module from the main components barrel. |
| packages/frappe-ui-react/src/components/hoverCard/types.ts | Introduces public prop/types for the new HoverCard API. |
| packages/frappe-ui-react/src/components/hoverCard/hoverCard.tsx | Implements the HoverCard composition using @base-ui/react/preview-card. |
| packages/frappe-ui-react/src/components/hoverCard/hoverCard.css | Adds open/close animations and reduced-motion overrides for the popup. |
| packages/frappe-ui-react/src/components/hoverCard/index.ts | Barrel exports for the HoverCard component and its types. |
| packages/frappe-ui-react/src/components/hoverCard/hoverCard.stories.tsx | Adds Storybook documentation/examples for HoverCard variants. |
| packages/frappe-ui-react/src/components/hoverCard/tests/hoverCard.tsx | Adds unit tests for visibility behavior and controlled mode. |
Comment on lines
+22
to
+28
| const container = useMemo(() => { | ||
| if (typeof portalTo === "string") { | ||
| if (portalTo === "body") return document.body; | ||
| return document.querySelector(portalTo) as HTMLElement; | ||
| } | ||
| return portalTo; | ||
| }, [portalTo]); |
Comment on lines
+58
to
+72
| it("supports controlled mode via open and onOpenChange", async () => { | ||
| const onOpenChange = jest.fn(); | ||
|
|
||
| const { rerender } = render( | ||
| <HoverCard | ||
| open={false} | ||
| onOpenChange={onOpenChange} | ||
| trigger={<button>Hover trigger</button>} | ||
| > | ||
| <div>Popup content</div> | ||
| </HoverCard> | ||
| ); | ||
|
|
||
| expect(screen.queryByText("Popup content")).not.toBeInTheDocument(); | ||
|
|
Comment on lines
+1
to
+14
| import type { ReactNode } from "react"; | ||
|
|
||
| export type HoverCardSide = "top" | "right" | "bottom" | "left"; | ||
| export type HoverCardAlign = "start" | "center" | "end"; | ||
|
|
||
| export interface HoverCardProps { | ||
| /** | ||
| * The content to show inside the HoverCard popup. | ||
| */ | ||
| children?: ReactNode; | ||
| /** | ||
| * The trigger element that activates the HoverCard when hovered or focused. | ||
| */ | ||
| trigger: ReactNode; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Frappe.UI.React.-.Video.mp4
Closes #93
Overview & Motivation
This PR implements the React version of the
HoverCardcomponent for the Frappe UI design system, following the behavior specified in the Frappe UI documentation (https://ui.frappe.io/docs/components/hovercard) and issue comment (#93 (comment)).The component is built using
@base-ui/react/preview-cardprimitives to maintain architectural consistency with existing headless components infrappe-ui-react.File-by-File Technical Summary
packages/frappe-ui-react/src/components/hoverCard/types.tsHoverCardPropssupporting positioning (side,align,offset,collisionPadding), triggers (trigger,children), delays (hoverDelay,leaveDelay), portal overrides (portalTo), arrow toggle (arrow), and open state control handlers (open,defaultOpen,onOpenChange).packages/frappe-ui-react/src/components/hoverCard/hoverCard.tsx@base-ui/react/preview-cardparts.<PreviewCard.Trigger>.<PreviewCard.Portal>target containers dynamically based on theportalToprop.<PreviewCard.Arrow>with a block display SVG and custom path to avoid rendering base separator lines.<PreviewCard.Arrow>using Tailwind selectors (data-[side]) to align the pointer toward the trigger.packages/frappe-ui-react/src/components/hoverCard/hoverCard.csshovercard-inandhovercard-out) to animate scale and opacity.[data-open]and[data-closed].@media (prefers-reduced-motion: reduce)overrides to support system-level accessibility settings.packages/frappe-ui-react/src/components/hoverCard/index.tsHoverCardcomponent and all typescript prop interfaces.packages/frappe-ui-react/src/components/index.ts./hoverCardto register the new component globally in the component library.packages/frappe-ui-react/src/components/hoverCard/hoverCard.stories.tsx@janeprofile link), Delays (slow fade-in/fade-out), and Arrow (downward pointing arrow indicator) usage stories.trigger,children,portalTo,onOpenChange,open,defaultOpen) to ensure the control panel is clean and prevent Storybook iframe communication timeouts.packages/frappe-ui-react/src/components/hoverCard/tests/hoverCard.tsx