Skip to content

Commit

Permalink
update heartbeat
Browse files Browse the repository at this point in the history
  • Loading branch information
271212 committed Sep 5, 2024
1 parent 7312971 commit 108604e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
34 changes: 34 additions & 0 deletions src/modules/l2-rollup-detail/MarkdownComponent/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'katex/dist/katex.min.css';
import { useEffect, useState } from 'react';
import Markdown from 'react-markdown';
import s from './styles.module.scss';

const MarkdownComponent = ({
text,
delay = 10,
}: {
text: string;
delay?: number;
}) => {
const [currentText, setCurrentText] = useState('');
const [currentIndex, setCurrentIndex] = useState(0);

useEffect(() => {
if (currentIndex < text.length) {
const timeout = setTimeout(() => {
setCurrentText((prevText) => prevText + text[currentIndex]);
setCurrentIndex((prevIndex) => prevIndex + 1);
}, delay);

return () => clearTimeout(timeout);
}
}, [currentIndex, delay, text]);

return (
<div className={s.markdown}>
<Markdown>{currentText}</Markdown>
</div>
);
};

export default MarkdownComponent;
15 changes: 15 additions & 0 deletions src/modules/l2-rollup-detail/MarkdownComponent/styles.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.markdown {
max-width: inherit;

* {
&::-webkit-scrollbar {
width: 2px;
height: 2px;
}

&::-webkit-scrollbar-thumb {
background: gray;
border-radius: 10px;
}
}
}
8 changes: 4 additions & 4 deletions src/modules/l2-rollup-detail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import TokenTransferTab from './TokenTransferTab';
import TokenTransferTabBitcoin from './TokenTransferTabBitcoin';
import TransactionsTab from './TransactionsTab';
import TransactionsTabBitcoin from './TransactionsTabBitcoin';
import Markdown from 'react-markdown';
import WatchListAddresses from './Watchlist';
import { formatAiSummary } from './utils';
import MarkdownComponent from './MarkdownComponent';

const L2RollupDetail = () => {
const {
Expand Down Expand Up @@ -110,7 +110,7 @@ const L2RollupDetail = () => {
w={{ base: '0px', md: '140px' }}
src={'/heartbeat/ic-wallet.svg'}
/>
<Flex gap="6px" direction={'column'}>
<Flex gap="6px" direction={'column'} w={'100%'}>
<Flex direction={'row'} alignItems={'center'} gap={'8px'}>
<Text fontWeight={'400'} fontSize={'16px'}>
{isMobile ? shortCryptoAddress(address) : address}
Expand Down Expand Up @@ -180,12 +180,12 @@ const L2RollupDetail = () => {
{isLoadingAI ? (
<Flex direction={'row'} alignItems={'center'} gap={'4px'}>
<Text>Analyzing...</Text>
<Skeleton w={'140px'} h={'20px'} speed={1.2} />
<Skeleton w={'120px'} h={'20px'} speed={1.2} />
</Flex>
) : (
<>
{aiSummary && (
<Markdown>{formatAiSummary(aiSummary)}</Markdown>
<MarkdownComponent text={formatAiSummary(aiSummary)} />
)}
</>
)}
Expand Down

0 comments on commit 108604e

Please sign in to comment.