@@ -4,6 +4,11 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
4
4
import { css } from '@emotion/react' ;
5
5
import { Toggle , ToggleBackground , colors } from 'decap-cms-ui-default' ;
6
6
7
+ const innerWrapper = css `
8
+ display : flex;
9
+ align-items : center;
10
+ `
11
+
7
12
function BooleanBackground ( { isActive, ...props } ) {
8
13
return (
9
14
< ToggleBackground
@@ -16,34 +21,42 @@ function BooleanBackground({ isActive, ...props }) {
16
21
}
17
22
18
23
export default class BooleanControl extends React . Component {
24
+ static propTypes = {
25
+ field : ImmutablePropTypes . map . isRequired ,
26
+ onChange : PropTypes . func . isRequired ,
27
+ classNameWrapper : PropTypes . string . isRequired ,
28
+ setActiveStyle : PropTypes . func . isRequired ,
29
+ setInactiveStyle : PropTypes . func . isRequired ,
30
+ forID : PropTypes . string ,
31
+ value : PropTypes . bool ,
32
+ }
33
+
34
+ static defaultProps = {
35
+ value : false ,
36
+ }
37
+
19
38
render ( ) {
20
- const { value, forID, onChange, classNameWrapper, setActiveStyle, setInactiveStyle } =
39
+ const { value, forID, onChange, classNameWrapper, setActiveStyle, setInactiveStyle, field } =
21
40
this . props ;
41
+
42
+ const prefix = field . get ( 'prefix' , false ) ;
43
+ const suffix = field . get ( 'suffix' , false ) ;
44
+
22
45
return (
23
46
< div className = { classNameWrapper } >
24
- < Toggle
25
- id = { forID }
26
- active = { value }
27
- onChange = { onChange }
28
- onFocus = { setActiveStyle }
29
- onBlur = { setInactiveStyle }
30
- Background = { BooleanBackground }
31
- />
47
+ < div css = { innerWrapper } >
48
+ { prefix && ( < span > { prefix } </ span > ) }
49
+ < Toggle
50
+ id = { forID }
51
+ active = { value }
52
+ onChange = { onChange }
53
+ onFocus = { setActiveStyle }
54
+ onBlur = { setInactiveStyle }
55
+ Background = { BooleanBackground }
56
+ />
57
+ { suffix && ( < span > { suffix } </ span > ) }
58
+ </ div >
32
59
</ div >
33
60
) ;
34
61
}
35
62
}
36
-
37
- BooleanControl . propTypes = {
38
- field : ImmutablePropTypes . map . isRequired ,
39
- onChange : PropTypes . func . isRequired ,
40
- classNameWrapper : PropTypes . string . isRequired ,
41
- setActiveStyle : PropTypes . func . isRequired ,
42
- setInactiveStyle : PropTypes . func . isRequired ,
43
- forID : PropTypes . string ,
44
- value : PropTypes . bool ,
45
- } ;
46
-
47
- BooleanControl . defaultProps = {
48
- value : false ,
49
- } ;
0 commit comments