Skip to content

YPE-1332: Render introduction chapter#151

Open
cameronapak wants to merge 23 commits intomainfrom
YPE-1332-react-sdk-bible-reader-render-introduction-chapter
Open

YPE-1332: Render introduction chapter#151
cameronapak wants to merge 23 commits intomainfrom
YPE-1332-react-sdk-bible-reader-render-introduction-chapter

Conversation

@cameronapak
Copy link
Collaborator

@cameronapak cameronapak commented Feb 16, 2026

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.
@changeset-bot
Copy link

changeset-bot bot commented Feb 16, 2026

⚠️ No Changeset found

Latest commit: aa95330

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

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
@cameronapak cameronapak marked this pull request as ready for review February 17, 2026 04:06
@cameronapak cameronapak self-assigned this Feb 17, 2026
@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.

@cameronapak cameronapak requested a review from bmanquen February 17, 2026 04:06
@cameronapak cameronapak changed the title WIP: YPE-1332 react sdk bible reader render introduction chapter YPE-1332: Render introduction chapter Feb 17, 2026
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.
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 17, 2026

Greptile Summary

This PR adds support for rendering Bible introduction chapters (e.g., JHN.INTRO) in the reader component. It introduces an intro button (InfoIcon) in the chapter picker grid, hides the book/chapter h1 header for non-numerical chapters, shows an "unavailable" message when a chapter doesn't exist in the selected version, and displays a user-friendly label (e.g., "Intro") in the toolbar trigger. The CSS changes are substantial: ~60 new USFM class styles for introduction content, a switch from fixed CSS variable values to inherit-based cascading for proper em-relative sizing, and conversion of physical properties to logical properties for RTL support.

  • Intro chapters are detected via bookData.intro?.id matching the current chapter, and an availability check (chapterUnavailable) prevents rendering BibleTextView for missing chapters
  • The BibleChapterPicker.Trigger render prop now passes a display label for chapter instead of the raw chapter ID — this is a behavioral change for external consumers (see inline comment)
  • Toolbar grid layout is now conditionally sized based on whether auth is enabled (grid-cols-[auto_1fr_auto] vs grid-cols-[1fr_auto])
  • CSS .imte moved from the hidden metadata group to a visible styled block, which is correct for intro rendering
  • The .pc/.qc classes had font-variant: small-caps and font-weight: bold removed to align with the USFM specification
  • No changeset entry was added — expected for a WIP PR but will be needed before merge

Confidence Score: 4/5

  • This PR is well-structured with proper test coverage via Storybook; the main concern is the chapter render prop semantic change for external consumers.
  • Score reflects solid implementation with good test coverage, comprehensive CSS additions for USFM intro content, and proper RTL logical property conversion. Deducted one point for the behavioral change in the Trigger render prop's chapter parameter which could break external consumers, and the WIP status indicating further changes are expected.
  • Pay close attention to packages/ui/src/components/bible-chapter-picker.tsx for the render prop behavioral change, and packages/ui/src/styles/bible-reader.css due to its large scope of CSS changes.

Important Files Changed

Filename Overview
packages/ui/src/components/bible-reader.tsx Adds intro chapter rendering logic: hides h1 header for non-numerical chapters, adds chapter availability check with useMemo, and shows unavailable message. Also conditionally adjusts toolbar grid layout based on auth. Well-structured changes with proper memoization.
packages/ui/src/components/bible-chapter-picker.tsx Adds intro button (InfoIcon) to chapter grid, refactors intro chapters out of the chapter list rendering, and changes Trigger's chapter render prop to pass display label instead of raw ID. Includes JSDoc update documenting the behavioral change.
packages/ui/src/styles/bible-reader.css Major CSS refactoring: switches from fixed var() values on & * to inherit-based cascade, converts physical properties (padding-left, text-align: right) to logical properties (padding-inline-start, text-align: end) for RTL, adds ~60 new USFM class styles for introduction content, and unhides .imte for proper intro rendering.
packages/ui/src/components/bible-reader.stories.tsx Adds IntroChapter story with integration tests for intro chapter rendering, h1 visibility, unavailable message absence, and toolbar label display. Test coverage is good but uses a slightly fragile querySelector('p') check.
packages/ui/src/test/mock-data/books.ts Adds intro field to JHN mock book data matching the BibleBookIntroSchema shape (id, passage_id, title). Straightforward and correct.
packages/ui/src/test/mocks/handlers.ts Adds MSW handler for JHN.INTRO passage endpoint returning mock intro HTML content with USFM classes (imt, im, ip, qt). Clean addition.

Flowchart

flowchart TD
    A["User selects chapter\n(chapter picker)"] --> B{Is chapter intro?}
    B -->|Yes| C["Set chapter = intro.passage_id\n(e.g. 'INTRO')"]
    B -->|No| D["Set chapter = chapterId\n(e.g. '1')"]
    C --> E["BibleReader.Content renders"]
    D --> E
    E --> F{chapterIsNumerical?}
    F -->|Yes| G["Show h1 header\n(book title + chapter number)"]
    F -->|No| H["Hide h1 header"]
    G --> I{chapterUnavailable?}
    H --> I
    I -->|Yes| J["Show unavailable message"]
    I -->|No| K["Render BibleTextView\n(USFM content)"]
    E --> L["Toolbar.Trigger"]
    L --> M["Resolve display label\n(chapter title or 'Intro')"]
    M --> N["Show: 'John Intro'"]
Loading

Last reviewed commit: 9dc55a9

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.

6 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

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.
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.

1 participant