Skip to content

Commit

Permalink
Highlight summary content when it changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hilsonshrestha committed Jul 25, 2024
1 parent 7fa9037 commit 5396e3c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/public/sumshaper/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,29 @@ function CustomMarkdown({
onSourceClick?: (elem: HTMLDivElement | null, id: string | null, sourceId: string | null) => void;
onActiveRefChange?: (_: HTMLDivElement | null) => void;
}) {
const [wasUpdated, setWasUpdated] = useState(false);
const isFirstRender = useRef(true);

useEffect(() => {
if (isFirstRender.current) {
return () => {};
}
setWasUpdated(true);
const t = setTimeout(() => {
setWasUpdated(false);
}, 1000);

return () => {
clearTimeout(t);
};
}, [data, isFirstRender]);

useEffect(() => {
isFirstRender.current = false;
}, []);

return (
<div>
<div className={`${style.markdownContent} ${wasUpdated ? style.markdownHighlight : ''}`}>
{data.map((item, index) => {
if (item.text === '\n') {
return (
Expand Down
2 changes: 2 additions & 0 deletions src/public/sumshaper/SummaryApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ function SummaryApp({ parameters, setAnswer }: StimulusParams<SumParams>) {
</ScrollArea>
{activeDocumentId !== null && (
<Summary
key={activeDocumentId}
conversationId={localSummaries[activeDocumentId].conversationId}
sentences={localSummaries[activeDocumentId].content}
onSummaryBadgePositionChange={handleSummaryBadgePositionChange}
Expand All @@ -395,6 +396,7 @@ function SummaryApp({ parameters, setAnswer }: StimulusParams<SumParams>) {
<Grid.Col span={4}>
{activeDocumentId !== null && (
<Source
key={activeDocumentId}
conversationId={localSummaries[activeDocumentId].conversationId}
sourceList={sources[activeDocumentId].content}
onSourceBadgePositionChange={handleSourceBadgePositionChange}
Expand Down
8 changes: 8 additions & 0 deletions src/public/sumshaper/sumsifter.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,11 @@
.modalForm {
padding: 20px;
}

.markdownContent {
transition: background-color 200ms;
}

.markdownHighlight {
background-color: var(--mantine-color-green-1);
}

0 comments on commit 5396e3c

Please sign in to comment.