fix: conflict row bug (#130)

* fix: temp fixes, need to still work on it

* fix: im a god at css otl

* fix: handle edge case where they have conflicting classes in their schedule

* fix: got it working

* fix: don't change the font size of course names

* fix: remove unused prop

* fix: lint errs

* fix: remove unused code
This commit is contained in:
Dhruv
2024-03-11 23:41:20 -05:00
committed by GitHub
parent 4c61ebd3fc
commit a8ea3bc683
3 changed files with 36 additions and 34 deletions

View File

@@ -5,7 +5,7 @@ import CourseCatalogInjectedPopup from '@views/components/injected/CourseCatalog
import RecruitmentBanner from '@views/components/injected/RecruitmentBanner/RecruitmentBanner'; import RecruitmentBanner from '@views/components/injected/RecruitmentBanner/RecruitmentBanner';
import TableHead from '@views/components/injected/TableHead'; import TableHead from '@views/components/injected/TableHead';
import TableRow from '@views/components/injected/TableRow/TableRow'; import TableRow from '@views/components/injected/TableRow/TableRow';
import TableSubheading from '@views/components/injected/TableSubheading/TableSubheading'; // import TableSubheading from '@views/components/injected/TableSubheading/TableSubheading';
import { useKeyPress } from '@views/hooks/useKeyPress'; import { useKeyPress } from '@views/hooks/useKeyPress';
import useSchedules from '@views/hooks/useSchedules'; import useSchedules from '@views/hooks/useSchedules';
import { CourseCatalogScraper } from '@views/lib/CourseCatalogScraper'; import { CourseCatalogScraper } from '@views/lib/CourseCatalogScraper';
@@ -63,12 +63,9 @@ export default function CourseCatalogMain({ support }: Props): JSX.Element {
<ExtensionRoot> <ExtensionRoot>
<RecruitmentBanner /> <RecruitmentBanner />
<TableHead>Plus</TableHead> <TableHead>Plus</TableHead>
{rows.map((row, i) => { {rows.map(
if (!row.course) { row =>
// TODO: handle the course section headers row.course && (
return <TableSubheading key={row.element.innerText + i.toString()} row={row} />;
}
return (
<TableRow <TableRow
key={row.course.uniqueId} key={row.course.uniqueId}
row={row} row={row}
@@ -76,8 +73,8 @@ export default function CourseCatalogMain({ support }: Props): JSX.Element {
activeSchedule={activeSchedule} activeSchedule={activeSchedule}
onClick={handleRowButtonClick(row.course)} onClick={handleRowButtonClick(row.course)}
/> />
); )
})} )}
{selectedCourse && ( {selectedCourse && (
<CourseCatalogInjectedPopup <CourseCatalogInjectedPopup
course={selectedCourse} course={selectedCourse}

View File

@@ -72,16 +72,17 @@
} }
.inActiveSchedule { .inActiveSchedule {
* { > *:not(td:last-child) {
color: colors.$turtle_pond !important; color: colors.$turtle_pond !important;
font-weight: bold !important; font-weight: bold !important;
} }
} }
.isConflict { // for the edge case where they have conflicting classes in their schedule
* { .isConflict:not(.inActiveSchedule) {
color: colors.$speedway_brick !important; > *:not(td:last-child) {
font-weight: normal !important; color: colors.$speedway_brick;
text-decoration: line-through !important; font-weight: normal;
text-decoration: line-through;
} }
} }

View File

@@ -1,11 +1,10 @@
import type { Course, ScrapedRow } from '@shared/types/Course'; import type { Course, ScrapedRow } from '@shared/types/Course';
import type { UserSchedule } from '@shared/types/UserSchedule'; import type { UserSchedule } from '@shared/types/UserSchedule';
import { Button } from '@views/components/common/Button/Button';
import ConflictsWithWarning from '@views/components/common/ConflictsWithWarning/ConflictsWithWarning'; import ConflictsWithWarning from '@views/components/common/ConflictsWithWarning/ConflictsWithWarning';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import AddIcon from '~icons/material-symbols/add-circle'; import RowIcon from '~icons/material-symbols/bar-chart-rounded';
import styles from './TableRow.module.scss'; import styles from './TableRow.module.scss';
@@ -30,8 +29,9 @@ export default function TableRow({ row, isSelected, activeSchedule, onClick }: P
useEffect(() => { useEffect(() => {
element.classList.add(styles.row); element.classList.add(styles.row);
element.classList.add('group');
const portalContainer = document.createElement('td'); const portalContainer = document.createElement('td');
portalContainer.style.textAlign = 'right'; // portalContainer.style.textAlign = 'right';
const lastTableCell = element.querySelector('td:last-child'); const lastTableCell = element.querySelector('td:last-child');
lastTableCell!.after(portalContainer); lastTableCell!.after(portalContainer);
setContainer(portalContainer); setContainer(portalContainer);
@@ -85,16 +85,20 @@ export default function TableRow({ row, isSelected, activeSchedule, onClick }: P
} }
return ReactDOM.createPortal( return ReactDOM.createPortal(
<> <div className='relative'>
<Button <button
icon={AddIcon} className='bg-ut-burntorange w-6 h-6 items-center justify-center color-white! flex m1 rounded'
className={styles.rowButton}
color='ut-burntorange'
onClick={onClick} onClick={onClick}
variant='single' >
<RowIcon color='ut-white' />
</button>
{conflicts.length > 0 && (
<ConflictsWithWarning
className='group-hover:visible invisible text-white absolute left-13 top--3'
conflicts={conflicts}
/> />
{conflicts.length > 0 && <ConflictsWithWarning className={styles.conflictTooltip} conflicts={conflicts} />} )}
</>, </div>,
container container
); );
} }