* feat(v5): UI updates * fix: css file size * fix: e2e tests * fix: e2e tests * fix: e2e tests * chore: add theme toggle to react demo example * Update sources panel display, update dark theme * fix: lint * fix(askai): address ui review feedback * fix: pin icon positioning * fix(askai): improve a11y and dark-mode shimmer for thinking and error states - add role=alert/status and aria-hidden on error/thinking UI - support dark-mode shimmer gradients via CSS variables - respect prefers-reduced-motion for shimmer - handle null date in useRelativeFormattedDate with fallback translation
63 lines
1.8 KiB
TypeScript
63 lines
1.8 KiB
TypeScript
import type { JSX } from 'react';
|
|
import React from 'react';
|
|
|
|
import type { AskAiScreenStateProps } from './AskAiScreenState';
|
|
import { CloseIcon, SparklesIcon } from './icons';
|
|
import { Results } from './Results';
|
|
import type { ResultsScreenTranslations } from './ResultsScreen';
|
|
import type { InternalDocSearchHit } from './types';
|
|
import { getCollection } from './utils';
|
|
|
|
type ConversationHistoryScreenProps = Omit<AskAiScreenStateProps<InternalDocSearchHit>, 'translations'> & {
|
|
translations?: ResultsScreenTranslations;
|
|
};
|
|
|
|
export function ConversationHistoryScreen({
|
|
onAskAiToggle,
|
|
...props
|
|
}: ConversationHistoryScreenProps): JSX.Element | null {
|
|
const collection = React.useMemo(() => getCollection(props.state, 'recentConversations'), [props.state]);
|
|
|
|
React.useEffect(() => {
|
|
if (!collection || collection.items.length === 0) {
|
|
onAskAiToggle(true);
|
|
}
|
|
}, [collection, onAskAiToggle]);
|
|
|
|
if (!collection) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div className="DocSearch-Dropdown-Container DocSearch-Conversation-History">
|
|
<Results
|
|
{...props}
|
|
key={collection.source.sourceId}
|
|
title=""
|
|
translations={props.translations}
|
|
collection={collection}
|
|
renderIcon={() => (
|
|
<div className="DocSearch-Hit-icon">
|
|
<SparklesIcon />
|
|
</div>
|
|
)}
|
|
renderAction={({ item }) => (
|
|
<div className="DocSearch-Hit-action">
|
|
<button
|
|
type="button"
|
|
className="DocSearch-Hit-action-button"
|
|
onClick={(e) => {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
props.conversations.remove(item);
|
|
props.refresh();
|
|
}}
|
|
>
|
|
<CloseIcon />
|
|
</button>
|
|
</div>
|
|
)}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|