-
Notifications
You must be signed in to change notification settings - Fork 23
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
1 parent
6cfe13d
commit e0fafee
Showing
89 changed files
with
5,543 additions
and
437 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,77 @@ | ||
import { | ||
ReactElement, | ||
ReactNode, | ||
} from 'react' | ||
|
||
import InfiniteScroll from 'react-infinite-scroller' | ||
|
||
interface Pagination { | ||
offset: number, | ||
first: number, | ||
count: number, | ||
} | ||
|
||
interface InfiniteScrollProps { | ||
onPaginationChange?: (pagination: Pagination)=>void, | ||
pagination?: Pagination, | ||
children: ReactNode, | ||
threshold?: number, | ||
scrollNode?: HTMLElement, | ||
loader?: ReactElement, | ||
isLoading: boolean, | ||
allCount: number, | ||
} | ||
|
||
export const B3InfiniteScroll = (props: InfiniteScrollProps) => { | ||
const { | ||
pagination: { | ||
offset = 0, | ||
first = 10, | ||
count = 20, | ||
} = {}, | ||
onPaginationChange = () => {}, | ||
children, | ||
threshold = 250, | ||
scrollNode, | ||
loader, | ||
isLoading, | ||
allCount = 0, | ||
} = props | ||
|
||
const handleLoadMore = () => { | ||
if (!isLoading) { | ||
onPaginationChange({ | ||
offset: offset + first, | ||
first, | ||
count, | ||
}) | ||
} | ||
} | ||
const page = Math.floor((offset / first) + 1) | ||
const getScrollParent = scrollNode ? () => scrollNode : undefined | ||
|
||
return ( | ||
<div | ||
style={scrollNode ? {} : { | ||
overflow: 'auto', | ||
}} | ||
> | ||
<InfiniteScroll | ||
pageStart={page} | ||
loadMore={handleLoadMore} | ||
hasMore={offset + first < count} | ||
loader={isLoading ? (loader || ( | ||
<div> | ||
Loading ... | ||
</div> | ||
)) : <></>} | ||
getScrollParent={getScrollParent} | ||
threshold={threshold} | ||
initialLoad={false} | ||
useWindow={false} | ||
> | ||
{ children } | ||
</InfiniteScroll> | ||
</div> | ||
) | ||
} |
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,36 @@ | ||
import { | ||
DataUsageRounded, | ||
} from '@mui/icons-material' | ||
|
||
import styled from '@emotion/styled' | ||
|
||
interface B3NoDataProps { | ||
text?: string | ||
backgroundColor?: string | ||
} | ||
|
||
const NoDataContainer = styled('div')(({ | ||
backgroundColor = '#fff', | ||
}: B3NoDataProps) => ({ | ||
height: '100%', | ||
backgroundColor, | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
color: '#aaa', | ||
fontSize: '18px', | ||
})) | ||
|
||
const NoDataText = styled('span')(() => ({ | ||
marginLeft: '10px', | ||
})) | ||
|
||
export const B3NoData = ({ | ||
text, | ||
backgroundColor, | ||
}: B3NoDataProps) => ( | ||
<NoDataContainer backgroundColor={backgroundColor}> | ||
<DataUsageRounded fontSize="large" /> | ||
<NoDataText>{text || 'No Data'}</NoDataText> | ||
</NoDataContainer> | ||
) |
Oops, something went wrong.