Repository navigation
fix(ui): BibleCard, VerseOfTheDay - keep SDK components from shifting while they load - #515
Open
cameronapak wants to merge 12 commits into
Open
cameronapak wants to merge 12 commits into
cameronapak wants to merge 12 commits into
Conversation
cameronapak
marked this pull request as draft
December 3, 2026 17:20
BibleCard and VerseOfTheDay reserve the height of a typical verse while the passage loads, BibleCard's version button and the Reader's book title keep their loaded size, and Inter and Untitled Serif get metric-matched local fallbacks generated from the real font files, so the font swap does not move text. Amp-Thread-ID: https://ampcode.com/threads/T-01a23831-2d77-77fd-9e5e-e91ef59406bf
cameronapak
force-pushed
the
fix/ui-layout-shift
branch
from
December 4, 2026 11:11
bae44f0 to
10e8d9e
Compare
🦋 Changeset detectedLatest commit: c69d034 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
Found with break-ui using real versions: a copyright with a bare URL pushed BibleCard's logo out of the card at 320px; at 200% zoom the version button and VOTD share button left their cards; the VOTD eyebrow clamped to "VER…"; right-to-left references put the abbreviation first; and AnimatedHeight clipped glyph overhang horizontally. Amp-Thread-ID: https://ampcode.com/threads/T-01a23831-2d77-77fd-9e5e-e91ef59406bf
The copyright line added in #518 appeared at full height when the verse arrived, outside AnimatedHeight, so content below jumped 24px at once (CLS 0.049 at 390px on Slow 4G). Keeping one empty line in its place while loading brings that to 0.014, the remaining difference being the verse's own length versus the typical-verse reservation. Amp-Thread-ID: https://ampcode.com/threads/T-01a23831-2d77-77fd-9e5e-e91ef59406bf
From mobile-native: Scripture in cards (data-selectable=false) was user-select: none with the touch callout disabled, so readers could not long-press to copy a verse; the Reader, where taps select verses, keeps that behavior. SDK buttons and the footnote marker get touch-action: manipulation so taps fire without the double-tap delay, and the card share and version buttons press down on touch. Amp-Thread-ID: https://ampcode.com/threads/T-01a23831-2d77-77fd-9e5e-e91ef59406bf
From review-animations: - Button transitioned `all` on the default ease; it now transitions only color, background, border, shadow, opacity, scale, and transform over 150ms on a strong ease-out. Tailwind v4 scale utilities set `scale`, so the card press feedback now actually animates. - Press feedback is motion-safe only. - AnimatedHeight drops from 300ms ease-out to 200ms on the same strong curve; with the loading reservation it only covers the remaining difference. - Popovers keep their trigger origin and 150ms, on the strong curve; with reduced motion they fade without zooming or sliding. Amp-Thread-ID: https://ampcode.com/threads/T-01a23831-2d77-77fd-9e5e-e91ef59406bf
From emil-design-eng: the version picker popover opened and closed in 150ms. Closing is the system responding, so it now takes 100ms; opening keeps 150ms. Also updates the changeset for this PR's later fixes. Amp-Thread-ID: https://ampcode.com/threads/T-01a23831-2d77-77fd-9e5e-e91ef59406bf
The metric-matched Times fallback sits before Source Serif 4 in the serif stack, so a failed gated stylesheet or font left readers on Times. Remove the fallback when the brand font fails and keep later mounts from reinstalling it. Amp-Thread-ID: https://ampcode.com/threads/T-01a23831-2d77-77fd-9e5e-e91ef59406bf
…yrights The loading placeholder now sits in a .p paragraph like the passage, so it gets the same indent and bottom margin, and the copyright uses a 1.2 line height instead of inheriting 24px lines. A new story holds the passage request and checks that a typical verse loads within one line of the reserved height at phone and desktop widths. A copyright longer than about four lines beside the logo now takes the full width with the logo underneath, so it is not squeezed into a narrow column. Amp-Thread-ID: https://ampcode.com/threads/T-01a23831-2d77-77fd-9e5e-e91ef59406bf
…ce words overflow-wrap:anywhere let the reference shrink below its longest word, so at 320px the version button stayed beside it and words split mid-word (THESSALONIAN/ME). The reference now keeps its longest word's width, capped at the row, so the button wraps underneath; only a word wider than the whole card breaks. Amp-Thread-ID: https://ampcode.com/threads/T-01a23831-2d77-77fd-9e5e-e91ef59406bf
At 200% zoom on a phone, the reference had about 80px between the sun icon and the share button, so overflow-wrap:anywhere split words mid-word. When the card content is under 13rem, the icon and share button now share the top row and the eyebrow and reference take the full width below. The reference breaks only words wider than the whole card.
cameronapak
marked this pull request as ready for review
December 4, 2026 12:51
The search popover dropped its animation entirely under reduced motion, so it popped in and out. The shared popover already removes zoom and slide under reduced motion and keeps the fade, so the override is removed. Document the motion guidance in packages/ui/AGENTS.md: prefer transform and opacity, allow short height reveals such as AnimatedHeight that turn off under reduced motion, and keep fades under reduced motion. Measured on Slow 4G with 4x CPU, AnimatedHeight scored lower CLS than an instant snap in every case. Amp-Thread-ID: https://ampcode.com/threads/T-01a23831-2d77-77fd-9e5e-e91ef59406bf
React merges style resources that share a precedence into one tag. The server-rendered Untitled Serif fallback shared yv-sdk-fonts with the base fonts, so when the brand font failed, removeBrandFontFallback deleted the merged tag, including the Google Fonts import and the Inter fallback. Give the brand fallback its own precedence so only its rules are removed. Amp-Thread-ID: https://ampcode.com/threads/T-01a23831-2d77-77fd-9e5e-e91ef59406bf
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira: YPE-6878
New here? Start here
What's this? Several SDK UI components change size after they first appear on screen, which pushes everything below them around while a page loads.
VerseOfTheDay(VOTD) andBibleCardgrow from a small spinner to the full verse,BibleCard's version button widens when its abbreviation arrives, the Bible Reader's title line grows when book data arrives, and text reflows when the web fonts (Inter and Untitled Serif) replace the fallback font. This PR makes each of them reserve about their final size before the content arrives. It also makesBibleCardand VOTD hold up with long text, zoom, touch, and reduced motion.Why does it matter? Content that jumps while it loads is hard to read and easy to mis-tap, because buttons move under the user's finger. On a throttled phone, the Reader's text jumped about 26px down and back up as fonts loaded, and VOTD pushed the content below it down by up to 177px.
Who does it affect? People using any app that renders these components, most noticeably on phones and slow connections. Integrators don't need to change anything: there are no API or prop changes.
What happens if we leave this as-is? The jumps continue. Host apps such as the web sample (#514) keep a stopgap that reserves a fixed height around these components.
Before / after
Measured in
examples/vite-reactwith the live API: Slow 4G, cache disabled, and 4× CPU throttling at 390px. Each component renders by itself with a gray block below it. Before ismain(919a8a4), after is this branch. Red boxes mark elements the browser reported as shifted.VOTD, typical verse (James 1:19, 107 characters), 390px: before, both cards grow from a spinner and push the gray block down in steps. After, the cards open at their loaded height and nothing moves. (MP4)
BibleCard (John 3:16), 390px: before, the card grows from a spinner and the version button widens. After, the card opens at about its loaded height and the button keeps its width. (MP4)
Bible Reader, 390px: before, the text drops when the book title arrives, then jumps again when the web fonts replace the fallbacks. After, the title line holds its height and paragraphs keep their size through the font swap. (MP4)
Cumulative layout shift (CLS) while loading, where lower is better and 0 means nothing moved:
main)The loading state reserves the space of a median-length verse, so verses much shorter or longer than that still move a little when they arrive. The short-verse row shrinks instead of growing, which is why it barely changes.
BibleCard with worst-case data, 320px: before, a long reference squeezes beside the version button, and a copyright with a bare URL pushes the Bible App logo out of the card ("Bible A"). After, the version button wraps under the reference, words stay whole, and long copyrights span the card with the logo underneath.
BibleCard with long copyrights, 1440px: a copyright longer than about four lines beside the logo now spans the card with the logo underneath. A 4-line copyright keeps the logo beside it.
VOTD at 200% zoom, 390px phone: before, the eyebrow is clipped to "VERSE OF THE…" and the share button is pushed out of the card. After, the sun icon and share button share the top row, and the eyebrow and reference take the full width below with words kept whole.
What changed
Loading without layout shift
BibleTextPlaceholderrenders about 100 characters of invisible text, the median VOTD length (40 days sampled: p25 80, median 104, p75 145 characters). It uses the passage's own font, size, line height, and.pparagraph margin, with the spinner centered over it. It wraps at the card's real width, so it reserves the right height on phones and desktops.BibleCardand VOTD use it in place of the bare spinner.min-w-[3ch]box, the pattern the Reader toolbar already uses, so the button keeps about its loaded width. The 8px copyright now usesleading-[1.2]instead of inheriting 24px lines, so a two-line copyright no longer makes the footer taller than the logo.yv-fonts.tsxdeclaresYV Inter Fallback(local Arial or Liberation Sans) andYV Untitled Serif Fallback(local Times New Roman or Liberation Serif). Theirsize-adjustand ascent and descent overrides were generated from the real font files with Capsize, for each weight the SDK renders (400, 500, 700). So text takes the same space before and after the web font arrives. No font files are added; these rules only resize fonts already on the device.@font-face.--yv-font-sansand--yv-font-serif(coretheme.css, uiglobal.css,chrome.css) and the Reader's rendered font stack include the fallbacks. Persisted Reader font values are unchanged.Worst-case data and zoom
<bdi>, so in right-to-left Scripture the abbreviation follows the reference.text-wrap: balancethe copyright uses.AnimatedHeightclips only vertically, so horizontal overflow such as focus rings isn't cut off.Touch and motion
user-select: text, default touch callout). The Reader keeps its own selection behavior.touch-manipulation, which removes the double-tap zoom delay. The cards' share and version buttons press down toscale(0.97)on touch.Buttontransitions only color, background, border, shadow, opacity,scale, andtransform, notall, over 150ms oncubic-bezier(0.23, 1, 0.32, 1). The press effect runs only undermotion-safe.AnimatedHeightruns 200ms on the same curve. Popovers open in 150ms and close in 100ms. With reduced motion they only fade, with no zoom or slide. The search popover now does the same instead of dropping its animation entirely.packages/ui/AGENTS.mddocuments the motion guidance: prefer transform and opacity, allow short height reveals such asAnimatedHeightthat turn off under reduced motion, and keep fades under reduced motion. On Slow 4G with 4× CPU,AnimatedHeightscored lower CLS than an instant snap in every case measured.Known limits
Verification
pnpm --filter @youversion/platform-react-ui exec vitest run --project unit): 687 passed. New: the Untitled Serif fallback is removed when the gated stylesheet fails, and later mounts don't reinstall it.--project storybook): 136 passed.BibleCardstoryLoadingReservesTypicalHeightholds a typical passage (Isaiah 40:31) while it measures the loading card at 358px and 700px. It checks that the loaded card is within one passage line of the loading card. It fails when the placeholder is shortened (71px off) or loses its paragraph margin (29px off).LoadsSavedPreferencesFromLocalStoragenow expects the rendered stack with the fallback, while the persisted value staysUNTITLED_SERIF_FONT.oxlint, Prettier,tsc,size-limit, and the UI build's style verification pass.steady-loading-layout.md, patch for@youversion/platform-coreand@youversion/platform-react-ui.Confidence Score: 5/5

The PR appears safe to merge; the previous font cleanup issue is fixed.Summary
This PR reserves loading space for Bible cards and improves font fallbacks, narrow layouts, touch behavior, and reduced motion.
Reviews (4) · Last reviewed commit: "fix(ui): keep base fonts when the brand ..." · Reviewed by Greptile