1
1
import React from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
3
import { css } from '@emotion/core' ;
4
+ import styled from '@emotion/styled' ;
4
5
import { useIntl } from 'react-intl' ;
5
6
import filterDataAttributes from '../../../utils/filter-data-attributes' ;
6
7
import usePrevious from '../../../hooks/use-previous' ;
@@ -16,6 +17,10 @@ import { getLanguageLabelStyles } from './editor.styles';
16
17
17
18
const COLLAPSED_HEIGHT = 32 ;
18
19
20
+ const Wrapper = styled . div `
21
+ flex : 1 ;
22
+ ` ;
23
+
19
24
const Editor = props => {
20
25
const intl = useIntl ( ) ;
21
26
const ref = React . useRef ( ) ;
@@ -53,6 +58,8 @@ const Editor = props => {
53
58
onToggle ( ) ;
54
59
}
55
60
61
+ const languagesControl = props . languagesControl ( ) ;
62
+
56
63
return (
57
64
< CollapsibleMotion
58
65
minHeight = { COLLAPSED_HEIGHT }
@@ -108,34 +115,45 @@ const Editor = props => {
108
115
< div
109
116
css = { css `
110
117
display : flex;
118
+
119
+ & : empty {
120
+ margin : 0 !important ;
121
+ }
111
122
` }
112
123
>
113
- < div
114
- css = { css `
115
- flex : 1 ;
116
- ` }
117
- >
118
- { ( ( ) => {
119
- if ( props . error ) return < div > { props . error } </ div > ;
120
- if ( props . warning ) return < div > { props . warning } </ div > ;
121
- return props . languagesControl ( ) ;
122
- } ) ( ) }
123
- </ div >
124
- < div
125
- css = { css `
126
- flex : 0 ;
127
- ` }
128
- >
129
- { renderToggleButton && isOpen && (
124
+ { ( ( ) => {
125
+ if ( props . error )
126
+ return (
127
+ < Wrapper >
128
+ < div > { props . error } </ div >
129
+ </ Wrapper >
130
+ ) ;
131
+ if ( props . warning )
132
+ return (
133
+ < Wrapper >
134
+ < div > { props . warning } </ div >
135
+ </ Wrapper >
136
+ ) ;
137
+ return (
138
+ languagesControl && < Wrapper > { languagesControl } </ Wrapper >
139
+ ) ;
140
+ } ) ( ) }
141
+ { renderToggleButton && isOpen && (
142
+ < div
143
+ css = { css `
144
+ flex : 0 ;
145
+ ` }
146
+ >
130
147
< FlatButton
131
148
onClick = { toggle }
132
149
label = { intl . formatMessage ( messages . collapse ) }
133
150
icon = { < AngleUpIcon size = "small" /> }
134
151
/>
135
- ) }
136
- </ div >
152
+ </ div >
153
+ ) }
154
+
155
+ { ( props . error || props . warning ) && props . languagesControl ( ) }
137
156
</ div >
138
- { ( props . error || props . warning ) && props . languagesControl ( ) }
139
157
</ Spacings . Stack >
140
158
) ;
141
159
} }
0 commit comments