|
5 | 5 | /** |
6 | 6 | * @file CommentRow.tsx |
7 | 7 | * @input Uses React, StyleX, Astryx Card/Section/Link/Timestamp/Badge, |
8 | | - * useContainerReveal, useClickableContainer, ChatMessageMetadata, |
9 | | - * ChatTypingIndicator, and the Comments family's context and parts |
| 8 | + * useContainerReveal, useClickableContainer, ChatMessageMetadata, the |
| 9 | + * caller's typing indicator, and the Comments family's context and parts |
10 | 10 | * @output Exports CommentRow: a thread (its first comment, render-derived open |
11 | | - * replies, typing state, hidden seen metadata, and reply composer, on a |
12 | | - * selectable Card or Section) at depth 0, or a reply at depth 1 |
| 11 | + * replies, typing state, and reply composer, on a selectable Card or |
| 12 | + * Section) at depth 0, or a reply at depth 1 |
13 | 13 | * @position Internal row renderer shared by Comments and CommentThread |
14 | 14 | */ |
15 | 15 |
|
16 | | -import { |
17 | | - useCallback, |
18 | | - useRef, |
19 | | - useState, |
20 | | - type CSSProperties, |
21 | | - type ReactNode, |
22 | | -} from 'react'; |
| 16 | +import {useCallback, useRef, useState, type ReactNode} from 'react'; |
23 | 17 | import * as stylex from '@stylexjs/stylex'; |
24 | 18 | import {Badge} from '@astryxdesign/core/Badge'; |
25 | 19 | import {Card} from '@astryxdesign/core/Card'; |
@@ -50,7 +44,6 @@ import { |
50 | 44 | } from './CommentActions'; |
51 | 45 | import {CommentComposerBase} from './CommentComposer'; |
52 | 46 | import {CommentMarkdown} from './CommentMarkdown'; |
53 | | -import {ChatTypingIndicator} from '../Chat/ChatTypingIndicator'; |
54 | 47 | import { |
55 | 48 | AuthorName, |
56 | 49 | AvatarSpacer, |
@@ -87,10 +80,6 @@ export type ThreadDivider = 'top' | 'bottom'; |
87 | 80 |
|
88 | 81 | /** The 28px avatar column (StyleX resolves only same-file constants). */ |
89 | 82 | const AVATAR_SIZE = `calc(${spacingVars['--spacing-6']} + ${spacingVars['--spacing-1']})`; |
90 | | -const TYPING_INDICATOR_STYLE: CSSProperties & |
91 | | - Record<'--astryx-chat-typing-indicator-dots-column-width', string> = { |
92 | | - '--astryx-chat-typing-indicator-dots-column-width': AVATAR_SIZE, |
93 | | -}; |
94 | 83 | export const THREAD_DIVIDERS: readonly ThreadDivider[] = ['top', 'bottom']; |
95 | 84 |
|
96 | 85 | const styles = stylex.create({ |
@@ -130,9 +119,6 @@ const styles = stylex.create({ |
130 | 119 | flexBasis: 0, |
131 | 120 | minWidth: 0, |
132 | 121 | }, |
133 | | - typingIndicator: { |
134 | | - width: '100%', |
135 | | - }, |
136 | 122 | // Row controls carry one spacing step of inline padding. Pulling the row |
137 | 123 | // back by that step puts their glyphs on the body text line, so only their |
138 | 124 | // hover and pressed fills cross it. |
@@ -350,6 +336,7 @@ export function CommentRow({ |
350 | 336 | replyError, |
351 | 337 | replyTarget, |
352 | 338 | selectedThreadId, |
| 339 | + typingIndicator, |
353 | 340 | } = scope; |
354 | 341 | const [isMetadataMenuOpen, setIsMetadataMenuOpen] = useState(false); |
355 | 342 | const {getContainerProps, getContentRevealProps} = useContainerReveal(); |
@@ -812,15 +799,14 @@ export function CommentRow({ |
812 | 799 | ))} |
813 | 800 | </VStack> |
814 | 801 | )} |
815 | | - {depth === 0 && isThreadSelected && typingUsers.length > 0 && ( |
816 | | - <HStack width="100%" data-thread-typing-indicator="true"> |
817 | | - <ChatTypingIndicator |
818 | | - names={typingUsers.map(user => user.name)} |
819 | | - xstyle={styles.typingIndicator} |
820 | | - style={TYPING_INDICATOR_STYLE} |
821 | | - /> |
822 | | - </HStack> |
823 | | - )} |
| 802 | + {depth === 0 && |
| 803 | + isThreadSelected && |
| 804 | + typingIndicator != null && |
| 805 | + typingUsers.length > 0 && ( |
| 806 | + <HStack width="100%" data-thread-typing-indicator="true"> |
| 807 | + {typingIndicator({users: typingUsers})} |
| 808 | + </HStack> |
| 809 | + )} |
824 | 810 | </VStack> |
825 | 811 |
|
826 | 812 | {depth === 0 && |
|
0 commit comments