Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

24T3 Lectures and Tutorials UI improvements #30

Merged
merged 24 commits into from
Oct 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Seperate the weeks
sofiadebellis committed Oct 5, 2024
commit 9553c148703068acd0560b9abc3825d3027ed76c
116 changes: 81 additions & 35 deletions frontend/src/page/Content/ContentLecturesSearch.jsx
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ import InfoIcon from "@mui/icons-material/Info";
const ContentLecturesSearch = () => {
const { getters, setters } = useContext(Context);
const { content_lectures, weeks, topics } = getters.content;
console.log(content_lectures)
console.log(content_lectures);

const [searchQuery, setSearchQuery] = useState("");
const [week, setWeek] = useState("All");
@@ -173,11 +173,13 @@ const ContentLecturesSearch = () => {
label="Week"
>
<MenuItem value="All">All</MenuItem>
{weeks.map((week) => (
<MenuItem key={week.week} value={week.week}>
{week.week}
</MenuItem>
))}
{weeks
.filter((week) => week.week !== 6)
.map((week) => (
<MenuItem key={week.week} value={week.week}>
{week.week}
</MenuItem>
))}
</Select>
</FormControl>
<FormControl>
@@ -325,35 +327,79 @@ const ContentLecturesSearch = () => {
</Box>
</Modal>

<Box
sx={{
display: "grid",
gridTemplateColumns: {
xs: "repeat(1, 1fr)",
sm: "repeat(2, 1fr)",
lg: "repeat(3, 1fr)",
xl: "repeat(4, 1fr)",
},
gap: 2,
mt: 3,
}}
>
{filteredLectures.map((lecture, index) => (
<div key={index}>
<TutLecContentCard
contentKey={lecture.key}
name={lecture.name}
duration_mins={lecture.duration_mins}
relevance={lecture.relevance}
week={lecture.week().week}
topicEmoji={lecture.topic().emoji}
topicName={lecture.topic().name}
live={lecture.status}
lecture={true}
thumbnail={lecture.thumbnail && lecture.thumbnail.length > 0 ? lecture.thumbnail[0] : null}
/>
</div>
))}
<Box sx={{ mt: 3 }}>
{weeks.map((weekObj) => {
const lecturesForWeek = filteredLectures.filter(
(lecture) => lecture.week().week === weekObj.week
);

if (lecturesForWeek.length === 0) return null;

return (
<React.Fragment key={weekObj.week}>
<Box
sx={{
display: "flex",
alignItems: "center",
width: "100%",
mt: 4,
mb: 2,
}}
>
<hr
style={{
flexGrow: 1,
borderTop: "1px solid #ccc",
margin: 0,
}}
/>
<Box sx={{ px: 2, whiteSpace: "nowrap", fontWeight: "bold" }}>
Week {weekObj.week}
</Box>
<hr
style={{
flexGrow: 1,
borderTop: "1px solid #ccc",
margin: 0,
}}
/>
</Box>

<Box
sx={{
display: "grid",
gridTemplateColumns: {
xs: "repeat(1, 1fr)",
sm: "repeat(2, 1fr)",
lg: "repeat(3, 1fr)",
xl: "repeat(4, 1fr)",
},
gap: 2,
}}
>
{lecturesForWeek.map((lecture) => (
<TutLecContentCard
key={lecture.key}
contentKey={lecture.key}
name={lecture.name}
duration_mins={lecture.duration_mins}
relevance={lecture.relevance}
week={lecture.week().week}
topicEmoji={lecture.topic().emoji}
topicName={lecture.topic().name}
live={lecture.status}
lecture={true}
thumbnail={
lecture.thumbnail && lecture.thumbnail.length > 0
? lecture.thumbnail[0]
: null
}
/>
))}
</Box>
</React.Fragment>
);
})}
</Box>
</>
);
99 changes: 66 additions & 33 deletions frontend/src/page/Content/ContentTutorialsSearch.jsx
Original file line number Diff line number Diff line change
@@ -146,11 +146,13 @@ const ContentTutorialsSearch = () => {
label="Week"
>
<MenuItem value="All">All</MenuItem>
{weeks.map((week) => (
<MenuItem key={week.week} value={week.week}>
{week.week}
</MenuItem>
))}
{weeks
.filter((week) => week.week !== 6)
.map((week) => (
<MenuItem key={week.week} value={week.week}>
{week.week}
</MenuItem>
))}
</Select>
</FormControl>
<FormControl>
@@ -247,34 +249,65 @@ const ContentTutorialsSearch = () => {
</Box>
</Modal>

<Box
sx={{
display: "grid",
gridTemplateColumns: {
xs: "repeat(1, 1fr)",
sm: "repeat(2, 1fr)",
lg: "repeat(3, 1fr)",
xl: "repeat(4, 1fr)",
},
gap: 2,
mt: 3,
}}
>
{filteredTutorials.map((tutorial, index) => (
<div key={index}>
<TutLecContentCard
contentKey={tutorial.key}
name={tutorial.name}
duration_mins={tutorial.duration}
relevance={tutorial.importance.split(" ")[1]}
week={tutorial.week().week}
topicEmoji={tutorial.topic().emoji}
topicName={tutorial.topic().name}
live={""}
lecture={false}
/>
</div>
))}
<Box sx={{ mt: 3 }}>
{weeks.map((weekObj) => {
const tutorialsForWeek = filteredTutorials.filter(
(tutorial) => tutorial.week().week === weekObj.week
);

if (tutorialsForWeek.length === 0) return null;

return (
<React.Fragment key={weekObj.week}>
<Box
sx={{
display: "flex",
alignItems: "center",
width: "100%",
mt: 4,
mb: 2,
}}
>
<hr
style={{
flexGrow: 1,
borderTop: "1px solid #ccc",
margin: 0,
}}
/>
<Box sx={{ px: 2, whiteSpace: "nowrap", fontWeight: "bold" }}>
Week {weekObj.week}
</Box>
<hr
style={{
flexGrow: 1,
borderTop: "1px solid #ccc",
margin: 0,
}}
/>
</Box>
<Box
display="grid"
gridTemplateColumns="repeat(auto-fill, minmax(300px, 1fr))"
gap={3}
>
{tutorialsForWeek.map((tutorial) => (
<TutLecContentCard
contentKey={tutorial.key}
name={tutorial.name}
duration_mins={tutorial.duration}
relevance={tutorial.importance.split(" ")[1]}
week={tutorial.week().week}
topicEmoji={tutorial.topic().emoji}
topicName={tutorial.topic().name}
live={""}
lecture={false}
/>
))}
</Box>
</React.Fragment>
);
})}
</Box>
</>
);