Skip to content

Commit

Permalink
Merge pull request #86 from sqrl-planner/develop
Browse files Browse the repository at this point in the history
Clean up dark text code and close issue #84
  • Loading branch information
eamonma authored Jun 27, 2022
2 parents 75d46c2 + cfe9e86 commit 2a3fada
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
1 change: 1 addition & 0 deletions components/sidebar/OverviewView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ const OverviewView = () => {

{coursesToShow[term].map((identifier: string) => {
const course = courses[identifier]
if(!course) return
const { department, numeral, suffix } = breakdownCourseCode(
course.code
)
Expand Down
32 changes: 13 additions & 19 deletions components/timetable/Timetable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,27 +330,21 @@ export const Timetable = ({
}}
>
{!abstract && (
// Situations where we should show dark text:
// - Light mode conflict:
// - !highlightConflicts
// - meeting.identifier === sidebarCourse
// - emphasizeOnHover AND
// - hoverCourseKey === meeting.courseKey
// - Dark mode conflict: NEVER

<MeetingComponent
style={{
color: !dark
? hoverCourseKey === meeting.courseKey &&
emphasizeOnHover
? "black"
: meeting.identifier === sidebarCourse
? "black"
: "white"
: "white",
}}
darkText={
!(dark || highlightConflicts) ||
(emphasizeOnHover &&
hoverCourseKey === meeting.courseKey &&
!dark) ||
(meeting.identifier === hoverMeeting.courseIdentifier &&
hoverMeeting.meeting.substring(0, 3) ===
meeting.category.substring(0, 3).toUpperCase() &&
!dark)
// || meeting.identifier === sidebarCourse
!dark &&
(!highlightConflicts ||
meeting.identifier === sidebarCourse ||
(emphasizeOnHover &&
hoverCourseKey === meeting.courseKey))
}
meeting={meeting}
twentyFour={twentyFour}
Expand Down
8 changes: 4 additions & 4 deletions src/utils/course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ export const getSectionType = (section: string) => {
}

export const getMeetingTypes = (course: Course) => ({
lecture: course.sections.some(
lecture: course?.sections.some(
(section) => section.teachingMethod === "LECTURE"
),
tutorial: course.sections.some(
tutorial: course?.sections.some(
(section) => section.teachingMethod === "TUTORIAL"
),
practical: course.sections.some(
practical: course?.sections.some(
(section) => section.teachingMethod === "PRACTICAL"
),
})
Expand Down Expand Up @@ -105,6 +105,6 @@ export const meetingsMissing = (
}

export const courseIsForCredit = (course: Course) => {
if (course.description.includes("does not carry credit weight")) return false
if (course?.description.includes("does not carry credit weight")) return false
return true
}

0 comments on commit 2a3fada

Please sign in to comment.