Skip to content

Commit af4376d

Browse files
committed
feat: Add paragon and make the cards nicer looking.
1 parent 0c99db1 commit af4376d

File tree

2 files changed

+43
-14
lines changed

2 files changed

+43
-14
lines changed

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"main": "src/index.jsx",
55
"peerDependencies": {
66
"@edx/frontend-platform": "*",
7+
"@openedx/paragon": "*",
78
"react": "*"
89
}
910
}

frontend/src/plugin.jsx

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import React, { useState, useEffect } from "react";
22
import { getConfig } from "@edx/frontend-platform";
33
import { getAuthenticatedHttpClient } from "@edx/frontend-platform/auth";
4+
import { Card, Container, Row, Col, Badge, Collapsible } from "@openedx/paragon";
45

56
const CourseList = ({ courseListData }) => {
67
const [archivedCourses, setArchivedCourses] = useState(new Set());
78

9+
// Safety check for courseListData
10+
if (!courseListData || !courseListData.visibleList) {
11+
console.log("DEBUG: courseListData not available yet");
12+
return <div>Loading courses...</div>;
13+
}
14+
815
// Extract the "visibleList"
916
const courses = courseListData.visibleList;
1017

@@ -82,29 +89,50 @@ const CourseList = ({ courseListData }) => {
8289
console.log("DEBUG: Active courses count:", activeCourses.length);
8390
console.log("DEBUG: Archived courses count:", archivedCoursesList.length);
8491

85-
const renderCourse = (courseData) => (
86-
<div key={courseData.cardId}>
87-
<h2>
88-
{courseData.course.courseName}
89-
<img
92+
const renderCourse = (courseData, isArchived = false) => (
93+
<Col key={courseData.cardId} xs={12} sm={6} md={4} lg={3} className="mb-4">
94+
<Card>
95+
<Card.ImageCap
9096
src={getConfig().LMS_BASE_URL + courseData.course.bannerImgSrc}
9197
alt={courseData.course.courseName}
92-
></img>
93-
</h2>
94-
</div>
98+
/>
99+
<Card.Header
100+
title={courseData.course.courseName}
101+
subtitle={courseData.course.courseNumber}
102+
actions={isArchived && <Badge variant="secondary">Archived</Badge>}
103+
/>
104+
<Card.Section>
105+
{courseData.course.shortDescription && (
106+
<p className="text-muted small">
107+
{courseData.course.shortDescription}
108+
</p>
109+
)}
110+
</Card.Section>
111+
</Card>
112+
</Col>
95113
);
96114

97115
return (
98-
<div>
99-
{activeCourses.map(renderCourse)}
116+
<Container fluid>
117+
<Row>
118+
{activeCourses.map((courseData) => renderCourse(courseData, false))}
119+
</Row>
100120

101121
{archivedCoursesList.length > 0 && (
102-
<div>
103-
<h2>Archived Courses</h2>
104-
{archivedCoursesList.map(renderCourse)}
122+
<div className="mt-5">
123+
<Collapsible
124+
title={`Archived Courses (${archivedCoursesList.length})`}
125+
defaultOpen={false}
126+
>
127+
<Row>
128+
{archivedCoursesList.map((courseData) =>
129+
renderCourse(courseData, true),
130+
)}
131+
</Row>
132+
</Collapsible>
105133
</div>
106134
)}
107-
</div>
135+
</Container>
108136
);
109137
};
110138

0 commit comments

Comments
 (0)