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

Bug fix: Subject cards now say (Not offered) if "Show in Session" filter button is used #241

Closed
wants to merge 10 commits into from

Conversation

shergillmanav19
Copy link
Contributor

made subject cards unclickable and added a warning hover for subjects that are not offered for that specific term

Overview

Closes #194

@shergillmanav19 shergillmanav19 requested a review from a team as a code owner July 6, 2021 00:59
@aomi
Copy link
Member

aomi commented Jul 6, 2021

Not sure why the preview link isn't showing but here it is:
https://staging-clockwork--courseup-ba4f8o0z.web.app/scheduler/202105

@@ -52,9 +52,28 @@ export function SidebarContainer({ searchQuery, term }: SidebarContainerProps):
const loading = subjectsLoading || coursesLoading;

// sorts the list of subjects alphabetically
const sortedSubjects = useMemo(() => subjects?.sort((a, b) => (a.subject > b.subject ? 1 : -1)), [subjects]);
let sortedSubjects = useMemo(() => subjects?.sort((a, b) => (a.subject > b.subject ? 1 : -1)), [subjects]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe extend the type of subjects[] with a inSession: boolean instead?

@@ -112,6 +112,7 @@ export interface Seat {
export interface KualiSubject {
subject: string;
title: string;
inSession?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file isn't stable (it's generated) so I suggest making a type that extends this one instead.

@keithradford
Copy link
Collaborator

How about something like this design wise? It emulates how chakra deals with disabled buttons by basically just butting a grey tint over it. Additionally I think it should have this appearance permanently, not just on hover. Lastly, the pointer on hover should be not-allowed or just the default cursor so it doesn't appear clickable.

Screen Shot 2021-07-06 at 5 34 30 PM

Comment on lines 58 to 79
let sortedSubjects = useMemo(() => inSessionSubjects?.sort((a, b) => (a.subject > b.subject ? 1 : -1)), [
inSessionSubjects,
]);
const parsedCourses = useMemo(() => computeParsedCourses(courses), [courses]);
//if filter is set then we want to add (Not offered) to subjects

if (filter) {
sortedSubjects = sortedSubjects?.filter((subject) => {
if (parsedCourses[subject.subject]) {
subject.inSession = true;
return subject;
} else {
subject.inSession = false;
return subject;
}
});
} else {
sortedSubjects = sortedSubjects?.filter((subject) => {
subject.inSession = true;
return subject;
});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to add this filter logic within the sortedSubjects / computeParsedCourses as this avoids sidesteps the optimization of the useMemo.

src/lib/types.ts Outdated
Comment on lines 3 to 6
export interface KualiSubjectInSession {
inSession?: boolean;
}
export type InSessionSubject = KualiSubject & KualiSubjectInSession;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be combined into one type declaration. Also, I would suggest not calling it InSessionSubject as we might use it for other stuff :)

Comment on lines 52 to 53
// re assign the type of subjects so inSession property is available
const inSessionSubjects: InSessionSubject[] | null = subjects;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't required since you're mapping against the original thing. You can just return a InSessionSubject from the map below.

Comment on lines 125 to 186
<Box
bgColor={selected ? undefined : 'white'}
bgGradient={selected ? 'linear(to-l, #2e95d1, #7cbce2)' : undefined}
color={selected ? 'white' : 'black'}
boxShadow="md"
py={2}
px={4}
my={1}
cursor={!schedule ? 'pointer' : 'auto'}
_hover={{
bgGradient: schedule ? undefined : selected ? undefined : 'linear(to-l, #39c686, #80dbb1)',

color: schedule ? undefined : 'white',
}}
>
<Flex direction="row" alignItems="center" justifyContent="space-between">
<VStack alignItems="start" spacing="0">
<Text fontSize="lg" fontWeight="bold" p={0} m={0}>
{subject} {code}
</Text>
<Text fontSize="sm" fontWeight="normal" p={0} m={0}>
{title}
</Text>
</VStack>
{buttons(code, schedule)}
</Flex>
</Box>
);
} else {
return (
<Box
bgColor={selected ? (inSessionSubject ? undefined : '#d3d3d3') : inSessionSubject ? 'white' : '#d3d3d3'}
bgGradient={selected ? 'linear(to-l, #2e95d1, #7cbce2)' : undefined}
color={selected ? 'white' : 'black'}
boxShadow="md"
py={2}
px={4}
my={1}
cursor={!schedule ? (inSessionSubject ? 'pointer' : 'auto') : 'auto'}
_hover={{
bgGradient: schedule
? undefined
: selected
? undefined
: inSessionSubject
? 'linear(to-l, #39c686, #80dbb1)'
: 'linear(to-l, #d3d3d3, #d3d3d3)',
color: schedule ? undefined : 'white',
}}
>
<Flex direction="row" alignItems="center" justifyContent="space-between">
<VStack alignItems="start" spacing="0">
<Text fontSize="lg" fontWeight="bold" p={0} m={0}>
{subject} {code}
</Text>
<Text fontSize="sm" fontWeight="normal" p={0} m={0}>
{title}
</Text>
</VStack>
{buttons(code, schedule)}
</Flex>
</Box>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be combined and just conditionally pass in the props?

@github-actions
Copy link

github-actions bot commented Jul 26, 2021

Visit the preview URL for this PR (updated for commit 98184c0):

https://staging-clockwork--pr241-manav-bug-fix-subjec-cjj4lbdx.web.app

(expires Wed, 11 Aug 2021 03:52:56 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@shergillmanav19 shergillmanav19 requested a review from aomi July 26, 2021 05:13
Copy link
Member

@aomi aomi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some visual issues I'm seeing:
image
The gray background colouring appears to be spilling over the defined card. This is due to the usage of the same gray so maybe switching it to be lighter/darker will help clear that up?

Also, I don't think the hover against the text needs to be present when a card is disabled.

The warning icon is low resolution. While I really like the tool-tip the icon usage seems a bit out of place. I'd maybe side on removing it for and add something like this once we've refined it a bit more. Interested in hearing your thoughts as well as @keithradford and @FlyteWizard

Comment on lines 31 to 50
if (subject.inSession) {
return (
<LinkBox
as={Link}
to={{
pathname: `/${route}/${term}/${subject.subject}`,
search: pid ? `?pid=${pid}` : undefined,
}}
key={index}
>
<Card subject={subject.subject} inSessionSubject={subject.inSession} title={subject.title} />
</LinkBox>
);
} else {
return (
<Box key={index}>
<Card subject={subject.subject} inSessionSubject={subject.inSession} title={subject.title} />
</Box>
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can use tenary conditional so you can remove the ifs and returns.

Comment on lines 125 to 137
bgColor={
selected
? inSessionSubject === undefined
? undefined
: inSessionSubject
? undefined
: '#d3d3d3'
: inSessionSubject === undefined
? 'white'
: inSessionSubject
? 'white'
: '#d3d3d3'
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit extreme and could likely be simplified somehow. Or even just moving this into separate variables so it's easier to read would be great.

@shergillmanav19 shergillmanav19 requested a review from aomi August 4, 2021 04:22
@aomi
Copy link
Member

aomi commented Jan 31, 2022

Given the outdated nature and lack of user reports about this issue closing.

@aomi aomi closed this Jan 31, 2022
@aomi aomi deleted the manav/bug-fix/subject-with-no-courses branch February 8, 2022 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Subjects with no courses appear when using Only Show Courses in Session
3 participants