@@ -2,23 +2,28 @@ import React from 'react';
22import ReactDOM from 'react-dom/client' ;
33import './index.css' ;
44import {
5- IgrStepper , IgrStep , StepperOrientation , StepperTitlePosition , IgrStepperModule , IgrStepModule , IgrRadio , IgrRadioGroup ,
6- IgrRadioChangeEventArgs , IgrRadioModule , IgrRadioGroupModule , IgrButton , IgrButtonModule
5+ IgrButton ,
6+ IgrRadio ,
7+ IgrRadioChangeEventArgs ,
8+ IgrRadioGroup ,
9+ IgrStep ,
10+ IgrStepper ,
11+ StepperOrientation ,
12+ StepperTitlePosition ,
713} from 'igniteui-react' ;
814import 'igniteui-webcomponents/themes/light/bootstrap.css' ;
915
10- IgrStepperModule . register ( ) ;
11- IgrStepModule . register ( ) ;
12- IgrRadioModule . register ( ) ;
13- IgrRadioGroupModule . register ( ) ;
14- IgrButtonModule . register ( ) ;
16+ export interface StepperOrientationProps {
17+ orientation : StepperOrientation ;
18+ titlePosition : StepperTitlePosition ;
19+ }
1520
16- export default class StepperOrientationSample extends React . Component < any , any > {
21+ export default class StepperOrientationSample extends React . Component < any , StepperOrientationProps > {
1722 private stepperRef = React . createRef < IgrStepper > ( ) ;
1823
19- constructor ( props : any ) {
24+ constructor ( props : StepperOrientationProps ) {
2025 super ( props ) ;
21- this . state = { orientation : StepperOrientation . Horizontal , isDefaultTitlePosition : true } ;
26+ this . state = { orientation : "horizontal" , titlePosition : "auto" } ;
2227 this . handleTitlePositionChange = this . handleTitlePositionChange . bind ( this ) ;
2328 this . handleOrientationChange = this . handleOrientationChange . bind ( this ) ;
2429 }
@@ -30,26 +35,26 @@ export default class StepperOrientationSample extends React.Component<any, any>
3035 < div className = "radio-group" >
3136 < label > Title position</ label >
3237 < div className = "radio-group-container" >
33- < IgrRadioGroup alignment = "horizontal" >
34- < IgrRadio name = "title" value = "Top" onChange = { this . handleTitlePositionChange } > < span > Top</ span > </ IgrRadio >
35- < IgrRadio name = "title" value = "Bottom" onChange = { this . handleTitlePositionChange } > < span > Bottom</ span > </ IgrRadio >
36- < IgrRadio name = "title" value = "Start" onChange = { this . handleTitlePositionChange } > < span > Start</ span > </ IgrRadio >
37- < IgrRadio name = "title" value = "End" onChange = { this . handleTitlePositionChange } > < span > End</ span > </ IgrRadio >
38- < IgrRadio name = "title" value = "" checked = { true } onChange = { this . handleTitlePositionChange } > < span > Default </ span > </ IgrRadio >
38+ < IgrRadioGroup alignment = "horizontal" onChange = { this . handleTitlePositionChange } value = { this . state . titlePosition } >
39+ < IgrRadio name = "title" value = "top" > < span > Top</ span > </ IgrRadio >
40+ < IgrRadio name = "title" value = "bottom" > < span > Bottom</ span > </ IgrRadio >
41+ < IgrRadio name = "title" value = "start" > < span > Start</ span > </ IgrRadio >
42+ < IgrRadio name = "title" value = "end" > < span > End</ span > </ IgrRadio >
43+ < IgrRadio name = "title" value = "auto" > < span > Auto (default) </ span > </ IgrRadio >
3944 </ IgrRadioGroup >
4045 </ div >
4146 </ div >
4247 < div className = "radio-group" >
4348 < label > Orientation</ label >
4449 < div className = "radio-group-container" >
45- < IgrRadioGroup alignment = "horizontal" >
46- < IgrRadio name = "orientation" value = "Horizontal" checked = { true } onChange = { this . handleOrientationChange } > < span > Horizontal</ span > </ IgrRadio >
47- < IgrRadio name = "orientation" value = "Vertical" onChange = { this . handleOrientationChange } > < span > Vertical</ span > </ IgrRadio >
50+ < IgrRadioGroup alignment = "horizontal" onChange = { this . handleOrientationChange } value = { this . state . orientation } >
51+ < IgrRadio name = "orientation" value = "horizontal" > < span > Horizontal</ span > </ IgrRadio >
52+ < IgrRadio name = "orientation" value = "vertical" > < span > Vertical</ span > </ IgrRadio >
4853 </ IgrRadioGroup >
4954 </ div >
5055 </ div >
5156 </ div >
52- < IgrStepper ref = { this . stepperRef } orientation = { this . state . orientation } >
57+ < IgrStepper ref = { this . stepperRef } orientation = { this . state . orientation } titlePosition = { this . state . titlePosition } >
5358 < IgrStep >
5459 < span slot = "title" > Order</ span >
5560 < IgrButton onClick = { ( ) => { this . stepperRef . current . next ( ) ; } } > < span > NEXT</ span > </ IgrButton >
@@ -70,32 +75,13 @@ export default class StepperOrientationSample extends React.Component<any, any>
7075 }
7176
7277 public handleTitlePositionChange ( e : IgrRadioChangeEventArgs ) {
73- const value = e . detail . value ;
74-
75- if ( value === '' ) {
76- this . setDefaultTitlePosition ( ) ;
77- this . setState ( { isDefaultTitlePosition : true } ) ;
78- } else {
79- const newTitlePosition : StepperTitlePosition = StepperTitlePosition [ value as keyof typeof StepperTitlePosition ] ;
80- this . stepperRef . current . titlePosition = newTitlePosition ;
81- this . setState ( { isDefaultTitlePosition : false } ) ;
82- }
78+ const newTitlePosition = e . detail . value as StepperTitlePosition ;
79+ this . setState ( { titlePosition : newTitlePosition } ) ;
8380 }
8481
8582 public handleOrientationChange ( e : IgrRadioChangeEventArgs ) {
86- const value = e . detail . value ;
87- const newOrientation : StepperOrientation = StepperOrientation [ value as keyof typeof StepperOrientation ] ;
88- this . setDefaultTitlePosition ( newOrientation ) ;
89- this . setState ( { orientation : newOrientation } ) ;
90- }
91-
92- public setDefaultTitlePosition ( orientation ?: StepperOrientation ) {
93- const currentOrientation = orientation !== undefined ? orientation : this . state . orientation ;
94- if ( currentOrientation === StepperOrientation . Horizontal ) {
95- this . stepperRef . current . titlePosition = StepperTitlePosition . Bottom ;
96- } else {
97- this . stepperRef . current . titlePosition = StepperTitlePosition . End ;
98- }
83+ const newOrientation = e . detail . value as StepperOrientation ;
84+ this . setState ( { orientation : newOrientation , titlePosition : "auto" } ) ;
9985 }
10086}
10187
0 commit comments