Skip to content

YPE-1343: Bible Reader next and prev chapter btns#168

Merged
cameronapak merged 47 commits intomainfrom
cp/YPE-1343-react-sdk-bible-reader-toolbar-add-prev-and-next-chapter-buttons-in-the-bible-reader-toolbar-according-to-designs-from-tim-watson
Feb 25, 2026
Merged

YPE-1343: Bible Reader next and prev chapter btns#168
cameronapak merged 47 commits intomainfrom
cp/YPE-1343-react-sdk-bible-reader-toolbar-add-prev-and-next-chapter-buttons-in-the-bible-reader-toolbar-according-to-designs-from-tim-watson

Conversation

@cameronapak
Copy link
Collaborator

@cameronapak cameronapak commented Feb 24, 2026

This PR adds the next and previous chapter buttons to the Bible Reader in alignment with https://lifechurch.atlassian.net/browse/YPE-1343. This ticket came about in a conversation with myself and Tim Watson when processing the UX of the Bible Reader and felt like this was very important.

We got a new design approach for the Bible Reader Toolbar actions. Here's the figma design Tim gave me:

image
CleanShot.2026-02-24.at.12.15.11.mp4

And, based on how the Android YV Bible app, they do not hide the Intro title header, so... we're now showing it on web

CleanShot 2026-02-24 at 12 32 57@2x

Adds a button to select the introduction chapter for a book in the bible
chapter picker. This allows users to easily navigate to the book's
introduction.
Conditionally renders the book and chapter header in the bible reader
component. This ensures the header is only displayed when the chapter is
a valid numerical value.
Adjust the `grid-cols` class in the Bible reader toolbar to dynamically
render either `auto_1fr_auto` or `1fr_auto` based on the `authEnabled`
state from the `yvContext`.
This class handles intended list items, ensuring correct styling for
elements like the Acts Intro in certain Bible versions.
Corrected "Intended" to "Indented" in a CSS comment for clarity.
This commit adds and updates several CSS classes within the bible reader
styling to ensure accurate rendering of scripture content. Key changes
include:

- Applying `display: block` to the root element for better layout
  control.
- Inheriting typography from the root for improved cascade and em-based
  sizing.
- Adding detailed styling for various scripture formatting tags such as
  titles, headings, paragraphs, poetry, quotes, and special text styles.
- Updating comments to better reflect the purpose of each CSS class.
This commit introduces CSS rules for the `.yv-vlbl` class, ensuring that
verse labels are displayed with the correct sans-serif font. This
enhances the visual consistency and readability of biblical content
within the UI.
This commit introduces CSS styling for additional USFM tags within the
Bible reader component. These additions include:
- Hiding metadata and navigation tags like `\usfm`, `\h`, `\toca1`,
  `\toca2`, `\toca3`.
- Correcting the display of scripture quotations in introductions
  (`\iqt`).
- Adjusting the styling for inline elements like footnotes (`\fl`).
- Improving the handling of proper names (`\pn`).
- Updating styling for footnotes and endnotes (`\f`, `\fe`).
- Adding styling for secondary language text (`\sls`).
- Refining styles for major section headings (`\ms2`).
- Ensuring proper alignment for table cells (`\tcr`, `\tcr1`).
- Adding styling for indented list items (`\ph3`, `\lim3`).
spacing on the wrong side. Every other property in the file was
converted to logical properties, but this one slipped through.
- Replace parseInt with regex for chapterIsNumerical check
- Make chapterUnavailable validate against chapters array and intro ID
- Remove redundant || false in toolbar grid conditional
- Add JSDoc on chapter render prop clarifying it's a display label
- Add IntroChapter Storybook story with play function
- Add JHN intro mock data and MSW handler using real API response
Wait for the "Intro" label to appear in the bible reader toolbar in the
story. This ensures that the test correctly accounts for asynchronous
data loading before asserting the label's presence.
Refine the bible reader story for intro chapters to accurately reflect
real-world content. This includes using the TPT version for Joshua's
intro, which contains structured sections, and updating assertions to
verify specific formatting and content elements.
- Add top margin to .is/.s/.heading section headings for spacing
- Add IntroChapter story for JHN.INTRO rendering
- Fix JoshuaIntroChapter story to wait for content before assertions
This commit refactors the `BibleChapterPicker` component to correctly
display the chapter label in the toolbar trigger. Previously, it was
using the raw chapter ID, which could lead to incorrect display for
introductory chapters.

The `TriggerProps` type has been updated to include `chapterLabel` and
the component logic now correctly derives and uses this label for
rendering. Unit tests have also been updated to reflect this change and
ensure accurate display.
Organize the CSS rules for the bible reader component into logical
sections. This improves readability and maintainability. New sections
include major titles, section headings, introduction outlines,
paragraphs, character styles, and notes. Additionally, styles for
specific USFM tags have been refined for better accuracy and
consistency.
Adjust CSS for bible reader component to use shorthand margin properties
and more consistent text indentation for blockquotes.
Update text-indent for list items within the bible reader styles to
improve
readability and visual consistency.
Extract chapter selection logic into a reusable handler function to
improve code clarity and maintainability.
Replace "Loading..." text with a spinning loader icon in the Bible
reader toolbar when data is being fetched.
Adjusted the layout of the Bible reader toolbar to use flexbox for
better responsiveness and simplified the structure for chapter and
version pickers. Modified button sizes for better visual hierarchy.
…pter' into cp/YPE-1343-react-sdk-bible-reader-toolbar-add-prev-and-next-chapter-buttons-in-the-bible-reader-toolbar-according-to-designs-from-tim-watson
@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@changeset-bot
Copy link

