|
1 | | -import React from 'react'; |
2 | | -import ReactDOM from 'react-dom/client'; |
3 | | -import './index.css'; |
4 | | -import { IgrTextarea, IgrButton, IgrToast } from 'igniteui-react'; |
5 | | -import 'igniteui-webcomponents/themes/light/bootstrap.css'; |
| 1 | +import React from "react"; |
| 2 | +import ReactDOM from "react-dom/client"; |
| 3 | +import "./index.css"; |
| 4 | +import { IgrTextarea, IgrButton, IgrToast } from "igniteui-react"; |
| 5 | +import "igniteui-webcomponents/themes/light/bootstrap.css"; |
6 | 6 |
|
7 | 7 | export default function TextAreaFormIntegration() { |
| 8 | + let toastRef: IgrToast; |
8 | 9 |
|
9 | | - let toastRef: IgrToast; |
10 | | - |
11 | | - const onToastRef = (toast: IgrToast) => { |
12 | | - if (!toast) { return; } |
13 | | - toastRef = toast; |
| 10 | + const onToastRef = (toast: IgrToast) => { |
| 11 | + if (!toast) { |
| 12 | + return; |
14 | 13 | } |
| 14 | + toastRef = toast; |
| 15 | + }; |
15 | 16 |
|
16 | | - const onSubmitButtonClicked = (e:React.FormEvent<HTMLFormElement>) => { |
17 | | - if(toastRef){ |
18 | | - e.preventDefault(); |
19 | | - toastRef.show(); |
20 | | - } |
| 17 | + const onSubmitButtonClicked = (e: React.FormEvent<HTMLFormElement>) => { |
| 18 | + if (toastRef) { |
| 19 | + e.preventDefault(); |
| 20 | + toastRef.show(); |
21 | 21 | } |
| 22 | + }; |
22 | 23 |
|
23 | | - return ( |
24 | | - <div className="sample"> |
25 | | - <form id="form" onSubmit={onSubmitButtonClicked}> |
26 | | - <IgrTextarea rows={3} name="user_feedback" label="Your review" required> |
27 | | - </IgrTextarea> |
28 | | - <div className="controls"> |
29 | | - <IgrButton type="submit"><span>Submit review</span></IgrButton> |
30 | | - <IgrButton type="reset" variant="outlined"><span>Reset</span></IgrButton> |
31 | | - </div> |
32 | | - <IgrToast id="submitted" position="top" display-time="1e3" ref={onToastRef}><span>Your review was submitted</span></IgrToast> |
33 | | - </form> |
34 | | - </div> |
35 | | - ); |
| 24 | + return ( |
| 25 | + <div className="sample"> |
| 26 | + <form id="form" onSubmit={onSubmitButtonClicked}> |
| 27 | + <IgrTextarea |
| 28 | + rows={3} |
| 29 | + name="user_feedback" |
| 30 | + label="Your review" |
| 31 | + required |
| 32 | + ></IgrTextarea> |
| 33 | + <div className="controls"> |
| 34 | + <IgrButton type="submit"> |
| 35 | + <span>Submit review</span> |
| 36 | + </IgrButton> |
| 37 | + <IgrButton type="reset" variant="outlined"> |
| 38 | + <span>Reset</span> |
| 39 | + </IgrButton> |
| 40 | + </div> |
| 41 | + <IgrToast |
| 42 | + id="submitted" |
| 43 | + position="top" |
| 44 | + displayTime={1000} |
| 45 | + ref={onToastRef} |
| 46 | + > |
| 47 | + <span>Your review was submitted</span> |
| 48 | + </IgrToast> |
| 49 | + </form> |
| 50 | + </div> |
| 51 | + ); |
36 | 52 | } |
37 | 53 |
|
38 | 54 | // rendering above class to the React DOM |
39 | | -const root = ReactDOM.createRoot(document.getElementById('root')); |
40 | | -root.render(<TextAreaFormIntegration/>); |
| 55 | +const root = ReactDOM.createRoot(document.getElementById("root")); |
| 56 | +root.render(<TextAreaFormIntegration />); |
0 commit comments