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

Cornellians Say Frontend #484

Merged
merged 5 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
17 changes: 17 additions & 0 deletions client/public/cornellians_say_bear.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions client/src/modules/Course/Components/CornelliansSay.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import styles from '../Styles/CornelliansSay.module.css';
import Bear from '/cornellians_say_bear.svg';

/**
* Component for Cornellians Say. Only appears on courses that have at least 3 reviews
* and a valid summary generated.
*/
type SummaryProps = {
classSummary: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of not showing the CornelliansSay box if there isn't a course summary, we could have a default message that appears?

summaryTags: Map<string, [string, string]>;
}
const CornelliansSay = ({ classSummary, summaryTags }: SummaryProps) => {
const summaryTagsMap = new Map(Object.entries(summaryTags));

Check warning on line 14 in client/src/modules/Course/Components/CornelliansSay.tsx

View workflow job for this annotation

GitHub Actions / build

'summaryTagsMap' is assigned a value but never used

Check warning on line 14 in client/src/modules/Course/Components/CornelliansSay.tsx

View workflow job for this annotation

GitHub Actions / build

'summaryTagsMap' is assigned a value but never used

Check warning on line 14 in client/src/modules/Course/Components/CornelliansSay.tsx

View workflow job for this annotation

GitHub Actions / build

'summaryTagsMap' is assigned a value but never used

Check warning on line 14 in client/src/modules/Course/Components/CornelliansSay.tsx

View workflow job for this annotation

GitHub Actions / build

'summaryTagsMap' is assigned a value but never used
return (
<div className={styles.container}>
<div className={styles.header}>
<img src={Bear} alt="Bear Icon" className={styles.bearIcon} />
<h1 className={styles.title}>Cornellians Say</h1>
</div>
<p className={styles.summary}>{classSummary}</p>
<h2 className={styles.tagsTitle}>Top Tags</h2>
leihelen marked this conversation as resolved.
Show resolved Hide resolved
{/* map each tag into a div displaying each key/category with its
corresponding adjective and applies the corresponding style for the
adjective's connotation */}
<div className={styles.tagsContainer}>
{Array.from(summaryTags.entries()).map(([category, [adjective, connotation]]) => (
<div
key={category}
className={`${styles.tag} ${connotation === "positive"
? styles.positiveTag
: connotation === "negative"
? styles.negativeTag
: styles.neutralTag
}`}
>
{adjective} {category}
</div>
))}
</div>
</div>
);
};
export default CornelliansSay
109 changes: 61 additions & 48 deletions client/src/modules/Course/Components/Course.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import { lastOfferedSems } from 'common/CourseCard';

import Gauges from './Gauges';
import CornelliansSay from './CornelliansSay';
import CourseReviews from './CourseReviews';

import type { NewReview } from '../../../types';
Expand All @@ -26,10 +27,10 @@

import ReviewModal from './ReviewModal';

enum PageStatus {

Check warning on line 30 in client/src/modules/Course/Components/Course.tsx

View workflow job for this annotation

GitHub Actions / build

'PageStatus' is already declared in the upper scope on line 30 column 6

Check warning on line 30 in client/src/modules/Course/Components/Course.tsx

View workflow job for this annotation

GitHub Actions / build

'PageStatus' is defined but never used

Check warning on line 30 in client/src/modules/Course/Components/Course.tsx

View workflow job for this annotation

GitHub Actions / build

'PageStatus' is already declared in the upper scope on line 30 column 6

Check warning on line 30 in client/src/modules/Course/Components/Course.tsx

View workflow job for this annotation

GitHub Actions / build

'PageStatus' is defined but never used
Loading,

Check warning on line 31 in client/src/modules/Course/Components/Course.tsx

View workflow job for this annotation

GitHub Actions / build

'Loading' is already declared in the upper scope on line 12 column 8

Check warning on line 31 in client/src/modules/Course/Components/Course.tsx

View workflow job for this annotation

GitHub Actions / build

'Loading' is defined but never used

Check warning on line 31 in client/src/modules/Course/Components/Course.tsx

View workflow job for this annotation

GitHub Actions / build

'Loading' is already declared in the upper scope on line 12 column 8

Check warning on line 31 in client/src/modules/Course/Components/Course.tsx

View workflow job for this annotation

GitHub Actions / build

'Loading' is defined but never used
Success,

Check warning on line 32 in client/src/modules/Course/Components/Course.tsx

View workflow job for this annotation

GitHub Actions / build

'Success' is defined but never used

Check warning on line 32 in client/src/modules/Course/Components/Course.tsx

View workflow job for this annotation

GitHub Actions / build

'Success' is defined but never used
Error

Check warning on line 33 in client/src/modules/Course/Components/Course.tsx

View workflow job for this annotation

GitHub Actions / build

'Error' is defined but never used

Check warning on line 33 in client/src/modules/Course/Components/Course.tsx

View workflow job for this annotation

GitHub Actions / build

'Error' is defined but never used
}

