-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathAttachmentRow.tsx
More file actions
56 lines (49 loc) · 1.6 KB
/
AttachmentRow.tsx
File metadata and controls
56 lines (49 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { useStyles } from 'botframework-webchat-styles/react';
import { reactNode, validateProps } from 'botframework-webchat-react-valibot';
import cx from 'classnames';
import React, { memo } from 'react';
import { boolean, object, optional, pipe, readonly, string, type InferInput } from 'valibot';
import ScreenReaderText from '../ScreenReaderText';
import Bubble from './Bubble';
import styles from './StackedLayout.module.css';
const attachmentRowPropsSchema = pipe(
object({
attachedAlt: string(),
children: optional(reactNode()),
fromUser: boolean(),
hasAvatar: boolean(),
hasNub: boolean(),
showBubble: optional(boolean())
}),
readonly()
);
type AttachmentRowProps = InferInput<typeof attachmentRowPropsSchema>;
function AttachmentRow(props: AttachmentRowProps) {
const {
attachedAlt,
children,
fromUser,
hasAvatar,
hasNub,
showBubble = true
} = validateProps(attachmentRowPropsSchema, props);
const classNames = useStyles(styles);
return (
<div aria-roledescription="attachment" className={classNames['stacked-layout__attachment-row']} role="group">
<ScreenReaderText text={attachedAlt} />
{showBubble ? (
<Bubble
className={classNames['stacked-layout__attachment']}
fromUser={fromUser}
nub={hasAvatar || hasNub ? 'hidden' : false}
>
{children}
</Bubble>
) : (
<div className={cx(classNames['stacked-layout__attachment'])}>{children}</div>
)}
</div>
);
}
export default memo(AttachmentRow);
export { attachmentRowPropsSchema, type AttachmentRowProps };