33 */
44
55import React from 'react'
6+ import { TextAttributes } from '@opentui/core'
67import { useTheme } from '../../../hooks/use-theme'
8+ import { Button } from '../../button'
9+ import { BORDER_CHARS } from '../../../utils/ui-constants'
710import { ProgressIndicator } from './progress-indicator'
811import { SkipButton } from './skip-button'
912
@@ -13,6 +16,9 @@ export interface QuestionHeaderProps {
1316 answeredStates : boolean [ ]
1417 allAnswered : boolean
1518 onSkip ?: ( ) => void
19+ onNavigate ?: ( index : number ) => void
20+ onPrev ?: ( ) => void
21+ onNext ?: ( ) => void
1622 skipButtonFocused ?: boolean
1723 skipButtonHovered ?: boolean
1824 onSkipMouseOver ?: ( ) => void
@@ -26,13 +32,18 @@ export const QuestionHeader: React.FC<QuestionHeaderProps> = ({
2632 answeredStates,
2733 allAnswered,
2834 onSkip,
35+ onNavigate,
36+ onPrev,
37+ onNext,
2938 skipButtonFocused = false ,
3039 skipButtonHovered = false ,
3140 onSkipMouseOver,
3241 onSkipMouseOut,
3342 hasRoomForInlineButtons,
3443} ) => {
3544 const theme = useTheme ( )
45+ const isFirstQuestion = currentIndex === 0
46+ const isLastQuestion = currentIndex === totalQuestions - 1
3647
3748 return (
3849 < box
@@ -49,29 +60,72 @@ export const QuestionHeader: React.FC<QuestionHeaderProps> = ({
4960 < text style = { { fg : theme . secondary } } >
5061 Question { currentIndex + 1 } of { totalQuestions }
5162 </ text >
52- { totalQuestions > 1 && (
53- < text style = { { fg : theme . muted } } > (← → to navigate)</ text >
54- ) }
5563 </ box >
5664 { totalQuestions > 1 && (
5765 < ProgressIndicator
5866 currentIndex = { currentIndex }
5967 answeredStates = { answeredStates }
6068 allAnswered = { allAnswered }
69+ onNavigate = { onNavigate }
6170 />
6271 ) }
6372 </ box >
6473
65- { /* Right side: Skip button (if room) */ }
66- { hasRoomForInlineButtons && onSkip && (
67- < box style = { { flexDirection : 'row' , gap : 2 } } >
68- < SkipButton
69- onClick = { onSkip }
70- isFocused = { skipButtonFocused }
71- isHovered = { skipButtonHovered }
72- onMouseOver = { onSkipMouseOver }
73- onMouseOut = { onSkipMouseOut }
74- />
74+ { /* Right side: Navigation and Skip buttons (if room) */ }
75+ { hasRoomForInlineButtons && (
76+ < box style = { { flexDirection : 'row' , gap : 1 } } >
77+ { /* Navigation buttons (only show for multi-question forms) */ }
78+ { totalQuestions > 1 && (
79+ < >
80+ < Button
81+ onClick = { onPrev }
82+ style = { {
83+ borderStyle : 'single' ,
84+ borderColor : isFirstQuestion ? theme . muted : theme . secondary ,
85+ customBorderChars : BORDER_CHARS ,
86+ paddingLeft : 1 ,
87+ paddingRight : 1 ,
88+ } }
89+ >
90+ < text
91+ style = { {
92+ fg : isFirstQuestion ? theme . muted : theme . foreground ,
93+ attributes : isFirstQuestion ? undefined : TextAttributes . BOLD ,
94+ } }
95+ >
96+ ←
97+ </ text >
98+ </ Button >
99+ < Button
100+ onClick = { onNext }
101+ style = { {
102+ borderStyle : 'single' ,
103+ borderColor : isLastQuestion ? theme . muted : theme . secondary ,
104+ customBorderChars : BORDER_CHARS ,
105+ paddingLeft : 1 ,
106+ paddingRight : 1 ,
107+ } }
108+ >
109+ < text
110+ style = { {
111+ fg : isLastQuestion ? theme . muted : theme . foreground ,
112+ attributes : isLastQuestion ? undefined : TextAttributes . BOLD ,
113+ } }
114+ >
115+ →
116+ </ text >
117+ </ Button >
118+ </ >
119+ ) }
120+ { onSkip && (
121+ < SkipButton
122+ onClick = { onSkip }
123+ isFocused = { skipButtonFocused }
124+ isHovered = { skipButtonHovered }
125+ onMouseOver = { onSkipMouseOver }
126+ onMouseOut = { onSkipMouseOut }
127+ />
128+ ) }
75129 </ box >
76130 ) }
77131 </ box >
0 commit comments