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

[BUG] Chapter page issues #188 #245

Merged
merged 4 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function ChapterPage({
: filteredVerses?.slice(0).reverse();

return (
<div>
<div onClick={() => viewNavigation && setViewNavigation(false)}>
<div className="absolute inset-x-0 mx-auto max-w-5xl text-center font-inter">
<SvgChapterBackground className="relative inset-x-0 bottom-0 m-auto w-full rounded-full text-gray-300 text-opacity-25 dark:text-black dark:text-opacity-25 lg:top-12 lg:w-min" />
</div>
Expand Down Expand Up @@ -86,7 +86,7 @@ export default function ChapterPage({
</p>
</section>

<div className="mx-auto max-w-5xl px-4 text-center font-inter sm:px-6">
<div className="mx-auto max-w-5xl px-4 text-center font-inter sm:px-6">
<div className="flex items-center justify-between border-y border-gray-200 py-6">
<div
className={classNames(
Expand Down Expand Up @@ -116,13 +116,14 @@ export default function ChapterPage({
<VerseNavigator
verseCount={verses_count}
currentVerse={verseId}
chapterNumber={chapter_number}
viewNavigation={viewNavigation}
setViewNavigation={setViewNavigation}
setVerseId={setVerseId}
/>
<button
type="button"
className="relative -ml-px inline-flex items-center space-x-2 rounded-r-md border border-gray-300 bg-gray-50 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-100 focus:border-my-orange focus:outline-none focus:ring-1 focus:ring-my-orange dark:bg-dark-100 dark:text-gray-50 dark:hover:bg-dark-bg"
className="relative -ml-px inline-flex items-center space-x-2 rounded-r-md border border-gray-300 bg-gray-50 p-1 text-sm font-medium text-gray-700 hover:bg-gray-100 focus:border-my-orange focus:outline-none focus:ring-1 focus:ring-my-orange dark:bg-dark-100 dark:text-gray-50 dark:hover:bg-dark-bg"
onClick={() => setIsAscSorted(!isAscSorted)}
>
{isAscSorted ? (
Expand Down
40 changes: 24 additions & 16 deletions src/components/Chapter/VerseNavigator.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { Dispatch, SetStateAction } from "react";
import { useSelector } from "react-redux";

import LinkWithLocale from "components/LinkWithLocale";
import useMyStyles from "hooks/useMyStyles";
import { RootState } from "redux/reducers/rootReducer";
import { classNames } from "shared/functions";

interface Props {
verseCount: number;
currentVerse: number;
chapterNumber: number;
viewNavigation: boolean;
setViewNavigation: Dispatch<SetStateAction<boolean>>;
setVerseId: Dispatch<SetStateAction<number>>;
Expand All @@ -16,6 +18,7 @@ interface Props {
function VerseNavigator({
verseCount,
currentVerse,
chapterNumber,
viewNavigation,
setViewNavigation,
setVerseId,
Expand All @@ -27,9 +30,10 @@ function VerseNavigator({
<div
className={classNames(
fontSize === "large" ? "top-12" : "top-10",
`absolute flex w-full flex-wrap rounded border border-gray-200 bg-white p-3 shadow dark:border-dark-100 dark:bg-dark-bg ${
!viewNavigation && "hidden"
}`,
`absolute mt-2 flex flex-wrap rounded border border-gray-200 bg-white p-2 shadow dark:border-dark-100 dark:bg-dark-bg
${!viewNavigation && "hidden"}
${verseCount > 50 ? "-right-1 w-[360px] md:w-[550px]" : "-right-1 w-[360px]"}
`,
)}
>
<div
Expand All @@ -49,21 +53,25 @@ function VerseNavigator({
{Array(verseCount)
.fill(verseCount)
.map((_verse, index) => (
<div
onClick={() => {
setViewNavigation(false);
setVerseId(index + 1);
}}
<LinkWithLocale
key={index}
className={classNames(
`m-px flex min-w-[2.5rem] items-center justify-center rounded p-2 hover:cursor-pointer hover:bg-my-orange hover:text-white ${
index + 1 === currentVerse && "bg-my-orange text-white"
}`,
styles.fontSize.para,
)}
href={`/chapter/${chapterNumber}/verse/${index + 1}`}
prefetch={false}
>
{index + 1}
</div>
<div
onClick={() => {
setViewNavigation(false);
}}
className={classNames(
`m-px flex min-w-[2.5rem] items-center justify-center rounded p-2 hover:cursor-pointer hover:bg-my-orange hover:text-white ${
index + 1 === currentVerse && "bg-my-orange text-white"
}`,
styles.fontSize.para,
)}
>
{index + 1}
</div>
</LinkWithLocale>
))}
</div>
);
Expand Down