export const Course = () => {
Expand Down Expand Up @@ -218,62 +219,74 @@
{/* Course Name, Button + Gauges */}
<div className={styles.leftPanel}>
<div className={styles.classinfo}>
<h1
data-cy={`course-title-${selectedClass.classSub.toLowerCase()}-${
selectedClass.classNum
<h1
data-cy={`course-title-${selectedClass.classSub.toLowerCase()}-${selectedClass.classNum
}`}
>
{selectedClass.classTitle}
</h1>
<div className={styles.subtitle}>
{selectedClass.classSub.toUpperCase() +
' ' +
selectedClass.classNum +
', ' +
lastOfferedSems(selectedClass)}
</div>
<button
data-cy="leave-review-button"
className={styles.reviewbutton}
onClick={() => setOpen(true)}
>
Leave a review
</button>
>
{selectedClass.classTitle}
</h1>
<div className={styles.subtitle}>
{selectedClass.classSub.toUpperCase() +
' ' +
selectedClass.classNum +
', ' +
lastOfferedSems(selectedClass)}
</div>
<Gauges
overall={selectedClass.classRating}
difficulty={selectedClass.classDifficulty}
workload={selectedClass.classWorkload}
/>
<button
data-cy="leave-review-button"
className={styles.reviewbutton}
onClick={() => setOpen(true)}
>
Leave a review
</button>
</div>
< Gauges
overall={selectedClass.classRating}
difficulty={selectedClass.classDifficulty}
workload={selectedClass.classWorkload}
/>
<div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this div may be unnecessary?

{/* Check if course has a classSummary */}
{selectedClass?.classSummary && selectedClass?.summaryTags && (
<CornelliansSay
classSummary={selectedClass.classSummary}
summaryTags={
selectedClass.summaryTags instanceof Map
? selectedClass.summaryTags
: new Map(Object.entries(selectedClass.summaryTags))
}
/>
)}
</div>
</div>
<div className={styles.rightPanel}>
{/* Reviews Displaying */}
<div className={styles.reviewscontainer}>
<div className={styles.bar}>
<h2 className={styles.title}>Past Reviews ({courseReviews?.length}) </h2>
<div>
<label htmlFor="sort-reviews">Sort by: </label>
<select
name="sort-reviews"
id="sort-reviews"
onChange={sortReviewsBy}
className={styles.filtertext}
>
<option value="helpful">Most Helpful</option>
<option value="recent">Recent</option>
<option value="professor">Professor</option>
</select>
</div>
</div>
<div className={styles.reviews}>
<CourseReviews
reviews={courseReviews}
isPreview={false}
isProfile={false}
token={token}
/>
<div className={styles.bar}>
<h2 className={styles.title}>Past Reviews ({courseReviews?.length}) </h2>
<div>
<label htmlFor="sort-reviews">Sort by: </label>
<select
name="sort-reviews"
id="sort-reviews"
onChange={sortReviewsBy}
className={styles.filtertext}
>
<option value="helpful">Most Helpful</option>
<option value="recent">Recent</option>
<option value="professor">Professor</option>
</select>
</div>
</div>
<div className={styles.reviews}>
<CourseReviews
reviews={courseReviews}
isPreview={false}
isProfile={false}
token={token}
/>
</div>
</div>
</div>
</div>

Expand Down
67 changes: 67 additions & 0 deletions client/src/modules/Course/Styles/CornelliansSay.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
.container {
display: flex;
padding: 24px;
flex-direction: column;
align-items: flex-start;
gap: 5px;
border-radius: 10px;
background: #FFF;
}

.header {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 10px;
}

.bear-icon {
width: 40px;
height: 40px;
}

.title {
font-size: 24px;
font-weight: bold;
}

.summary {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like it looks a bit weird for the summary text to be different from the review text - so maybe no need to format this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esp the line height looks a bit funky

font-size: 16px;
line-height: 1.5;
margin-bottom: 15px;
}

.tagsTitle {
font-size: 18px;
margin-bottom: 10px;
}

.tagsContainer {
display: flex;
flex-wrap: wrap;
gap: 10px;
}

.tag {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the tags are too big somewhat, maybe reduce some of the padding

Copy link
Collaborator

@wizhaaa wizhaaa Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try

padding: 0 10px; 
min-height: 25px;

It also helps when the tag is too long on certain screen widths the text stacks on top of each other and clips the tag container.

font-size: 16px;
display: flex;
height: 25px;
padding: 10px;
justify-content: center;
align-items: center;
gap: 10px;
border-radius: 16px;
background: #FFF;
}

.positiveTag {
border: 1px solid #53b227;
}

.negativeTag {
border: 1px solid #ffa5a5;
}

.neutralTag {
border: 1px solid #f8cc30;
}
32 changes: 19 additions & 13 deletions client/src/modules/Course/Styles/Course.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
flex-flow: row nowrap;
justify-content: center;
align-items: flex-start;

padding: 63px 48px;
width: 100%;
}
Expand All @@ -22,6 +22,7 @@
flex-flow: column nowrap;
width: 40%;
padding-right: 24px;
gap: 16px;
}

.rightPanel {
Expand Down Expand Up @@ -61,16 +62,16 @@

padding: 3% 3% 1% 3%;

& > :first-child {
&> :first-child {
flex: 0 0 35%;
}

& > :nth-child(2) {
&> :nth-child(2) {
flex: 1;
}
}

.overview > * {
.overview>* {
justify-self: center;
}

Expand All @@ -88,7 +89,7 @@
width: 100%;
padding: 24px 32px;
}

.leftPanel {
width: 100%;
padding-right: 0px;
Expand All @@ -107,8 +108,9 @@
padding-bottom: 24px;
}

.gauges{
padding-bottom: 24px;;
.gauges {
padding-bottom: 24px;
;
}

.subtitle {
Expand Down Expand Up @@ -147,7 +149,7 @@
max-width: 1440px;
height: 100%;
max-height: 963px;

display: flex;
flex-flow: column nowrap;
}
Expand Down Expand Up @@ -180,20 +182,24 @@

/* Change scrollbar track color (background) */
::-webkit-scrollbar-track {
background: #ececec; /* Change to your desired background color */
background: #ececec;
/* Change to your desired background color */
border-radius: 13.573px;
}

/* Change scrollbar thumb color (the draggable part) */
::-webkit-scrollbar-thumb {
background: #807b7b; /* Change to your desired thumb color */
background: #807b7b;
/* Change to your desired thumb color */
border-radius: 13.573px;
}

/* Change scrollbar width and height */
::-webkit-scrollbar {
width: 6px; /* Change to your desired width */
height: 10px; /* Change to your desired height */
width: 6px;
/* Change to your desired width */
height: 10px;
/* Change to your desired height */
}
}

Expand Down Expand Up @@ -302,4 +308,4 @@
.reviewModal {
width: 70%;
}
}
}
Loading