-
Notifications
You must be signed in to change notification settings - Fork 16
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
Implement the left sidebar #864
Implement the left sidebar #864
Conversation
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.
Great job @fran. Added a couple of inline comments, but nothing of a blocker.
src/hooks/useOnScreen.ts
Outdated
import { RefObject, useEffect, useMemo, useState } from 'react' | ||
|
||
export function useOnScreen(ref: RefObject<HTMLElement>) { | ||
const [isIntersecting, setIntersecting] = useState(false) | ||
|
||
const observer = useMemo( | ||
() => | ||
new IntersectionObserver( | ||
([entry]) => entry && setIntersecting(entry.isIntersecting), | ||
{ | ||
threshold: 0.1, | ||
}, | ||
), | ||
[], | ||
) | ||
|
||
useEffect(() => { | ||
if (!ref.current) { | ||
return | ||
} | ||
|
||
observer.observe(ref.current) | ||
return () => observer.disconnect() | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []) | ||
|
||
return isIntersecting | ||
} |
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.
I see you end up not using the useOnScreen hook. We can probably remove it if so.
Also what was the intension here, this seems a little complex method to know if the item is on screen.
It might be easier to check with scrollHeight of the object.
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.
One more thing, does this include the changes mick mentioned or will that be a separate PR ?
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.
No it doesn't include that yet
68a3e8f
into
fran/gey-1721-allow-funder-to-login-from-funding-flow
* feat: add profile to comment box * fix: missing deps * chore: improve setTarget tn * feat: Implement the left sidebar (#864) * refactor: make ProjectProvider avoid multiple network-only requests not needed * feat: add project navigation in left panel * chore: remove unused hook
* feat: add profile to comment box * fix: missing deps * chore: improve setTarget tn * feat: Implement the left sidebar (#864) * refactor: make ProjectProvider avoid multiple network-only requests not needed * feat: add project navigation in left panel * chore: remove unused hook
* feat: add profile to comment box * fix: missing deps * chore: improve setTarget tn * feat: Implement the left sidebar (#864) * refactor: make ProjectProvider avoid multiple network-only requests not needed * feat: add project navigation in left panel * chore: remove unused hook
Resolves GEY-2204
Refactors the ProjectContainer and ProjectProvider to avoid network-only calls and make navigation between entries and back to project without reloading everything, and also avoiding passing props all the way down at least for the useProjectState. We can improve it even further by doing something similar with the funding flow, avoiding to pass all the setters and getters to every child
Removed several pieces of repeated code that happened when fetching a project, and the fetch itself is now in the ProjectProvider.
Missing the "active" state of the navigation as I still looking for a best way to detect which one should be active. Intersection Observer has performance problems, left commented out for now.