Skip to content

Commit

Permalink
Fix loading jumping
Browse files Browse the repository at this point in the history
  • Loading branch information
TyHil committed Dec 3, 2024
1 parent 567bfda commit d0ca5f7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 29 deletions.
22 changes: 14 additions & 8 deletions src/components/CourseOverview.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Skeleton } from '@mui/material';
import React from 'react';

import { TRENDS_URL } from '~data/config';
Expand All @@ -11,23 +12,28 @@ type CourseOverviewProps = {

const CourseOverview = ({ course, grades }: CourseOverviewProps) => {
return (
<div className="flex flex-col gap-2">
<p className="text-2xl font-bold text-center">
<div className="flex flex-col items-center gap-2">
<p className="text-2xl font-bold">
{searchQueryLabel(course)}
</p>
{grades.state === 'done' && (
<p className="text-lg font-semibold text-center">
{'Overall grade: ' + grades.data.letter_grade}
</p>
)}
{(grades.state === 'loading' && (
<Skeleton variant="rounded">
<p className="text-lg font-semibold">Overall grade: A+</p>
</Skeleton>
)) ||
(grades.state === 'done' && (
<p className="text-lg font-semibold">
{'Overall grade: ' + grades.data.letter_grade}
</p>
))}
<a
href={
TRENDS_URL +
'dashboard?searchTerms=' +
encodeURIComponent(searchQueryLabel(course))
}
target="_blank"
className="underline text-blue-600 hover:text-blue-800 visited:text-purple-600 text-center"
className="underline text-blue-600 hover:text-blue-800 visited:text-purple-600"
rel="noreferrer"
>
See on Trends
Expand Down
18 changes: 9 additions & 9 deletions src/components/SearchResultsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,16 @@ function Row({ course, grades, backupGrades, rmp, setPage }: RowProps) {
</IconButton>
</Tooltip>
</TableCell>
<TableCell align="right" className="border-b-0">
<TableCell align="center" className="border-b-0">
{((typeof grades === 'undefined' || grades.state === 'error') &&
(((typeof backupGrades === 'undefined' ||
backupGrades.state === 'error') && <></>) ||
(backupGrades.state === 'loading' && (
<Skeleton
variant="rounded"
className="rounded-full px-5 py-2 ml-auto"
className="rounded-full px-5 py-2 w-16 block mx-auto"
>
<Typography className="text-base">A</Typography>
<Typography className="text-base w-6">A+</Typography>
</Skeleton>
)) ||
(backupGrades.state === 'done' && (
Expand Down Expand Up @@ -155,7 +155,7 @@ function Row({ course, grades, backupGrades, rmp, setPage }: RowProps) {
}
>
<Typography
className="text-base text-black rounded-full px-5 py-2 inline"
className="text-base text-black text-center rounded-full px-5 py-2 w-16 block mx-auto"
sx={{
backgroundColor: gpaToColor(backupGrades.data.gpa),
}}
Expand All @@ -168,9 +168,9 @@ function Row({ course, grades, backupGrades, rmp, setPage }: RowProps) {
(grades.state === 'loading' && (
<Skeleton
variant="rounded"
className="rounded-full px-5 py-2 ml-auto"
className="rounded-full px-5 py-2 w-16 block mx-auto"
>
<Typography className="text-base">A</Typography>
<Typography className="text-base w-6">A+</Typography>
</Skeleton>
)) ||
(grades.state === 'done' && (
Expand All @@ -179,7 +179,7 @@ function Row({ course, grades, backupGrades, rmp, setPage }: RowProps) {
placement="top"
>
<Typography
className="text-base text-black rounded-full px-5 py-2 inline"
className="text-base text-black text-center rounded-full px-5 py-2 w-16 block mx-auto"
sx={{ backgroundColor: gpaToColor(grades.data.gpa) }}
>
{grades.data.letter_grade}
Expand All @@ -188,10 +188,10 @@ function Row({ course, grades, backupGrades, rmp, setPage }: RowProps) {
)) ||
null}
</TableCell>
<TableCell align="right" className="border-b-0">
<TableCell align="center" className="border-b-0">
{((typeof rmp === 'undefined' || rmp.state === 'error') && <></>) ||
(rmp.state === 'loading' && (
<Skeleton variant="rounded" className="rounded-full ml-auto">
<Skeleton variant="rounded" className="rounded-full">
<Rating sx={{ fontSize: 25 }} readOnly />
</Skeleton>
)) ||
Expand Down
29 changes: 17 additions & 12 deletions src/components/SingleProfInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,34 @@ function SingleProfInfo({ rmp }: Props) {
return (
<Grid container spacing={2} className="p-4">
<Grid item xs={6}>
<p className="text-xl font-bold">
<Skeleton variant="rounded" width="10%" height={25} />
</p>
<Skeleton variant="rounded">
<p className="text-xl font-bold">5.0</p>
</Skeleton>
<p>Professor rating</p>
</Grid>
<Grid item xs={6}>
<p className="text-xl font-bold">
<Skeleton variant="rounded" width="10%" height={25} />
</p>
<Skeleton variant="rounded">
<p className="text-xl font-bold">5.0</p>
</Skeleton>
<p>Difficulty</p>
</Grid>
<Grid item xs={6}>
<p className="text-xl font-bold">
<Skeleton variant="rounded" width="10%" height={25} />
</p>
<Skeleton variant="rounded">
<p className="text-xl font-bold">1,000</p>
</Skeleton>
<p>Ratings given</p>
</Grid>
<Grid item xs={6}>
<p className="text-xl font-bold">
<Skeleton variant="rounded" width="10%" height={25} />
</p>
<Skeleton variant="rounded">
<p className="text-xl font-bold">99%</p>
</Skeleton>
<p>Would take again</p>
</Grid>
<Grid item xs={12}>
<Skeleton variant="rounded">
<p>Visit Rate My Professors</p>
</Skeleton>
</Grid>
</Grid>
);
}
Expand Down

0 comments on commit d0ca5f7

Please sign in to comment.