File tree 4 files changed +48
-10
lines changed
4 files changed +48
-10
lines changed Original file line number Diff line number Diff line change
1
+ import { useIntersection } from 'common/hooks/useIntersection' ;
2
+ import { AnimatedGraphIcon } from 'components/Graphics/AnimatedGraphIcon' ;
3
+ import { Text } from 'components/Typography/Text' ;
4
+ import React , { FC } from 'react' ;
5
+
6
+ import styles from './infinite-loading.module.scss' ;
7
+
8
+ interface Props {
9
+ isLoading : boolean ;
10
+ triggerNextPage : ( ) => void ;
11
+ }
12
+
13
+ export const InifiniteLoading : FC < Props > = ( { isLoading, triggerNextPage } ) => {
14
+ const ref = useIntersection ( triggerNextPage ) ;
15
+ return (
16
+ < >
17
+ { isLoading && (
18
+ < div className = { styles . loadingContainer } >
19
+ < AnimatedGraphIcon className = { styles . loadingIcon } />
20
+ < Text > Laster...</ Text >
21
+ </ div >
22
+ ) }
23
+ < span ref = { ref } />
24
+ </ >
25
+ ) ;
26
+ } ;
Original file line number Diff line number Diff line change
1
+ .loadingIcon {
2
+ width : 60px ;
3
+ fill : var (--red );
4
+ margin-bottom : var (--spacing-1 );
5
+ }
6
+
7
+ .loadingContainer {
8
+ margin : var (--spacing-4 ) auto ;
9
+ text-align : center ;
10
+ }
Original file line number Diff line number Diff line change 14
14
15
15
.courseList {
16
16
width : 100% ;
17
+ th ,
18
+ td {
19
+ & :nth-child (1 ),
20
+ & :nth-child (2 ) {
21
+ text-align : left ;
22
+ }
23
+ & :nth-child (3 ) {
24
+ text-align : right ;
25
+ }
26
+ }
17
27
}
18
28
19
29
.loadingIcon {
Original file line number Diff line number Diff line change 1
- import { useIntersection } from 'common/hooks/useIntersection' ;
2
1
import { SearchInput } from 'components/forms/SearchInput' ;
3
- import { AnimatedGraphIcon } from 'components/Graphics/AnimatedGraphIcon ' ;
2
+ import { InifiniteLoading } from 'components/Loading/InfiniteLoading ' ;
4
3
import { Text } from 'components/Typography/Text' ;
5
4
import { Course } from 'models/Course' ;
6
5
import Head from 'next/head' ;
@@ -32,7 +31,6 @@ export const CourseListView: FC<Props> = ({
32
31
resetPages ( ) ;
33
32
onSearchChange ( event . target . value ) ;
34
33
} ;
35
- const ref = useIntersection ( nextPage ) ;
36
34
37
35
return (
38
36
< >
@@ -70,13 +68,7 @@ export const CourseListView: FC<Props> = ({
70
68
</ tbody >
71
69
</ table >
72
70
) : null }
73
- { isLoading && (
74
- < div className = { styles . loadingContainer } >
75
- < AnimatedGraphIcon className = { styles . loadingIcon } />
76
- < Text > Laster...</ Text >
77
- </ div >
78
- ) }
79
- < span ref = { ref } />
71
+ < InifiniteLoading isLoading = { isLoading } triggerNextPage = { nextPage } />
80
72
</ section >
81
73
</ >
82
74
) ;
You can’t perform that action at this time.
0 commit comments