Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ahmedriad1
Copy link
Collaborator

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
Untitled-2022-08-15-1522

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

Before After
image image

@vercel
Copy link

vercel bot commented Jan 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
quran-com ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 21, 2023 10:03am

@ahmedriad1 ahmedriad1 changed the title [WIP] Add new method for highlighting Add new method for highlighting Feb 20, 2023
Copy link

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

Comment on lines +80 to +91
const renderWord = useCallback(
(word: Word) => (
<QuranWord
key={word.location}
word={word}
font={quranFont}
isFontLoaded={isFontLoaded}
isHighlighted={word.verseKey === selectedVerseKey}
/>
),
[quranFont, isFontLoaded, selectedVerseKey],
);

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

Copy link
Collaborator Author

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.

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