-
Notifications
You must be signed in to change notification settings - Fork 3
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
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
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 GitHub Actions / build
Check warning on line 14 in client/src/modules/Course/Components/CornelliansSay.tsx GitHub Actions / build
Check warning on line 14 in client/src/modules/Course/Components/CornelliansSay.tsx GitHub Actions / build
|
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
@@ -26,10 +27,10 @@ | |
|
||
import ReviewModal from './ReviewModal'; | ||
|
||
enum PageStatus { | ||
Check warning on line 30 in client/src/modules/Course/Components/Course.tsx GitHub Actions / build
Check warning on line 30 in client/src/modules/Course/Components/Course.tsx GitHub Actions / build
Check warning on line 30 in client/src/modules/Course/Components/Course.tsx GitHub Actions / build
|
||
Loading, | ||
Check warning on line 31 in client/src/modules/Course/Components/Course.tsx GitHub Actions / build
Check warning on line 31 in client/src/modules/Course/Components/Course.tsx GitHub Actions / build
Check warning on line 31 in client/src/modules/Course/Components/Course.tsx GitHub Actions / build
|
||
Success, | ||
Check warning on line 32 in client/src/modules/Course/Components/Course.tsx GitHub Actions / build
|
||
Error | ||
Check warning on line 33 in client/src/modules/Course/Components/Course.tsx GitHub Actions / build
|
||
} | ||
|
||
export const Course = () => { | ||
|
@@ -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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
|
||
|
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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try
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; | ||
} |
There was a problem hiding this comment.
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?