Animate dropdown menus (#7704)

* animate dropdowns

* rm unused animation
This commit is contained in:
Samuel Newman
2025-02-12 21:20:08 +00:00
committed by GitHub
parent 5d3e2e1467
commit ff2a82d358
2 changed files with 14 additions and 1 deletions
+8 -1
View File
@@ -4,6 +4,7 @@ import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import * as DropdownMenu from '@radix-ui/react-dropdown-menu' import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
import {useA11y} from '#/state/a11y'
import {atoms as a, flatten, useTheme, web} from '#/alf' import {atoms as a, flatten, useTheme, web} from '#/alf'
import * as Dialog from '#/components/Dialog' import * as Dialog from '#/components/Dialog'
import {useInteractionState} from '#/components/hooks/useInteractionState' import {useInteractionState} from '#/components/hooks/useInteractionState'
@@ -177,10 +178,15 @@ export function Outer({
style?: StyleProp<ViewStyle> style?: StyleProp<ViewStyle>
}>) { }>) {
const t = useTheme() const t = useTheme()
const {reduceMotionEnabled} = useA11y()
return ( return (
<DropdownMenu.Portal> <DropdownMenu.Portal>
<DropdownMenu.Content sideOffset={5} loop aria-label="Test"> <DropdownMenu.Content
sideOffset={5}
loop
aria-label="Test"
className="dropdown-menu-transform-origin">
<View <View
style={[ style={[
a.rounded_sm, a.rounded_sm,
@@ -189,6 +195,7 @@ export function Outer({
t.name === 'light' ? t.atoms.bg : t.atoms.bg_contrast_25, t.name === 'light' ? t.atoms.bg : t.atoms.bg_contrast_25,
t.atoms.shadow_md, t.atoms.shadow_md,
t.atoms.border_contrast_low, t.atoms.border_contrast_low,
!reduceMotionEnabled && a.zoom_fade_in,
style, style,
]}> ]}>
{children} {children}
+6
View File
@@ -187,6 +187,7 @@ input:focus {
animation: rotate 500ms linear infinite; animation: rotate 500ms linear infinite;
} }
/* animations for atoms */
@keyframes fadeIn { @keyframes fadeIn {
from { from {
opacity: 0; opacity: 0;
@@ -214,6 +215,11 @@ input:focus {
} }
} }
/* animating radix dropdowns requires knowing the data attributes */
.dropdown-menu-transform-origin > * {
transform-origin: var(--radix-dropdown-menu-content-transform-origin);
}
.force-no-clicks > *, .force-no-clicks > *,
.force-no-clicks * { .force-no-clicks * {
pointer-events: none !important; pointer-events: none !important;