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

Mobile table usability #335

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all 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
44 changes: 28 additions & 16 deletions src/components/common/SearchResultsTable/searchResultsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
TableRow,
Tooltip,
Typography,
useMediaQuery,
} from '@mui/material';
import React, { useState } from 'react';

Expand Down Expand Up @@ -97,6 +98,7 @@ function Row({
color,
}: RowProps) {
const [open, setOpen] = useState(false);
const isSmallScreen = useMediaQuery('(max-width:600px)');

const rainbowColors = useRainbowColors();
const gpaToColor = (gpa: number): string => {
Expand Down Expand Up @@ -137,6 +139,16 @@ function Row({
</Tooltip>
</TableCell>
<TableCell>
{isSmallScreen && (
<Typography
className="leading-tight text-lg text-gray-600 dark:text-gray-200 cursor-text"
sx={{
whiteSpace: 'nowrap', // Prevents text from wrapping to a new line
}}
>
{searchQueryLabel(convertToProfOnly(course))}
</Typography>
)}
<Tooltip
title={inCompare ? 'Remove from Compare' : 'Add to Compare'}
placement="top"
Expand Down Expand Up @@ -167,22 +179,22 @@ function Row({
/>
</Tooltip>
</TableCell>
<TableCell component="th" scope="row">
<Typography
onClick={
(e) => e.stopPropagation() // prevents opening/closing the card when clicking on the text
}
className="leading-tight text-lg text-gray-600 dark:text-gray-200 cursor-text"
>
{searchQueryLabel(course) +
((typeof course.profFirst === 'undefined' &&
typeof course.profLast === 'undefined') ||
(typeof course.prefix === 'undefined' &&
typeof course.number === 'undefined')
? ' (Overall)'
: '')}
</Typography>
</TableCell>
{!isSmallScreen && (
<TableCell component="th" scope="row">
<Typography
onClick={(e) => e.stopPropagation()} // prevents opening/closing the card when clicking on the text
className="leading-tight text-lg text-gray-600 dark:text-gray-200 cursor-text"
>
{searchQueryLabel(course) +
((typeof course.profFirst === 'undefined' &&
typeof course.profLast === 'undefined') ||
(typeof course.prefix === 'undefined' &&
typeof course.number === 'undefined')
? ' (Overall)'
: '')}
</Typography>
</TableCell>
)}
<TableCell align="right">
{((typeof grades === 'undefined' || grades.state === 'error') && (
<></>
Expand Down
Loading