({children}: ThreadScrollButtonProps)
| 334 | * A ThreadScrollButton displays a button to scroll to the bottom of a Chat thread. |
| 335 | */ |
| 336 | export function ThreadScrollButton({children}: ThreadScrollButtonProps) { |
| 337 | let {isNearBottom, scrollToBottom, ...buttonProps} = useContext(ThreadScrollButtonContext); |
| 338 | let ref = useRef<HTMLDivElement>(null); |
| 339 | let isVisible = !isNearBottom; |
| 340 | let isExiting = useExitAnimation(ref, isVisible); |
| 341 | |
| 342 | if (!isVisible && !isExiting) { |
| 343 | return null; |
| 344 | } |
| 345 | |
| 346 | return ( |
| 347 | <ButtonContext.Provider |
| 348 | value={{slots: {[DEFAULT_SLOT]: {}, scroll: {onPress: scrollToBottom, ...buttonProps}}}}> |
| 349 | <ThreadScrollButtonInner domRef={ref} isExiting={isExiting}> |
| 350 | {children} |
| 351 | </ThreadScrollButtonInner> |
| 352 | </ButtonContext.Provider> |
| 353 | ); |
| 354 | } |
| 355 | |
| 356 | interface ThreadScrollButtonInnerProps { |
| 357 | domRef: RefObject<HTMLDivElement | null>; |
nothing calls this directly
no test coverage detected