-
Notifications
You must be signed in to change notification settings - Fork 1
[FLOW 28] Added Review Distribution View #188
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
Conversation
That is actually very clever - will look into it |
|
||
// Handle search result data from search worker message | ||
const performSearch = (event: MessageEvent) => { | ||
const performSearch = useCallback((event: MessageEvent) => { |
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.
Probably don't need to useCallback here since this is an uncomplicated fn with no deps, it just adds memory/allocation overhead: https://kentcdodds.com/blog/usememo-and-usecallback
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.
example.mp4
(EDIT: updated the video to not use the stupid zoomy animation thing)
Oh, I added this useCallback because I noticed it was adding a new event listener for every user input character in the searchBar, which I don't think is the expected behavior. You do make a good point though - I think there is some kind of underlying cache mechanism because I did console.time
and somewhere, somehow React is already caching the data itself. But this makes it so there is just one event listener added after the component mounts (instead of a new eventListener every time the searchBar is edited)
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.
sounds good :D
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.
Hmm maybe that's an issue with useEffect
below? That's where we add the listeners
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.
oh wait, good point - yeah I think that would be a better solution - just remove the handleUserKeyPress in the dependency array, since we can avoid two separate useCallbacks with that.
finally got this done without importing a gazillion material UI components demo.mp4 |
"@fortawesome/react-fontawesome": "^0.1.8", | ||
"@loadable/component": "^5.12.0", | ||
"@tippy.js/react": "^3.1.1", | ||
"@tippyjs/react": "^4.2.6", |
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.
Package was deprecated, which is why CSS styling wasn't showing up for some components using this. See: https://www.npmjs.com/package/@tippy.js/react
setDeleting(true); | ||
try { | ||
const [response, status] = await makeAuthenticatedDELETERequest( | ||
const [, status] = await makeAuthenticatedDELETERequest( |
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 is just correcting a lint error introduced in #184
</PopoverWrapper> | ||
); | ||
|
||
export default Popover; |
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.
PopoverWrapper is nearly identical to ToolTipWrapper, except instead it has an arrow and appears when clicked instead of being hovered over. Both use tippy.js/react.
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.
Wow this is sick
demo.mp4
Associated Backend PR: UWFlow/uwflow#131
PR Summary Generated With Copilot:
This pull request introduces several changes to the codebase, focusing on updating dependencies, adding a Rating Distribution view to the professor and course view, fixing linting issues and a small error with search. The most important changes include updating the
@tippyjs/react
dependency, adding new components for displaying rating distributions, and refactoring the search bar's event handling.Dependency updates:
package.json
: Updated the@tippyjs/react
dependency from version 3.1.1 to 4.2.6.Enhancements to rating display components:
src/components/display/Popover.tsx
: Added a newPopover
component to encapsulate popover functionality.src/components/display/RatingBox.tsx
: Integrated the newPopover
component and added aRatingDistributionGraph
to display detailed rating distributions.src/components/display/RatingDistributionGraph.tsx
: Created a newRatingDistributionGraph
component to visualize rating distributions.src/components/display/styles/Popover.tsx
: Added styled components for thePopover
component.src/components/display/styles/RatingDistributionGraph.tsx
: Added styled components for theRatingDistributionGraph
component.Refactoring and improvements to search functionality:
src/components/navigation/SearchBar.tsx
: Refactored the search bar to useuseEffect
for handling search worker messages and key press events, improving readability and maintainability.GraphQL query updates:
src/graphql/fragments/CourseFragment.tsx
: Added a new fragmentCourseReviewDistribution
to fetch course review distributions.src/graphql/fragments/ProfFragment.tsx
: Added a new fragmentProfReviewDistribution
to fetch professor review distributions.src/graphql/queries/course/Course.tsx
: Updated course queries to include the newCourseReviewDistribution
fragment.src/graphql/queries/prof/Prof.tsx
: Updated professor queries to include the newProfReviewDistribution
fragment.Enhancements to course page:
src/pages/coursePage/CourseInfoHeader.tsx
: Updated theCourseInfoHeader
component to include rating distributions in the props and display them using the new components.src/pages/coursePage/CoursePage.tsx
: Added logic to process and pass rating distribution data to theCourseInfoHeader
component