Skip to content

Commit a914efa

Browse files
authored
Merge pull request #68 from dotkom/fix/course-list-align
fix(course-list): align table and split out infinite loading icon
2 parents 9e1b732 + ef5cd36 commit a914efa

File tree

4 files changed

+48
-10
lines changed

4 files changed

+48
-10
lines changed
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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 numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
}

views/CourseListView/course-list-view.module.scss

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414

1515
.courseList {
1616
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+
}
1727
}
1828

1929
.loadingIcon {

views/CourseListView/index.tsx

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { useIntersection } from 'common/hooks/useIntersection';
21
import { SearchInput } from 'components/forms/SearchInput';
3-
import { AnimatedGraphIcon } from 'components/Graphics/AnimatedGraphIcon';
2+
import { InifiniteLoading } from 'components/Loading/InfiniteLoading';
43
import { Text } from 'components/Typography/Text';
54
import { Course } from 'models/Course';
65
import Head from 'next/head';
@@ -32,7 +31,6 @@ export const CourseListView: FC<Props> = ({
3231
resetPages();
3332
onSearchChange(event.target.value);
3433
};
35-
const ref = useIntersection(nextPage);
3634

3735
return (
3836
<>
@@ -70,13 +68,7 @@ export const CourseListView: FC<Props> = ({
7068
</tbody>
7169
</table>
7270
) : 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} />
8072
</section>
8173
</>
8274
);

0 commit comments

Comments
 (0)