Skip to content

Add support for aligned popover placements (start/end variants) - #23

Merged
JSv4 merged 1 commit into
mainfrom
claude/resolve-issue-22-gZ4Uy
Apr 4, 2026
Merged

Add support for aligned popover placements (start/end variants)#23
JSv4 merged 1 commit into
mainfrom
claude/resolve-issue-22-gZ4Uy

Conversation

@JSv4

@JSv4 JSv4 commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Extended the Popover component to support 12 placement options instead of 4, adding start and end alignment variants for each cardinal direction. This allows for more flexible positioning of popovers relative to their trigger elements.

Key Changes

  • Type Definition: Updated PopoverPlacement type to include all 12 variants:

    • top, top-start, top-end
    • bottom, bottom-start, bottom-end
    • left, left-start, left-end
    • right, right-start, right-end
  • Position Calculation Logic: Extended the positioning algorithm in Popover.tsx to handle all new placement variants:

    • Start variants align with the trigger's start edge
    • End variants align with the trigger's end edge
    • Center variants (original behavior) remain unchanged
  • CSS Transforms: Added corresponding CSS transform rules in Popover.styles.ts for proper alignment of each placement variant

  • Storybook:

    • Updated the placement control options to include all 12 variants
    • Added a new BottomEnd story demonstrating a practical use case (user menu dropdown)

Implementation Details

The positioning logic uses the trigger element's bounding rectangle to calculate coordinates:

  • For horizontal placements (left/right): start uses top, center uses top + height/2, end uses bottom
  • For vertical placements (top/bottom): start uses left, center uses left + width/2, end uses right
  • CSS transforms are applied to align the popover content appropriately relative to the calculated position

https://claude.ai/code/session_01SZorT2y1tzv2yNKtZ7fbt6

Extend PopoverPlacement type with -start and -end variants for all four
directions (top, bottom, left, right). This enables right-aligned dropdowns
via bottom-end, left-aligned via bottom-start, and similar patterns for
other directions — resolving viewport overflow when popovers are placed
near screen edges.

Closes #22
@JSv4 JSv4 linked an issue Apr 3, 2026 that may be closed by this pull request
@JSv4
JSv4 merged commit 7d2100e into main Apr 4, 2026
4 checks passed
@JSv4
JSv4 deleted the claude/resolve-issue-22-gZ4Uy branch April 4, 2026 04:20
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.

Popover: add bottom-end placement for right-aligned dropdowns

2 participants