@@ -5,7 +5,35 @@ import componentTypes from '@data-driven-forms/react-form-renderer/dist/cjs/comp
5
5
import useFieldApi from '@data-driven-forms/react-form-renderer/dist/cjs/use-field-api' ;
6
6
import useFormApi from '@data-driven-forms/react-form-renderer/dist/cjs/use-form-api' ;
7
7
8
- //import './form-fields-mapper-docs.css';
8
+ const formGroupStyle = {
9
+ display : 'flex' ,
10
+ flexDirection : 'column' ,
11
+ marginBottom : 16 ,
12
+ }
13
+
14
+ const inputStyles = {
15
+ width : '100%' ,
16
+ padding : '12px 20px' ,
17
+ margin : '8px 0' ,
18
+ display : 'inline-block' ,
19
+ border : '1px solid #ccc' ,
20
+ borderRadius : 4 ,
21
+ boxSizing : 'border-box' ,
22
+ }
23
+
24
+ const paragraphStyle = {
25
+ marginTop : 0 ,
26
+ marginBottom : 4 ,
27
+ }
28
+
29
+ const requiredStyle = {
30
+ color : 'red' ,
31
+ marginLeft : 2 ,
32
+ }
33
+
34
+ const errorStyle = {
35
+ color : 'orangered'
36
+ }
9
37
10
38
const getButtonStyle = ( variant ) => ( {
11
39
color : 'White' ,
@@ -51,11 +79,15 @@ const TextField = (props) => {
51
79
...rest
52
80
} = useFieldApi ( props ) ;
53
81
return (
54
- < div className = { `ddorg__demo-formGroup ${ isRequired ? 'required' : '' } ${ error ? 'error' : '' } ` } >
55
- < label htmlFor = { input . name } > { label } </ label >
56
- < input id = { input . name } { ...input } { ...rest } />
57
- { touched && error && < p className = "error-text" > { error } </ p > }
58
- { customProp && < p > This is a custom prop and has nothing to do with form schema</ p > }
82
+ < div style = { {
83
+ ...formGroupStyle ,
84
+ ...( isRequired && requiredStyle ) ,
85
+ ...( error && touched && errorStyle )
86
+ } } >
87
+ < label style = { { color : 'initial' } } htmlFor = { input . name } > { isRequired && < span style = { errorStyle } > * </ span > } { label } </ label >
88
+ < input style = { inputStyles } id = { input . name } { ...input } { ...rest } />
89
+ { touched && error && < p style = { paragraphStyle } > { error } </ p > }
90
+ { customProp && < p style = { { color : 'initial' } } > This is a custom prop and has nothing to do with form schema</ p > }
59
91
</ div >
60
92
) ;
61
93
} ;
0 commit comments