-
Notifications
You must be signed in to change notification settings - Fork 28
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
Conversation
…that are not offered for the term
Not sure why the preview link isn't showing but here it is: |
@@ -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]); |
There was a problem hiding this comment.
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?
src/lib/fetchers.tsx
Outdated
@@ -112,6 +112,7 @@ export interface Seat { | |||
export interface KualiSubject { | |||
subject: string; | |||
title: string; | |||
inSession?: boolean; |
There was a problem hiding this comment.
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.
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 |
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; | ||
}); | ||
} |
There was a problem hiding this comment.
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
export interface KualiSubjectInSession { | ||
inSession?: boolean; | ||
} | ||
export type InSessionSubject = KualiSubject & KualiSubjectInSession; |
There was a problem hiding this comment.
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 :)
// re assign the type of subjects so inSession property is available | ||
const inSessionSubjects: InSessionSubject[] | null = subjects; |
There was a problem hiding this comment.
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.
<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> |
There was a problem hiding this comment.
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?
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 🌎 |
There was a problem hiding this 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:
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
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> | ||
); | ||
} |
There was a problem hiding this comment.
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 if
s and returns
.
bgColor={ | ||
selected | ||
? inSessionSubject === undefined | ||
? undefined | ||
: inSessionSubject | ||
? undefined | ||
: '#d3d3d3' | ||
: inSessionSubject === undefined | ||
? 'white' | ||
: inSessionSubject | ||
? 'white' | ||
: '#d3d3d3' | ||
} |
There was a problem hiding this comment.
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.
…he color of bg to the SidebarContainer color (#e4e4e4)
… ternary operation to subjectlist
Given the outdated nature and lack of user reports about this issue closing. |
made subject cards unclickable and added a warning hover for subjects that are not offered for that specific term
Overview
Closes #194