Skip to content

Commit 8214459

Browse files
authored
Merge pull request #1834 from AletheiaFact/Migrating-lists-from-home
Migrating lists from home
2 parents aad77a1 + 4e318ef commit 8214459

File tree

5 files changed

+52
-104
lines changed

5 files changed

+52
-104
lines changed

src/components/ClaimReview/ReviewsGrid.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,8 @@ const ReviewsGrid = ({ reviews, title }) => {
77
<GridList
88
title={title}
99
dataSource={reviews}
10-
loggedInMaxColumns={2}
10+
loggedInMaxColumns={12}
1111
disableSeeMoreButton={true}
12-
gridLayout={{
13-
xs: 1,
14-
sm: 1,
15-
md: 1,
16-
lg: 1,
17-
}}
1812
renderItem={(review) => <ReviewCard review={review} />}
1913
/>
2014
);

src/components/Debate/DebateGrid.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,7 @@ const DebateGrid = ({ debates }) => {
1818
<GridList
1919
title={"Debates"}
2020
dataSource={debates}
21-
loggedInMaxColumns={1}
22-
gridLayout={{
23-
gutter: 10,
24-
xs: 1,
25-
sm: 1,
26-
md: 1,
27-
lg: 1,
28-
}}
21+
loggedInMaxColumns={6}
2922
disableSeeMoreButton={true}
3023
renderItem={(debateClaim) => {
3124
return (
@@ -63,7 +56,7 @@ const DebateGrid = ({ debates }) => {
6356
>
6457
{debateClaim.personalities.map((p) => {
6558
return (
66-
<Grid item key={p._id} xs={12} md={5.5}>
59+
<Grid item key={p._id} xs={12} sm={5.5}>
6760
<PersonalityMinimalCard
6861
personality={p}
6962
/>

src/components/GridList.tsx

Lines changed: 17 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,39 @@
11
import SectionTitle from "./SectionTitle";
2-
import { Col, List, Row } from "antd";
2+
import { Grid } from "@mui/material";
33
import React from "react";
44
import Button, { ButtonType } from "./Button";
55
import { ArrowForwardOutlined } from "@mui/icons-material";
6-
import { isUserLoggedIn } from "../atoms/currentUser";
7-
import { useAtom } from "jotai";
86

97
const GridList = ({
108
renderItem,
11-
loggedInMaxColumns = 3,
9+
loggedInMaxColumns = 6,
1210
dataSource,
1311
title,
1412
href = "",
1513
dataCy = "",
1614
seeMoreButtonLabel = "",
1715
disableSeeMoreButton = false,
18-
gridLayout = {},
1916
}) => {
20-
const [isLoggedIn] = useAtom(isUserLoggedIn);
21-
const overrideGridLayout = isLoggedIn
22-
? {
23-
xl: loggedInMaxColumns,
24-
xxl: loggedInMaxColumns,
25-
...gridLayout,
26-
}
27-
: {
28-
xl: 2,
29-
xxl: 2,
30-
...gridLayout,
31-
};
3217
return (
3318
<>
3419
<SectionTitle>{title}</SectionTitle>
3520

36-
<Row
37-
style={{
38-
width: "100%",
39-
}}
40-
>
41-
<List
42-
itemLayout="horizontal"
43-
dataSource={dataSource}
44-
style={{ width: "100%" }}
45-
grid={{
46-
gutter: 10,
47-
xs: 1,
48-
sm: 1,
49-
md: loggedInMaxColumns - 1,
50-
lg: 2,
51-
...overrideGridLayout,
52-
}}
53-
renderItem={(item: any) => {
54-
return (
55-
<Col
56-
style={{
57-
display: "flex",
58-
height: "100%",
59-
}}
60-
>
61-
{renderItem(item)}
62-
</Col>
63-
);
64-
}}
65-
/>
66-
</Row>
21+
<Grid container columnSpacing={1}>
22+
{dataSource.map((item) => (
23+
<Grid container
24+
item
25+
xs={12}
26+
md={loggedInMaxColumns}
27+
lg={6}
28+
key={item}
29+
>
30+
{renderItem(item)}
31+
</Grid>
32+
))}
33+
</Grid>
6734

6835
{!disableSeeMoreButton && (
69-
<Col
36+
<Grid item
7037
style={{
7138
display: "flex",
7239
justifyContent: "center",
@@ -87,7 +54,7 @@ const GridList = ({
8754
{seeMoreButtonLabel} <ArrowForwardOutlined fontSize="small"/>
8855
</span>
8956
</Button>
90-
</Col>
57+
</Grid>
9158
)}
9259
</>
9360
);

src/components/Home/HomeFeedList.tsx

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
import React from "react";
2-
import { Col, List } from "antd";
2+
import { Grid, List } from "@mui/material";
33
import PersonalityCard from "../Personality/PersonalityCard";
44
import ClaimCard from "../Claim/ClaimCard";
55
import styled from "styled-components";
66
import ReviewCard from "../ClaimReview/ReviewCard";
77

88
const HomeFeedListStyled = styled(List)`
9-
.ant-spin-nested-loading {
10-
width: 100%;
11-
}
12-
13-
.ant-list-items {
149
display: flex;
1510
flex-wrap: wrap;
1611
gap: 32px;
1712
justify-content: space-between;
18-
}
1913
2014
.item {
2115
display: flex;
@@ -27,39 +21,39 @@ const HomeFeedListStyled = styled(List)`
2721
const HomeFeedList = ({ results }) => {
2822
return (
2923
<HomeFeedListStyled
30-
itemLayout="horizontal"
31-
dataSource={results}
3224
style={{ width: "100%", display: "flex" }}
33-
renderItem={(item) => (
34-
<Col className="item">
35-
{item && item.type === "personality" && (
36-
<PersonalityCard personality={item} summarized={true} />
37-
)}
25+
>
26+
{results?.map((item) => (
27+
<Grid item className="item" key={item}>
28+
{item && item.type === "personality" && (
29+
<PersonalityCard personality={item} summarized={true} />
30+
)}
3831

39-
{item && item.type === "claim" && (
40-
<ClaimCard
41-
personality={item?.personalities[0]}
42-
claim={item}
43-
content={item?.content[0]?.content}
44-
/>
45-
)}
32+
{item && item.type === "claim" && (
33+
<ClaimCard
34+
personality={item?.personalities[0]}
35+
claim={item}
36+
content={item?.content[0]?.content}
37+
/>
38+
)}
4639

47-
{item && item.type === "sentence" && (
48-
<ReviewCard
49-
review={{
50-
personality: item?.personality,
51-
claim: item?.claim,
52-
content: {
53-
content: item.content,
54-
...item,
55-
},
56-
}}
57-
summarized={true}
58-
/>
59-
)}
60-
</Col>
61-
)}
62-
/>
40+
{item && item.type === "sentence" && (
41+
<ReviewCard
42+
review={{
43+
personality: item?.personality,
44+
claim: item?.claim,
45+
content: {
46+
content: item.content,
47+
...item,
48+
},
49+
}}
50+
summarized={true}
51+
/>
52+
)}
53+
</Grid>
54+
))
55+
}
56+
</HomeFeedListStyled>
6357
);
6458
};
6559

src/components/Personality/PersonalitiesGrid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const PersonalitiesGrid = ({ personalities, title }) => {
1919
<GridList
2020
title={title}
2121
dataSource={personalities}
22-
loggedInMaxColumns={2}
22+
loggedInMaxColumns={6}
2323
href={href}
2424
dataCy="testSeeMorePersonality"
2525
seeMoreButtonLabel={t("home:seeMorePersonalitiesButton")}

0 commit comments

Comments
 (0)