changeset-bot bot commented Feb 24, 2026

🦋 Changeset detected

Latest commit: afd79ba

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@youversion/platform-core Patch
@youversion/platform-react-hooks Patch
@youversion/platform-react-ui Patch
nextjs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 24, 2026

Greptile Summary

This PR adds previous/next chapter navigation buttons to the Bible Reader toolbar with full cross-book navigation support and intro chapter handling. The implementation follows clean separation of concerns: pure navigation logic in @youversion/platform-core, React hook integration in @youversion/platform-react-hooks, and UI components in @youversion/platform-react-ui.

Key Changes:

  • Added getAdjacentChapter utility to core package with comprehensive test coverage for cross-book navigation and intro chapters
  • Refactored useChapterNavigation hook to support cross-book navigation using the new core utility
  • Updated Bible Reader toolbar with embedded prev/next buttons inside the chapter picker button, following new design approach
  • Added chevron icon components and touch-hitbox utility (44px minimum) for mobile accessibility
  • Fixed USFM list item styling to use hanging indents without bullets per specification
  • Books data now lifted into BibleReaderContext to avoid duplicate API requests (addresses previous review feedback)
  • All navigation buttons include aria-label attributes for screen reader accessibility (addresses previous review feedback)

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Strong implementation with comprehensive test coverage, clean architecture following package dependency order (core → hooks → ui), and all previous review feedback addressed. Navigation logic is well-tested with 13 test cases covering edge cases.
  • No files require special attention

Important Files Changed

Filename Overview
packages/core/src/getAdjacentChapter.ts Well-tested pure logic for cross-book chapter navigation with comprehensive intro chapter support
packages/hooks/src/useChapterNavigation.ts Refactored to use getAdjacentChapter for cross-book navigation with proper book/chapter state updates
packages/ui/src/components/bible-reader.tsx Added prev/next buttons with cross-book navigation, updated toolbar layout; aria-labels added per previous feedback
packages/ui/src/styles/global.css Added touch-hitbox utility with 44px minimum touch target for accessibility

Last reviewed commit: a620e96

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

9 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Adjust CSS for list items (`li`, `lim`) to use hanging indents and block
display, improving readability and visual consistency within the Bible
reader component.
- Add aria-label to prev/next chevron buttons for screen readers
- Remove unnecessary !! double negation on bookData?.intro
- Simplify getNext by removing else block in favor of guard clause
- Use genChapters.at(-1) for clarity in cross-book test
- Add aria-label to prev/next chevron buttons for accessibility
- Remove !! double negation on bookData?.intro
- Simplify getNext by replacing else with guard clause
- Use genChapters.at(-1) for clarity in cross-book test
- Add explicit list-style-type: none to li/lim rules per USFM spec
- Add test for mixed intro/no-intro cross-book navigation
- Add changeset for patch bump across all packages
@cameronapak cameronapak self-assigned this Feb 24, 2026
@cameronapak
Copy link
Collaborator Author

@greptileai, I've made changes since you last reviewed. Please re-review this PR

Refine the aria-label for the BibleChapterPicker.Trigger and remove an
assertion from a story that incorrectly expected the H1 to be absent
from intro chapters.
@cameronapak cameronapak requested a review from camrun91 February 24, 2026 18:35
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

11 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@cameronapak
Copy link
Collaborator Author

Hey @camrun91, this PR is now ready for review. This PR adds the previous chapter and next chapter buttons to the React web BibleReader component. Long story short, I let Tim Watson know we didn't have that feature, and him and I came up with a design for it. This is the implementation.

One important thing to know is that this is built upon the work of #151 for intro chapters. That is being reviewed by David at this time, but it doesn't block this from being reviewed.

If you have any questions, please let me know. I'm an open book.

@cameronapak
Copy link
Collaborator Author

@bmanquen here's how I approached the previous and next chapter buttons and functionality on React web. It may be able to help you with Kotlin

Expose the fetched book data and loading state from the `useBooks` hook
within the `BibleReaderContext`. This allows child components to
directly access and utilize this information without re-fetching or
reimplementing logic.
@cameronapak
Copy link
Collaborator Author

@greptileai, please re-re-review. I've made the updates you requested

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

12 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Base automatically changed from YPE-1332-react-sdk-bible-reader-render-introduction-chapter to main February 24, 2026 22:29
…dd-prev-and-next-chapter-buttons-in-the-bible-reader-toolbar-according-to-designs-from-tim-watson
Copy link
Collaborator

@camrun91 camrun91 left a comment

Choose a reason for hiding this comment

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

LGTM I only have one question

…dd-prev-and-next-chapter-buttons-in-the-bible-reader-toolbar-according-to-designs-from-tim-watson
@cameronapak cameronapak merged commit a5f91bf into main Feb 25, 2026
5 checks passed
@cameronapak cameronapak deleted the cp/YPE-1343-react-sdk-bible-reader-toolbar-add-prev-and-next-chapter-buttons-in-the-bible-reader-toolbar-according-to-designs-from-tim-watson branch February 25, 2026 16:28
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