-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add infinite scroll functionality with loading indicator to Scroll co…
…mponent
- Loading branch information
Showing
6 changed files
with
119 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import React from 'react'; | ||
import { HeadersProvider } from './Scroll.provider'; | ||
import { ScrollList } from './ScrollList'; | ||
import type { HeaderBehavior, Items, StickTo } from './types'; | ||
import type { HeaderBehavior, Items, Loading, StickTo } from './types'; | ||
|
||
interface IScrollProps { | ||
stickTo?: StickTo; | ||
scrollBehavior?: ScrollBehavior; | ||
headerBehavior?: HeaderBehavior; | ||
items: Items; | ||
loading?: Loading; | ||
} | ||
|
||
export const Scroll: React.FC<IScrollProps> = ({ stickTo, scrollBehavior, headerBehavior, items }) => { | ||
export const Scroll: React.FC<IScrollProps> = ({ stickTo, scrollBehavior, headerBehavior, loading, items }) => { | ||
return ( | ||
<HeadersProvider headerBehavior={headerBehavior} stickTo={stickTo} scrollBehavior={scrollBehavior}> | ||
<ScrollList items={items} /> | ||
<ScrollList loading={loading} items={items} /> | ||
</HeadersProvider> | ||
); | ||
}; |
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,11 @@ | ||
import React from 'react'; | ||
|
||
interface IScrollLoadingProps { | ||
loading: boolean; | ||
} | ||
|
||
export const ScrollLoading: React.FC<IScrollLoadingProps> = ({ loading }) => { | ||
if (!loading) return null; | ||
|
||
return <li role="listitem" aria-label="Scroll Loading" className={`scroll-loading ${loading ? 'loading' : ''}`}></li>; | ||
}; |
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