Skip to content

Commit 13c2cb2

Browse files
committed
Polish and fix tests
1 parent 82989fc commit 13c2cb2

13 files changed

+39
-40
lines changed

packages/component/src/Activity/private/VoteButton.tsx

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { onErrorResumeNext, parseVoteAction, type OrgSchemaAction } from 'botframework-webchat-core';
2+
import cx from 'classnames';
23
import React, { memo, useCallback, useMemo } from 'react';
34
import { useRefFrom } from 'use-ref-from';
45

56
import ThumbsButton from './ThumbButton';
67

78
type Props = Readonly<{
8-
className?: string;
9+
className?: string | undefined;
910
action: OrgSchemaAction;
1011
onClick?: (action: OrgSchemaAction) => void;
1112
pressed: boolean;
@@ -29,7 +30,16 @@ const FeedbackVoteButton = memo(({ action, className, onClick, pressed }: Props)
2930

3031
const handleClick = useCallback(() => onClickRef.current?.(voteActionRef.current), [onClickRef, voteActionRef]);
3132

32-
return <ThumbsButton className={className} direction={direction} onClick={handleClick} pressed={pressed} />;
33+
return (
34+
<ThumbsButton
35+
className={cx(className, {
36+
'webchat__thumb-button--is-complete': action.actionStatus === 'CompletedActionStatus'
37+
})}
38+
direction={direction}
39+
onClick={handleClick}
40+
pressed={pressed}
41+
/>
42+
);
3343
});
3444

3545
FeedbackVoteButton.displayName = 'FeedbackVoteButton';

packages/component/src/ActivityStatus/OthersActivityStatus.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ import Timestamp from './Timestamp';
1616
import ActivityFeedback from '../Activity/ActivityFeedback';
1717
import StatusSlot from './StatusSlot';
1818

19-
type Props = Readonly<{ activity: WebChatActivity }>;
19+
type Props = Readonly<{ activity: WebChatActivity; className?: string | undefined }>;
2020

2121
const warnRootLevelThings = warnOnce(
2222
'Root-level things are being deprecated, please relate all things to `entities[@id=""]` instead. This feature will be removed in 2025-03-06.'
2323
);
2424

