Add dynamic style injection and transition safety#6
Open
krataratha wants to merge 1 commit into
Open
Conversation
Enhanced chapter transition with dynamic styles and safety.
There was a problem hiding this comment.
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
localStepused 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'}`} |
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.
Enhanced chapter transition with dynamic styles and safety.