@@ -5,57 +5,42 @@ import {Button, Col, Container, Row} from "reactstrap";
5
5
import { NewsCarousel } from "../../elements/NewsCarousel" ;
6
6
import { above , SITE_TITLE , useDeviceSize , useUserConsent } from "../../../services" ;
7
7
import { HomepageYoutubeCookieHandler } from "../../handlers/InterstitialCookieHandler" ;
8
- import { ListViewCard } from "../../elements/list-groups/ListView" ;
8
+ import { ListViewCardProps , ListViewCards } from "../../elements/list-groups/ListView" ;
9
9
import { ShortcutResponse , Subject } from "../../../../IsaacAppTypes" ;
10
10
import { ListViewTagProps } from "../../elements/list-groups/AbstractListViewItem" ;
11
11
import { StudentDashboard } from "../../elements/StudentDashboard" ;
12
12
13
- const getSubjectTags : { [ key in Subject ] : ListViewTagProps [ ] } = {
14
- physics : [ { tag : "11-14" , url : "physics/11_14" } , { tag : "GCSE" , url : "physics/gcse" } , { tag : "A-Level" , url : "physics/a_level" } , { tag : "University" , url : "physics/university" } ] ,
15
- maths : [ { tag : "GCSE" , url : "maths/gcse" } , { tag : "A-Level" , url : "maths/a_level" } , { tag : "University" , url : "maths/university" } ] ,
16
- chemistry : [ { tag : "GCSE" , url : "chemistry/gcse" } , { tag : "A-Level" , url : "chemistry/a_level" } ] ,
17
- biology : [ { tag : "A-Level" , url : "biology/a_level" } ] ,
18
- } ;
19
-
20
- const ListViewSubjectCard = ( { subject} : { subject : Subject } ) => {
21
- const item : ShortcutResponse = {
22
- title : subject . charAt ( 0 ) . toUpperCase ( ) + subject . slice ( 1 ) ,
23
- subtitle : "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris faucibus est vulputate augue tristique, sed vehicula turpis pellentesque." ,
24
- } ;
25
- const tags = getSubjectTags [ subject ] ;
26
-
27
- return < ListViewCard
28
- item = { item }
29
- subject = { subject }
30
- icon = { { type : "img" , icon : `/assets/phy/icons/redesign/subject-${ subject } .svg` } }
31
- tagList = { tags }
32
- /> ;
33
- } ;
34
-
35
- const a = < div style = { { borderRadius : "10px" , border : "1px solid rgb(236, 236, 236)" , background :"white" } } >
36
- < Row className = "w-100 link-list list-group-links ms-0 border-0" >
37
- < Col xs = { 6 } style = { { borderRight : "2px solid #ececec" , borderBottom : "2px solid #ececec" } } >
38
- < ListViewSubjectCard subject = "physics" />
39
- </ Col >
40
- < Col xs = { 6 } style = { { borderBottom : "2px solid #ececec" } } >
41
- < ListViewSubjectCard subject = "maths" />
42
- </ Col >
43
- </ Row >
44
- < Row className = "w-100 link-list list-group-links ms-0 border-0" >
45
- < Col xs = { 6 } style = { { borderRight : "2px solid #ececec" } } >
46
- < ListViewSubjectCard subject = "chemistry" /> </ Col >
47
- < Col xs = { 6 } >
48
- < ListViewSubjectCard subject = "biology" />
49
- </ Col >
50
- </ Row >
51
- </ div > ;
52
-
53
13
export const HomepagePhy = ( ) => {
54
14
useEffect ( ( ) => { document . title = SITE_TITLE ; } , [ ] ) ;
55
15
const { data : news } = useGetNewsPodListQuery ( { subject : "physics" } ) ;
56
16
const user = useAppSelector ( selectors . user . orNull ) ;
57
17
const deviceSize = useDeviceSize ( ) ;
58
18
const userConsent = useUserConsent ( ) ;
19
+ const subjectList : Subject [ ] = [ "physics" , "maths" , "chemistry" , "biology" ] ;
20
+ const subjectTags : { [ key in Subject ] : ListViewTagProps [ ] } = {
21
+ physics : [ { tag : "11-14" , url : "physics/11_14" } , { tag : "GCSE" , url : "physics/gcse" } , { tag : "A-Level" , url : "physics/a_level" } , { tag : "University" , url : "physics/university" } ] ,
22
+ maths : [ { tag : "GCSE" , url : "maths/gcse" } , { tag : "A-Level" , url : "maths/a_level" } , { tag : "University" , url : "maths/university" } ] ,
23
+ chemistry : [ { tag : "GCSE" , url : "chemistry/gcse" } , { tag : "A-Level" , url : "chemistry/a_level" } ] ,
24
+ biology : [ { tag : "A-Level" , url : "biology/a_level" } ] ,
25
+ } ;
26
+
27
+ const getListViewSubjectCard = ( { subject} : { subject : Subject } ) => {
28
+ const item : ShortcutResponse = {
29
+ title : subject . charAt ( 0 ) . toUpperCase ( ) + subject . slice ( 1 ) ,
30
+ subtitle : "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris faucibus est vulputate augue tristique, sed vehicula turpis pellentesque." ,
31
+ } ;
32
+
33
+ const listViewSubjectCard : ListViewCardProps = {
34
+ item : item ,
35
+ icon : { type : "img" , icon : `/assets/phy/icons/redesign/subject-${ subject } .svg` } ,
36
+ subject : subject ,
37
+ tagList : subjectTags [ subject ] ,
38
+ } ;
39
+
40
+ return listViewSubjectCard ;
41
+ } ;
42
+
43
+ const cards = subjectList . map ( ( subject : Subject ) => getListViewSubjectCard ( { subject} ) ) ;
59
44
60
45
return < >
61
46
{ /*<WarningBanner/>*/ }
@@ -132,7 +117,7 @@ export const HomepagePhy = () => {
132
117
< section id = "navigation-cards" >
133
118
< Container >
134
119
< h2 > Explore and learn!</ h2 >
135
- { a }
120
+ < ListViewCards cards = { cards } />
136
121
</ Container >
137
122
</ section >
138
123
0 commit comments