@@ -24,10 +24,12 @@ import { onTabSwitch, offTabSwitch } from '../tabbed'
24
24
import { OrderedGraph , blocks , compile , order , sequence } from '../code/graph'
25
25
26
26
import Card from '../../../../spi/Card'
27
+ import Icons from '../../../../spi/Icons'
27
28
import { MiniProgressStepper , StepperProps } from '../../../MiniProgressStepper'
28
29
import { ProgressStepState , statusFromStatusVector } from '../../../ProgressStepper'
29
30
import { subscribeToLinkUpdates , unsubscribeToLinkUpdates } from '../../../LinkStatus'
30
31
32
+ import '../../../../../../web/scss/components/Wizard/_index.scss'
31
33
import '../../../../../../web/scss/components/Wizard/PatternFly.scss'
32
34
33
35
const PatternFlyWizard = React . lazy ( ( ) => import ( '@patternfly/react-core' ) . then ( _ => ( { default : _ . Wizard } ) ) )
@@ -37,6 +39,9 @@ type Status = ProgressStepState['status']
37
39
type Props = WizardProps & { uuid : string }
38
40
39
41
export interface State {
42
+ /** Is the wizard in "collapsed" mode, where we only show the title and progress bar? */
43
+ collapsedHeader : boolean
44
+
40
45
/** Graph of code blocks across all steps */
41
46
graph : OrderedGraph
42
47
@@ -85,6 +90,7 @@ export default class Wizard extends React.PureComponent<Props, State> {
85
90
return {
86
91
status,
87
92
choices,
93
+ collapsedHeader : ! state ? false : state . collapsedHeader ,
88
94
codeBlocksPerStep : noChangeToCodeBlocks ? state . codeBlocksPerStep : codeBlocksPerStep ,
89
95
graph : noChangeToCodeBlocks ? state . graph : order ( sequence ( codeBlocks . filter ( Boolean ) ) )
90
96
}
@@ -189,6 +195,43 @@ export default class Wizard extends React.PureComponent<Props, State> {
189
195
return ( props . children || [ ] ) . slice ( 1 )
190
196
}
191
197
198
+ private readonly _toggleCollapsedHeader = ( ) =>
199
+ this . setState ( curState => ( { collapsedHeader : ! curState . collapsedHeader } ) )
200
+
201
+ private headerActions ( ) {
202
+ return (
203
+ < div className = "kui--wizard-header-action-buttons" >
204
+ < a className = "kui--wizard-collapse-button kui--block-action" onClick = { this . _toggleCollapsedHeader } >
205
+ < Icons icon = { this . state . collapsedHeader ? 'WindowMaximize' : 'WindowMinimize' } />
206
+ </ a >
207
+ </ div >
208
+ )
209
+ }
210
+
211
+ private title ( ) {
212
+ const label = this . props [ 'data-kui-title' ] . trim ( )
213
+ return (
214
+ < div className = "kui--wizard-header-title" aria-label = { label } >
215
+ { label }
216
+ </ div >
217
+ )
218
+ }
219
+
220
+ private description ( ) {
221
+ return < div className = "kui--wizard-header-description" > { this . props . children [ 0 ] } </ div >
222
+ }
223
+
224
+ private header ( ) {
225
+ return (
226
+ < div className = "kui--wizard-header kui--inverted-color-context" >
227
+ { this . headerActions ( ) }
228
+ { this . title ( ) }
229
+ { this . description ( ) }
230
+ { this . progress ( ) }
231
+ </ div >
232
+ )
233
+ }
234
+
192
235
private wizard ( ) {
193
236
const steps = Wizard . children ( this . props ) . map ( ( _ , stepIdx ) => ( {
194
237
name : _ . props [ 'data-kui-title' ] ,
@@ -198,25 +241,18 @@ export default class Wizard extends React.PureComponent<Props, State> {
198
241
component : < Card className = "kui--markdown-tab-card" > { _ . props && _ . props . children } </ Card >
199
242
} ) )
200
243
201
- const progress = this . progress ( )
202
-
203
244
// onGoToStep={this._onWizardStepChange} onNext={this._onWizardStepChange} onBack={this._onWizardStepChange}
204
245
return (
205
- < PatternFlyWizard
206
- hideClose
207
- steps = { steps . length === 0 ? [ { name : '' , component : '' } ] : steps }
208
- className = "kui--wizard"
209
- data-hide-cancel = { true }
210
- data-bottom-margin = { ! progress /* no bottom margin if we're showing a progress bar */ }
211
- footer = { this . footer ( ) }
212
- title = { this . props [ 'data-kui-title' ] . trim ( ) }
213
- description = {
214
- < React . Fragment >
215
- { this . props . children [ 0 ] }
216
- { progress }
217
- </ React . Fragment >
218
- }
219
- />
246
+ < div className = "kui--wizard" data-collapsed-header = { this . state . collapsedHeader || undefined } >
247
+ { this . header ( ) }
248
+ < div className = "kui--wizard-main-content" >
249
+ < PatternFlyWizard
250
+ steps = { steps . length === 0 ? [ { name : '' , component : '' } ] : steps }
251
+ data-hide-cancel = { true }
252
+ footer = { this . footer ( ) }
253
+ />
254
+ </ div >
255
+ </ div >
220
256
)
221
257
}
222
258
0 commit comments