Skip to content

Conversation

jerryzhou196
Copy link
Member

@jerryzhou196 jerryzhou196 commented Nov 7, 2024

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:

Refactoring and improvements to search functionality:

GraphQL query updates:

Enhancements to course page:

@jerryzhou196 jerryzhou196 self-assigned this Nov 7, 2024
@edwinzhng
Copy link
Member

What do you think about making the distributions popovers that opened up on click of the existing "easy" and "useful" text here? That would keep the UI cleaner so that the left border is still always the same roundedness as the "liked" circle bar

Screenshot 2024-11-06 at 7 12 49 PM

@jerryzhou196
Copy link
Member Author

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) => {
Copy link
Member

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

Copy link
Member Author

@jerryzhou196 jerryzhou196 Nov 7, 2024

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)

Copy link
Member Author

Choose a reason for hiding this comment

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

sounds good :D

Copy link
Member

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

Copy link
Member Author

@jerryzhou196 jerryzhou196 Nov 7, 2024

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.

@jerryzhou196
Copy link
Member Author

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",
Copy link
Member Author

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(
Copy link
Member Author

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;
Copy link
Member Author

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.

Copy link
Member

@edwinzhng edwinzhng left a 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

@jerryzhou196 jerryzhou196 merged commit 0f30c9e into main Jan 21, 2025
1 check passed
@jerryzhou196 jerryzhou196 deleted the flow-28-review-distributions branch January 21, 2025 02:18
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.

2 participants