Skip to content

Commit c117758

Browse files
authored
units page fixes (#1083)
* update background color to lightGray1 * use Card and not MuiCard * remove link={true} property on Card * style the cards on the units listing page with height: 100% so that the cards are all even height, regardless of the content of other cards in the grid
1 parent 3c24da1 commit c117758

File tree

1 file changed

+46
-46
lines changed

1 file changed

+46
-46
lines changed

frontends/mit-open/src/pages/UnitsListingPage/UnitsListingPage.tsx

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import {
44
} from "api/hooks/learningResources"
55
import {
66
Banner,
7-
MuiCard,
8-
CardContent,
7+
Card,
98
Container,
10-
Link,
119
Skeleton,
1210
Typography,
1311
styled,
@@ -55,7 +53,7 @@ const sortUnits = (
5553
}
5654

5755
const Page = styled.div(({ theme }) => ({
58-
backgroundColor: theme.custom.colors.white,
56+
backgroundColor: theme.custom.colors.lightGray1,
5957
}))
6058

6159
const PageContent = styled.div(({ theme }) => ({
@@ -93,6 +91,10 @@ const PageHeaderText = styled(Typography)(({ theme }) => ({
9391
...theme.typography.subtitle1,
9492
}))
9593

94+
const CardStyled = styled(Card)({
95+
height: "100%",
96+
})
97+
9698
const UnitContainer = styled.div(({ theme }) => ({
9799
display: "flex",
98100
flexDirection: "column",
@@ -149,23 +151,15 @@ const GridContainer = styled.div(({ theme }) => ({
149151
},
150152
}))
151153

152-
const UnitCardContainer = styled(MuiCard)({
154+
const UnitCardContainer = styled.div({
153155
display: "flex",
154156
flexDirection: "column",
155157
alignItems: "center",
158+
padding: "16px",
159+
height: "100%",
156160
})
157161

158-
const UnitCardLink = styled(Link)({
159-
display: "flex",
160-
flexDirection: "column",
161-
alignItems: "center",
162-
flexGrow: 1,
163-
"&:hover": {
164-
textDecoration: "none",
165-
},
166-
})
167-
168-
const UnitCardContent = styled(CardContent)({
162+
const UnitCardContent = styled.div({
169163
display: "flex",
170164
flexDirection: "column",
171165
flexGrow: 1,
@@ -318,41 +312,47 @@ const UnitCard: React.FC<UnitCardProps> = (props) => {
318312
return channelDetailQuery.isLoading ? (
319313
<UnitCardLoading />
320314
) : (
321-
<UnitCardContainer>
322-
<UnitCardLink href={unitUrl}>
323-
<UnitCardContent>
324-
<LogoContainer>
325-
<UnitLogo src={logo} alt={unit.name} />
326-
</LogoContainer>
327-
<ValuePropContainer>
328-
<ValuePropText>{unit.value_prop}</ValuePropText>
329-
</ValuePropContainer>
330-
<CountsTextContainer>
331-
<CountsText data-testid={`course-count-${unit.code}`}>
332-
{courseCount > 0 ? `Courses: ${courseCount}` : ""}
333-
</CountsText>
334-
<CountsText data-testid={`program-count-${unit.code}`}>
335-
{programCount > 0 ? `Programs: ${programCount}` : ""}
336-
</CountsText>
337-
</CountsTextContainer>
338-
</UnitCardContent>
339-
</UnitCardLink>
340-
</UnitCardContainer>
315+
<CardStyled href={unitUrl}>
316+
<Card.Content>
317+
<UnitCardContainer>
318+
<UnitCardContent>
319+
<LogoContainer>
320+
<UnitLogo src={logo} alt={unit.name} />
321+
</LogoContainer>
322+
<ValuePropContainer>
323+
<ValuePropText>{unit.value_prop}</ValuePropText>
324+
</ValuePropContainer>
325+
<CountsTextContainer>
326+
<CountsText data-testid={`course-count-${unit.code}`}>
327+
{courseCount > 0 ? `Courses: ${courseCount}` : ""}
328+
</CountsText>
329+
<CountsText data-testid={`program-count-${unit.code}`}>
330+
{programCount > 0 ? `Programs: ${programCount}` : ""}
331+
</CountsText>
332+
</CountsTextContainer>
333+
</UnitCardContent>
334+
</UnitCardContainer>
335+
</Card.Content>
336+
</CardStyled>
341337
)
342338
}
343339

344340
const UnitCardLoading = () => {
345341
return (
346-
<UnitCardContainer>
347-
<UnitCardContent>
348-
<LogoContainer>
349-
<Skeleton variant="rectangular" width={500} height={50} />
350-
</LogoContainer>
351-
<ValuePropContainer>
352-
<Skeleton variant="text" width={500} height={200} />
353-
</ValuePropContainer>
354-
</UnitCardContent>
355-
</UnitCardContainer>
342+
<Card>
343+
<Card.Content>
344+
<UnitCardContainer>
345+
<UnitCardContent>
346+
<LogoContainer>
347+
<Skeleton variant="rectangular" width={500} height={50} />
348+
</LogoContainer>
349+
<ValuePropContainer>
350+
<Skeleton variant="text" width={500} height={200} />
351+
</ValuePropContainer>
352+
</UnitCardContent>
353+
</UnitCardContainer>
354+
</Card.Content>
355+
</Card>
356356
)
357357
}
358358

0 commit comments

Comments
 (0)