-
-
Notifications
You must be signed in to change notification settings - Fork 470
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
Add new method for highlighting #1903
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
Overall looks good, I just left some questions
const renderWord = useCallback( | ||
(word: Word) => ( | ||
<QuranWord | ||
key={word.location} | ||
word={word} | ||
font={quranFont} | ||
isFontLoaded={isFontLoaded} | ||
isHighlighted={word.verseKey === selectedVerseKey} | ||
/> | ||
), | ||
[quranFont, isFontLoaded, selectedVerseKey], | ||
); |
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.
What is the purpose of using useCallback here? It seems like it will rerender components regardless this useCallback function
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.
We're using it as a dependency in the highlighter's useMemo
, so it's best practice to wrap it with a useCallback
.
Summary
Currently, we pass
shouldShowSecondaryHighlight
to the<QuranWord />
component if we want to highlight a line or a verse. This approach results in weird gaps between the highlights. This PR uses a different approach:Excalidraw link

In short, this approach involves using an absolute
<div>
with the highlight color as the background. The complex logic above is used to position the highlight accurately behind the verse.Screenshots