1- import React from "react" ;
1+ import React , { Fragment } from "react" ;
22import classNames from "classnames" ;
3- import _ from "lodash ";
3+ import "./wizard.css ";
44
5- const Step = ( { stepNumber, currentStep } ) => {
6- const isCurrentOrPastStep = stepNumber < = currentStep ;
5+ const Step = ( { stepNumber, currentStep, page } ) => {
6+ const isCurrentStep = stepNumber == = currentStep ;
77 return (
8- < div
9- className = { classNames ( "fa" , {
10- "fa-circle" : isCurrentOrPastStep ,
11- "fa-circle-o" : ! isCurrentOrPastStep
8+ < span
9+ className = { classNames ( "step" , {
10+ active : isCurrentStep
1211 } ) }
1312 />
1413 ) ;
@@ -17,7 +16,7 @@ const Step = ({ stepNumber, currentStep }) => {
1716const NextButton = ( { isLastPage, handleDone, handleNext } ) => (
1817 < button
1918 id = "wizard-doneNextButton"
20- className = "btn btnDefault "
19+ className = "nextBtn "
2120 onClick = { e => {
2221 e . target . blur ( ) ;
2322 return isLastPage ? handleDone ( ) : handleNext ( ) ;
@@ -32,7 +31,7 @@ const BackButton = ({ currentPage, handleBack }) => (
3231 { ! ! currentPage && (
3332 < button
3433 id = "wizard-backButton"
35- className = "btn btnSecondary "
34+ className = "prevBtn "
3635 onClick = { e => {
3736 e . target . blur ( ) ;
3837 handleBack ( ) ;
@@ -47,40 +46,19 @@ const BackButton = ({ currentPage, handleBack }) => (
4746const CancelButton = ( { handleCancel } ) => (
4847 < button
4948 id = "wizard-cancelButton"
50- className = "btn btnSecondary "
49+ className = "prevBtn "
5150 onClick = { ( ) => handleCancel ( ) }
5251 >
5352 Cancel
5453 </ button >
5554) ;
5655
57- const WizardBreadCrub = ( { steps, currentStep } ) => (
58- < div className = "stepcntnr" >
59- < div className = "stepper" >
60- { _ . range ( 1 , 2 * steps . length ) . map ( s => {
61- if ( s % 2 === 0 ) {
62- return < div key = { `line${ s } ` } className = "line" /> ;
63- }
64-
65- const stepNumber = s === 1 ? s : Math . ceil ( s / 2 ) ;
66- return (
67- < Step
68- key = { stepNumber }
69- stepNumber = { stepNumber }
70- title = { steps [ stepNumber - 1 ] . title }
71- currentStep = { currentStep }
72- />
73- ) ;
74- } ) }
75- </ div >
76- < div className = "steps" >
77- { steps . map ( s => (
78- < div key = { s . title } className = "steptext" >
79- { s . title }
80- </ div >
81- ) ) }
82- </ div >
83- </ div >
56+ const WizardBreadCrub = ( { pages, currentStep } ) => (
57+ < ul className = "wizard" >
58+ { pages . map ( ( page , index ) => (
59+ < Step stepNumber = { index + 1 } currentStep = { currentStep } page = { page } />
60+ ) ) }
61+ </ ul >
8462) ;
8563
8664const Wizard = ( {
@@ -92,38 +70,41 @@ const Wizard = ({
9270 handleDone,
9371 isLastPage
9472} ) => (
95- < div className = "mcontentcntnr" >
96- < WizardBreadCrub steps = { pages } currentStep = { currentPage + 1 } / >
73+ < div >
74+ < h3 > { pages && pages [ currentPage ] && pages [ currentPage ] . title } </ h3 >
9775 { currentPage >= 0 &&
9876 React . createElement ( pages [ currentPage ] . component , {
9977 ...pages [ currentPage ] . props
10078 } ) }
101- < div className = "action" >
102- { currentPage >= 0 && pages [ currentPage ] . navigationBarComponent ? (
103- pages [ currentPage ] . navigationBarComponent ( {
104- nextButton : (
79+ < WizardBreadCrub pages = { pages } currentStep = { currentPage + 1 } />
80+ < div style = { { overflow : "auto" } } >
81+ < div style = { { float : "right" } } >
82+ { currentPage >= 0 && pages [ currentPage ] . navigationBarComponent ? (
83+ pages [ currentPage ] . navigationBarComponent ( {
84+ nextButton : (
85+ < NextButton
86+ isLastPage = { isLastPage }
87+ handleDone = { handleDone }
88+ handleNext = { handleNext }
89+ />
90+ ) ,
91+ backButton : (
92+ < BackButton currentPage = { currentPage } handleBack = { handleBack } />
93+ ) ,
94+ cancelButton : < CancelButton handleCancel = { handleCancel } />
95+ } )
96+ ) : (
97+ < Fragment >
10598 < NextButton
10699 isLastPage = { isLastPage }
107100 handleDone = { handleDone }
108101 handleNext = { handleNext }
109102 />
110- ) ,
111- backButton : (
112103 < BackButton currentPage = { currentPage } handleBack = { handleBack } />
113- ) ,
114- cancelButton : < CancelButton handleCancel = { handleCancel } />
115- } )
116- ) : (
117- < div >
118- < NextButton
119- isLastPage = { isLastPage }
120- handleDone = { handleDone }
121- handleNext = { handleNext }
122- />
123- < BackButton currentPage = { currentPage } handleBack = { handleBack } />
124- < CancelButton handleCancel = { handleCancel } />
125- </ div >
126- ) }
104+ < CancelButton handleCancel = { handleCancel } />
105+ </ Fragment >
106+ ) }
107+ </ div >
127108 </ div >
128109 </ div >
129110) ;
0 commit comments