25-
const OthersActivityStatus = memo(({ activity }: Props) => {
25+
const OthersActivityStatus = memo(({ activity, className }: Props) => {
2626
const [{ sendStatus }] = useStyleSet();
2727
const { timestamp } = activity;
2828
const graph = useMemo(() => dereferenceBlankNodes(activity.entities || []), [activity.entities]);
@@ -56,13 +56,13 @@ const OthersActivityStatus = memo(({ activity }: Props) => {
5656
}, [graph, messageThing]);
5757

5858
return (
59-
<div className={classNames('webchat__activity-status', 'webchat__activity-status--slotted', sendStatus + '')}>
59+
<span className={classNames('webchat__activity-status', className, sendStatus + '')}>
6060
<StatusSlot>{timestamp && <Timestamp key="timestamp" timestamp={timestamp} />}</StatusSlot>
6161
<StatusSlot>{claimInterpreter && <Originator key="originator" project={claimInterpreter} />}</StatusSlot>
6262
<StatusSlot>
6363
<ActivityFeedback activity={activity} key="feedback" placement="activity-status" />
6464
</StatusSlot>
65-
</div>
65+
</span>
6666
);
6767
});
6868

packages/component/src/ActivityStatus/SelfActivityStatus.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ import React, { memo } from 'react';
55
import Timestamp from './Timestamp';
66
import useStyleSet from '../hooks/useStyleSet';
77

8-
type Props = Readonly<{ activity: WebChatActivity }>;
8+
type Props = Readonly<{ activity: WebChatActivity; className?: string | undefined }>;
99

10-
const SelftActivityStatus = memo(({ activity }: Props) => {
10+
const SelftActivityStatus = memo(({ activity, className }: Props) => {
1111
const [{ sendStatus }] = useStyleSet();
1212
const { timestamp } = activity;
1313

1414
return timestamp ? (
15-
<div className={classNames('webchat__activity-status', 'webchat__activity-status--self', sendStatus + '')}>
15+
<span
16+
className={classNames('webchat__activity-status', 'webchat__activity-status--self', className, sendStatus + '')}
17+
>
1618
<Timestamp timestamp={timestamp} />
17-
</div>
19+
</span>
1820
) : null;
1921
});
2022

packages/component/src/ActivityStatus/StatusSlot.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import classNames from 'classnames';
44
type Props = Readonly<{ className?: string; children?: ReactNode | undefined }>;
55

66
const StatusSlot = ({ children, className }: Props) => (
7-
<div className={classNames('webchat__activity-status-slot', className)}>{children}</div>
7+
<span className={classNames('webchat__activity-status-slot', className)}>{children}</span>
88
);
99

1010
StatusSlot.displayName = 'StatusSlot';

packages/component/src/Middleware/ActivityStatus/createTimestampMiddleware.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ export default function createTimestampMiddleware(): ActivityStatusMiddleware {
2020
// If "hideTimestamp" is set, we will not render the visual timestamp. But continue to render the screen reader only version.
2121
return <AbsoluteTime hide={true} value={activity.timestamp} />;
2222
} else if (activity.from.role === 'bot') {
23-
return <OthersActivityStatus activity={activity} />;
23+
return <OthersActivityStatus activity={activity} className={'webchat__activity-status--slotted'} />;
2424
}
2525

26-
return <SelfActivityStatus activity={activity} />;
26+
return <SelfActivityStatus activity={activity} className={'webchat__activity-status--slotted'} />;
2727
};
2828
}

packages/component/src/Styles/StyleSet/SendStatus.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ export default function createSendStatusStyle() {
1515
},
1616

1717
'& .webchat__activity-status-slot': {
18+
display: 'contents',
19+
1820
'&:not(:first-child)::before': {
19-
content: `"|"`,
20-
marginRight: '4px',
21-
display: 'inline-block'
21+
content: `"|"`
2222
},
23+
2324
'&:empty': {
2425
display: 'none'
2526
}

packages/component/src/Styles/StyleSet/SlottedActivityStatus.ts

-16
This file was deleted.

packages/component/src/Styles/StyleSet/ThumbButton.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ export default function () {
44
return {
55
'&.webchat__thumb-button': {
66
appearance: 'none',
7-
background: 'Transparent',
7+
background: 'transparent',
88
border: 0,
99
borderRadius: 2,
1010
boxSizing: 'content-box',
1111
height: 16,
12-
fontSize: '14px',
1312
/* The Fluent icon is larger than the button. We need to clip it.
1413
Without clipping, hover effect will appear on the edge of the button but not possible to click. */
1514
overflow: ['hidden', 'clip'],
@@ -21,14 +20,16 @@ export default function () {
2120
border: '1px solid transparent',
2221
borderRadius: '4px',
2322
display: 'flex',
24-
fontSize: '20px',
2523
height: '20px',
2624
justifyContent: 'center',
2725
padding: '5px',
2826
width: '20px',
2927

3028
'& .webchat__thumb-button__image': {
31-
color: 'currentColor'
29+
color: 'currentColor',
30+
fontSize: '20px',
31+
height: '1em',
32+
width: '1em'
3233
},
3334

3435
'&:hover, &:active, &.webchat__thumb-button--is-pressed': {
@@ -47,8 +48,7 @@ export default function () {
4748

4849
'& .webchat__thumb-button__image': {
4950
color: CSSTokens.ColorAccent,
50-
width: '1em',
51-
height: '1em'
51+
width: 14
5252
},
5353

5454
'&:hover .webchat__thumb-button__image:not(.webchat__thumb-button__image--is-filled)': {

packages/component/src/Styles/createStyleSet.ts

-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import createSendBoxButtonStyle from './StyleSet/SendBoxButton';
3333
import createSendBoxStyle from './StyleSet/SendBox';
3434
import createSendBoxTextBoxStyle from './StyleSet/SendBoxTextBox';
3535
import createSendStatusStyle from './StyleSet/SendStatus';
36-
import createSlottedActivityStatusStyle from './StyleSet/SlottedActivityStatus';
3736
import createSpinnerAnimationStyle from './StyleSet/SpinnerAnimation';
3837
import createStackedLayoutStyle from './StyleSet/StackedLayout';
3938
import createSuggestedActionsStyle from './StyleSet/SuggestedActions';
@@ -111,7 +110,6 @@ export default function createStyleSet(styleOptions: StyleOptions) {
111110
modalDialog: createModalDialogStyle(),
112111
renderMarkdown: createRenderMarkdownStyle(),
113112
sendStatus: createSendStatusStyle(),
114-
slottedActivityStatus: createSlottedActivityStatusStyle(),
115113
textContent: createTextContentStyle(),
116114
thumbButton: createThumbButtonStyle(),
117115
viewCodeDialog: createViewCodeDialogStyle()

packages/fluent-theme/src/components/theme/Theme.module.css

+4
Original file line numberDiff line numberDiff line change
@@ -598,4 +598,8 @@
598598
&:focus-visible {
599599
outline: var(--webchat-strokeWidthThick) solid var(--webchat-colorStrokeFocus2);
600600
}
601+
602+
&:global(.webchat__thumb-button--is-complete) {
603+
color: var(--webchat-colorNeutralForegroundDisabled);
604+
}
601605
}

0 commit comments

Comments
 (0)