Skip to content

Add dynamic style injection and transition safety#6

Open
krataratha wants to merge 1 commit into
ConardLi:mainfrom
krataratha:patch-1
Open

Add dynamic style injection and transition safety#6
krataratha wants to merge 1 commit into
ConardLi:mainfrom
krataratha:patch-1

Conversation

@krataratha

Copy link
Copy Markdown

Enhanced chapter transition with dynamic styles and safety.

Enhanced chapter transition with dynamic styles and safety.
Copilot AI review requested due to automatic review settings May 11, 2026 04:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates ChapterHost to support chapter-specific inline style injection during chapter transitions, and adjusts transition behavior when navigating between chapters.

Changes:

  • Adds memoized selection of the active chapter and composes inline styles with (intended) chapter-provided style overrides.
  • Refactors the chapter transition timeout handling (naming/cleanup) and tweaks transition transform distance.
  • Adjusts the fallback localStep used while transitioning between chapters, attempting to account for navigation direction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +30 to +42
const Active = useMemo(() => chapters[renderedIdx] ?? chapters[chapterIndex], [renderedIdx, chapterIndex]);

// New Feature: Composite styles for chapter-specific branding
const compositeStyles = {
position: 'absolute' as const,
inset: 0,
background: 'var(--bg)',
color: 'var(--fg)',
opacity: phase === 'in' ? 1 : 0,
transform: `translateY(${phase === 'in' ? '0' : '12px'})`,
transition: 'opacity 220ms ease, transform 220ms ease, background 480ms ease',
...Active.styles // Allows chapters to inject specific CSS variables (e.g., --accent)
};
<Component
localStep={renderedIdx === chapterIndex ? localStep : Active.steps - 1}
<Active.Component
localStep={renderedIdx === chapterIndex ? localStep : (direction === 'prev' ? 0 : Active.steps - 1)}
return (
<div
className={`chapter-host ${themeClass}`}
className={`chapter-host theme-${Active.theme ?? 'default'}`}
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