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