generated from stacks-network/.github
-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,528 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/app/_components/BlockList/LayoutA/BlockListWithControls.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from 'react'; | ||
|
||
import { ListFooter } from '../../../../common/components/ListFooter'; | ||
import { Section } from '../../../../common/components/Section'; | ||
import { Box } from '../../../../ui/Box'; | ||
import { Controls } from '../Controls'; | ||
import { UIBlock } from '../types'; | ||
import { Blocks } from './Blocks'; | ||
import { UpdateBar } from './UpdateBar'; | ||
import { useBlockListContext } from './context'; | ||
|
||
export function BlockListWithControls({ | ||
blockList, | ||
latestBlocksCount, | ||
updateList, | ||
enablePagination, | ||
isFetchingNextPage, | ||
hasNextPage, | ||
fetchNextPage, | ||
horizontalControls, | ||
}: { | ||
blockList: UIBlock[]; | ||
latestBlocksCount: number; | ||
updateList: () => void; | ||
enablePagination?: boolean; | ||
isFetchingNextPage?: boolean; | ||
hasNextPage?: boolean; | ||
fetchNextPage?: () => void; | ||
horizontalControls?: boolean; | ||
}) { | ||
const { fadeEffect, setFadeEffect, groupedByBtc, setGroupedByBtc, liveUpdates, setLiveUpdates } = | ||
useBlockListContext(); | ||
return ( | ||
<Section title="Recent Blocks"> | ||
<Box pb={6}> | ||
<Controls | ||
groupByBtc={{ | ||
onChange: () => { | ||
setGroupedByBtc(!groupedByBtc); | ||
}, | ||
isChecked: groupedByBtc, | ||
isDisabled: true, | ||
}} | ||
liveUpdates={{ | ||
onChange: () => setLiveUpdates(!liveUpdates), | ||
isChecked: liveUpdates, | ||
}} | ||
horizontal={horizontalControls} | ||
/> | ||
{!liveUpdates && ( | ||
<UpdateBar | ||
fadeEffect={fadeEffect} | ||
latestBlocksCount={latestBlocksCount} | ||
onClick={updateList} | ||
/> | ||
)} | ||
<Blocks blockList={blockList} fadeEffect={fadeEffect} /> | ||
<Box pt={4}> | ||
{(!liveUpdates || !enablePagination) && ( | ||
<ListFooter | ||
isLoading={isFetchingNextPage} | ||
hasNextPage={hasNextPage} | ||
fetchNextPage={fetchNextPage} | ||
label={'blocks'} | ||
/> | ||
)} | ||
</Box> | ||
</Box> | ||
</Section> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from 'react'; | ||
|
||
import { Icon } from '../../../../ui/Icon'; | ||
import { Stack } from '../../../../ui/Stack'; | ||
import { StxIcon } from '../../../../ui/icons'; | ||
import { UIBlock, UIBlockType } from '../types'; | ||
import { BlockCount } from './BlockCount'; | ||
import { BurnBlock } from './BurnBlock'; | ||
import { StxBlock } from './StxBlock'; | ||
import { FADE_DURATION } from './consts'; | ||
|
||
export function Blocks({ blockList, fadeEffect }: { blockList: UIBlock[]; fadeEffect: boolean }) { | ||
return ( | ||
<Stack | ||
pl={4} | ||
pr={2} | ||
gap={0} | ||
width={'full'} | ||
style={{ | ||
transition: `opacity ${FADE_DURATION / 1000}s`, | ||
opacity: fadeEffect ? 0 : 1, | ||
}} | ||
> | ||
{blockList.map((block, i) => { | ||
switch (block.type) { | ||
case UIBlockType.Block: | ||
return ( | ||
<StxBlock | ||
key={block.hash} | ||
hash={block.hash} | ||
height={block.height} | ||
timestamp={block.timestamp} | ||
txsCount={block.txsCount} | ||
icon={ | ||
i === 0 || (i > 0 && blockList[i - 1].type === UIBlockType.BurnBlock) ? ( | ||
<Icon as={StxIcon} size={2.5} color={'white'} /> | ||
) : undefined | ||
} | ||
/> | ||
); | ||
case UIBlockType.BurnBlock: | ||
return ( | ||
<BurnBlock | ||
key={block.hash} | ||
hash={block.hash} | ||
height={block.height} | ||
timestamp={block.timestamp} | ||
/> | ||
); | ||
case UIBlockType.Count: | ||
return <BlockCount key={block.count} count={block.count} />; | ||
} | ||
})} | ||
</Stack> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
'use client'; | ||
|
||
import React, { useCallback, useState } from 'react'; | ||
|
||
import { ListFooter } from '../../../../common/components/ListFooter'; | ||
import { Section } from '../../../../common/components/Section'; | ||
import { Box } from '../../../../ui/Box'; | ||
import { Icon } from '../../../../ui/Icon'; | ||
import { Stack } from '../../../../ui/Stack'; | ||
import { StxIcon } from '../../../../ui/icons'; | ||
import { ExplorerErrorBoundary } from '../../ErrorBoundary'; | ||
import { Controls } from '../Controls'; | ||
import { UIBlockType } from '../types'; | ||
import { BlockCount } from './BlockCount'; | ||
import { BlockListWithControls } from './BlockListWithControls'; | ||
import { BurnBlock } from './BurnBlock'; | ||
import { BlockListProvider } from './Provider'; | ||
import { StxBlock } from './StxBlock'; | ||
import { UpdateBar } from './UpdateBar'; | ||
import { useBlockListContext } from './context'; | ||
import { useBlockList } from './useBlockList'; | ||
|
||
const LIST_LENGTH = 17; | ||
|
||
function NonPaginatedBlockListLayoutABase() { | ||
const { blockList, updateList, latestBlocksCount } = useBlockList(LIST_LENGTH); | ||
|
||
return ( | ||
<BlockListWithControls | ||
blockList={blockList} | ||
latestBlocksCount={latestBlocksCount} | ||
updateList={updateList} | ||
/> | ||
); | ||
} | ||
|
||
export function NonPaginatedBlockListLayoutA() { | ||
return ( | ||
<ExplorerErrorBoundary | ||
Wrapper={Section} | ||
wrapperProps={{ | ||
title: 'Recent Blocks', | ||
gridColumnStart: ['1', '1', '2'], | ||
gridColumnEnd: ['2', '2', '3'], | ||
minWidth: 0, | ||
}} | ||
tryAgainButton | ||
> | ||
<BlockListProvider> | ||
<NonPaginatedBlockListLayoutABase /> | ||
</BlockListProvider> | ||
</ExplorerErrorBoundary> | ||
); | ||
} |
Oops, something went wrong.