[@mantine/notifications] Direction-aware positions: top-start / top-end / bottom-start / bottom-end #9345
ReemX
started this conversation in
Feature requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
Add direction-aware values to
NotificationPosition:top-start,top-end,bottom-startandbottom-end. They resolve toleft/rightfromuseDirection(). Existing values and thebottom-rightdefault stay exactly as they are, so nothing breaks.Context
#6563 asked for the default position to flip in RTL and was closed as not planned. The advice was to choose
left/rightin app code. That works, and I'm not proposing to change the default or the meaning ofleft/right. This is an opt-in addition.Why it belongs in the library
getFloatingPosition(dir, position)swapsleft↔rightfor Popover, Tooltip, Menu and Tour. Drawer picksrtlTransitionsfromuseDirection(). Inside@mantine/notificationsitself, the progress bar has a[dir="rtl"]rule. Notifications is the only positioned overlay that ignores direction completely.positionis also set per notification (notifications.show({ position })). Every call site that sets one has to read the direction itself, and an app that changes direction at runtime has to re-render<Notifications>with a different prop.start/endsay what the developer means ("the trailing corner") once.inset-inline-start.Proposed implementation (small, non-breaking)
'top-start' | 'top-end' | 'bottom-start' | 'bottom-end'to theNotificationPositiontype.Notifications.tsx, readconst { dir } = useDirection()and mapstart/endtoleft/rightfor both thepositionprop and eachnotification.position, beforegetGroupedNotifications. The six physical containers, the CSS andgetNotificationStateStylesstay unchanged, so the slide-in direction comes out right automatically.I'm happy to open the PR if this direction sounds good to you.
All reactions