({placement, align, reduceMotion})
| 462 | } |
| 463 | |
| 464 | function SpectrumToastList({placement, align, reduceMotion}) { |
| 465 | let {isExpanded, toggleExpanded} = useContext(ToastContainerContext)!; |
| 466 | |
| 467 | // Attach click handler to ref since ToastList doesn't pass through onClick/onPress. |
| 468 | let toastListRef = useRef(null); |
| 469 | useEvent(toastListRef, 'click', e => { |
| 470 | // Have to check if this is a button because stopPropagation in react events doesn't affect native events. |
| 471 | if (!isExpanded && !(getEventTarget(e) as Element)?.closest('button')) { |
| 472 | toggleExpanded(); |
| 473 | } |
| 474 | }); |
| 475 | |
| 476 | return ( |
| 477 | <ToastList<SpectrumToastValue> |
| 478 | ref={toastListRef} |
| 479 | style={({isHovered}) => { |
| 480 | let origin = isHovered ? 95 : 55; |
| 481 | return { |
| 482 | perspective: 80, |
| 483 | perspectiveOrigin: |
| 484 | 'center ' + (placement === 'top' ? `calc(100% + ${origin}px)` : `${-origin}px`), |
| 485 | transition: 'perspective-origin 400ms' |
| 486 | }; |
| 487 | }} |
| 488 | className={ |
| 489 | toastCss[isExpanded ? 'toast-list-expanded' : 'toast-list-collapsed'] + |
| 490 | toastList({placement, align, isExpanded}) |
| 491 | }> |
| 492 | {({toast}) => ( |
| 493 | <SpectrumToast |
| 494 | toast={toast} |
| 495 | placement={placement} |
| 496 | align={align} |
| 497 | reduceMotion={reduceMotion} |
| 498 | /> |
| 499 | )} |
| 500 | </ToastList> |
| 501 | ); |
| 502 | } |
| 503 | |
| 504 | interface SpectrumToastProps extends ToastProps<SpectrumToastValue> { |
| 505 | placement?: 'top' | 'bottom'; |
nothing calls this directly
no test coverage detected