|
| 1 | +import React from 'react'; |
| 2 | +import ReactDOM from 'react-dom/client'; |
| 3 | +import './index.css'; |
| 4 | +import { |
| 5 | + IgrStepper, IgrStep, IgrStepperModule, IgrRadio, IgrRadioGroup, IgrRadioModule, IgrRadioGroupModule, |
| 6 | + IgrButton, IgrButtonModule, IgrInput, IgrInputModule, IgrSelect, IgrSelectItem, IgrSelectModule, IgrDropdown, |
| 7 | + IgrDropdownItemComponentEventArgs, IgrComponentValueChangedEventArgs |
| 8 | +} from 'igniteui-react'; |
| 9 | +import 'igniteui-webcomponents/themes/light/bootstrap.css'; |
| 10 | + |
| 11 | +IgrStepperModule.register(); |
| 12 | +IgrInputModule.register(); |
| 13 | +IgrRadioModule.register(); |
| 14 | +IgrRadioGroupModule.register(); |
| 15 | +IgrButtonModule.register(); |
| 16 | +IgrSelectModule.register(); |
| 17 | + |
| 18 | +export default class StepperAnimations extends React.Component<any, any> { |
| 19 | + private stepperRef = React.createRef<IgrStepper>(); |
| 20 | + constructor(props: any) { |
| 21 | + super(props); |
| 22 | + this.state = { orientation: 'horizontal', horizontalAnimation: 'slide', verticalAnimation: 'grow', animationDuration: "320" }; |
| 23 | + this.orientationChange = this.orientationChange.bind(this); |
| 24 | + this.horizontalAnimationChange = this.horizontalAnimationChange.bind(this); |
| 25 | + this.verticalAnimationChange = this.verticalAnimationChange.bind(this); |
| 26 | + this.animationDurationChange = this.animationDurationChange.bind(this); |
| 27 | + } |
| 28 | + |
| 29 | + public render(): JSX.Element { |
| 30 | + return ( |
| 31 | + <div className="container sample"> |
| 32 | + <article className="settings"> |
| 33 | + <IgrSelect label="Orienation" change={this.orientationChange}> |
| 34 | + <IgrSelectItem key="horizontal-item" value="horizontal" selected><span key="horizontal">Horizontal</span></IgrSelectItem> |
| 35 | + <IgrSelectItem key="vertical-item" value="vertical"><span key="vertical">Vertical</span></IgrSelectItem> |
| 36 | + </IgrSelect> |
| 37 | + <IgrSelect label="Vertical Animation" change={this.horizontalAnimationChange}> |
| 38 | + <IgrSelectItem key="grow-item" value="grow" selected><span key="grow">Grow</span></IgrSelectItem> |
| 39 | + <IgrSelectItem key="vertical-fade-item" value="fade"><span key="vertical-fade">Fade</span></IgrSelectItem> |
| 40 | + <IgrSelectItem key="vertical-none-item" value="none" selected><span key="vertical-none">None</span></IgrSelectItem> |
| 41 | + </IgrSelect> |
| 42 | + <IgrSelect label="Horizontal Animation" change={this.verticalAnimationChange}> |
| 43 | + <IgrSelectItem key="slide-item" value="slide" selected><span key="slide">Slide</span></IgrSelectItem> |
| 44 | + <IgrSelectItem key="horizontal-fade-item" value="fade"><span key="horizontal-fade">Fade</span></IgrSelectItem> |
| 45 | + <IgrSelectItem key="horizontal-none-item" value="none" selected><span key="horizontal-none">None</span></IgrSelectItem> |
| 46 | + </IgrSelect> |
| 47 | + <IgrInput type="number" value="320" label="Duration" change={this.animationDurationChange}> |
| 48 | + <span key="duration-suffix" slot="suffix">ms</span> |
| 49 | + </IgrInput> |
| 50 | + </article> |
| 51 | + |
| 52 | + {/* TO DO: bind the animation properties when they are available */} |
| 53 | + <IgrStepper ref={this.stepperRef} orientation={this.state.orientation} > |
| 54 | + <IgrStep key="info"> |
| 55 | + <span key="info-title" slot="title">Personal Info</span> |
| 56 | + <form key="info-form"> |
| 57 | + <IgrInput key="full-name" label="Full Name" type="text" name="fullName"></IgrInput> |
| 58 | + <IgrInput key="email" label="Email" type="email" name="email"></IgrInput> |
| 59 | + |
| 60 | + <IgrButton key="info-next" clicked={() => { this.stepperRef.current.next(); }}><span>NEXT</span></IgrButton> |
| 61 | + </form> |
| 62 | + </IgrStep> |
| 63 | + <IgrStep key="address"> |
| 64 | + <span key="address-title" slot="title">Delivery address</span> |
| 65 | + <form key="address-form"> |
| 66 | + <IgrInput key="city" label="City" type="text" name="city"></IgrInput> |
| 67 | + <IgrInput key="street" label="Street" type="text" name="street"></IgrInput> |
| 68 | + |
| 69 | + <IgrButton key="address-prev" clicked={() => { this.stepperRef.current.prev(); }}><span>PREVIOUS</span></IgrButton> |
| 70 | + <IgrButton key="address-next" clicked={() => { this.stepperRef.current.next(); }}><span>NEXT</span></IgrButton> |
| 71 | + </form> |
| 72 | + </IgrStep> |
| 73 | + <IgrStep key="payment"> |
| 74 | + <span key="payment-title" slot="title">Payment</span> |
| 75 | + <IgrRadioGroup key="payment-options"> |
| 76 | + <IgrRadio key="pay-pal-radio" name="payment" checked><span key="pay-pal">PayPal (n@mail.com; 18/02/2021)</span></IgrRadio> |
| 77 | + <IgrRadio key="visa-radio" name="payment"><span key="visa">Visa (**** **** **** 1234; 12/23)</span></IgrRadio> |
| 78 | + <IgrRadio key="master-card-radio" name="payment"><span key="master-card">MasterCard (**** **** **** 5678; 12/24)</span></IgrRadio> |
| 79 | + </IgrRadioGroup> |
| 80 | + |
| 81 | + <IgrButton key="payment-prev" clicked={() => { this.stepperRef.current.prev(); }}><span>PREVIOUS</span></IgrButton> |
| 82 | + <IgrButton key="payment-next" clicked={() => { this.stepperRef.current.next(); }}><span>SUBMIT</span></IgrButton> |
| 83 | + </IgrStep> |
| 84 | + <IgrStep key="status"> |
| 85 | + <span key="status-title" slot="title">Delivery status</span> |
| 86 | + <p key="status-text">Your order is on its way. Expect delivery on 25th September 2021. Delivery address: San Jose, CA 94243.</p> |
| 87 | + |
| 88 | + <IgrButton key="status-prev" clicked={() => { this.stepperRef.current.prev(); }}><span>PREVIOUS</span></IgrButton> |
| 89 | + <IgrButton key="status-reset" clicked={() => { this.stepperRef.current.reset(); }}><span>RESET</span></IgrButton> |
| 90 | + </IgrStep> |
| 91 | + </IgrStepper> |
| 92 | + </div> |
| 93 | + ); |
| 94 | + } |
| 95 | + |
| 96 | + public orientationChange(s: IgrDropdown, e: IgrDropdownItemComponentEventArgs){ |
| 97 | + const selectedValue = e.detail.value; |
| 98 | + this.setState({orientation: selectedValue}); |
| 99 | + } |
| 100 | + public horizontalAnimationChange(s: IgrDropdown, e: IgrDropdownItemComponentEventArgs){ |
| 101 | + const selectedValue = e.detail.value; |
| 102 | + this.setState({horizontalAnimation: selectedValue}); |
| 103 | + } |
| 104 | + public verticalAnimationChange(s: IgrDropdown, e: IgrDropdownItemComponentEventArgs){ |
| 105 | + const selectedValue = e.detail.value; |
| 106 | + this.setState({verticalAnimation: selectedValue}); |
| 107 | + } |
| 108 | + public animationDurationChange(s: IgrInput, e: IgrComponentValueChangedEventArgs){ |
| 109 | + const animationDuration = e.detail; |
| 110 | + this.setState({animationDuration: animationDuration}); |
| 111 | + } |
| 112 | +} |
| 113 | + |
| 114 | +// rendering above class to the React DOM |
| 115 | +const root = ReactDOM.createRoot(document.getElementById('root')); |
| 116 | +root.render(<StepperAnimations />); |
0 commit comments