Skip to content

Commit 5e96b57

Browse files
cee-chenmgadewoll
andauthored
[Emotion] Convert basic form controls (#7823)
Co-authored-by: Lene Gadewoll <[email protected]>
1 parent b96a14c commit 5e96b57

File tree

116 files changed

+1737
-1116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+1737
-1116
lines changed
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
**Bug fixes**
2+
3+
- Fixed broken focus/invalid styling on compressed `EuiDatePickerRange`s
4+
5+
**CSS-in-JS conversions**
6+
7+
- Converted `EuiFieldText` to Emotion
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**CSS-in-JS conversions**
2+
3+
- Updated the autofill colors of Chrome (and other webkit browsers) to better match EUI's light and dark mode
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Updated `EuiFormControlLayout` to automatically pass icon padding affordance down to child `input`s
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
**CSS-in-JS conversions**
2+
3+
- Converted `EuiFieldNumber` to Emotion
4+
- Converted `EuiFieldSearch` to Emotion
5+
- Converted `EuiFieldPassword` to Emotion
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
**CSS-in-JS conversions**
2+
3+
- Converted `EuiTextArea` to Emotion
4+
- Converted `EuiSelect` to Emotion
5+
- Converted `EuiSuperSelect` to Emotion

packages/eui/src-docs/src/views/form_controls/form_control_layout.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,7 @@ export default () => {
100100
<EuiFormControlLayout
101101
prepend={<EuiFormLabel htmlFor={labelInputId}>Label</EuiFormLabel>}
102102
>
103-
<EuiFieldText
104-
type="text"
105-
className="euiFieldText--inGroup"
106-
controlOnly
107-
id={labelInputId}
108-
/>
103+
<EuiFieldText type="text" controlOnly id={labelInputId} />
109104
</EuiFormControlLayout>
110105

111106
<EuiFormControlLayout
@@ -115,13 +110,7 @@ export default () => {
115110
}
116111
append={<EuiButtonEmpty size="xs">Button</EuiButtonEmpty>}
117112
>
118-
<EuiFieldText
119-
type="text"
120-
className="euiFieldText--inGroup"
121-
id={readOnlyInputId}
122-
controlOnly
123-
readOnly
124-
/>
113+
<EuiFieldText type="text" id={readOnlyInputId} controlOnly readOnly />
125114
</EuiFormControlLayout>
126115

127116
<EuiFormControlLayout
@@ -133,7 +122,6 @@ export default () => {
133122
>
134123
<EuiFieldText
135124
type="number"
136-
className="euiFieldNumber--inGroup"
137125
controlOnly
138126
aria-label="Use aria labels when no actual label is in use"
139127
/>
@@ -150,7 +138,6 @@ export default () => {
150138
>
151139
<EuiFieldText
152140
type="text"
153-
className="euiFieldText--inGroup"
154141
controlOnly
155142
aria-label="Use aria labels when no actual label is in use"
156143
/>

packages/eui/src-docs/src/views/form_controls/form_controls_example.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -477,16 +477,6 @@ export const FormControlsExample = {
477477
the <EuiCode>controlOnly</EuiCode> and <EuiCode>type</EuiCode> props
478478
of <strong>EuiFieldText</strong> as the wrapped control.
479479
</p>
480-
481-
<EuiCallOut title="Additional padding required" color="warning">
482-
<p>
483-
The padding on the <EuiCode>input</EuiCode> itself doesn&rsquo;t
484-
take into account the presence of the various icons supported by{' '}
485-
<strong>EuiFormControlLayout</strong>. Any input component
486-
provided to <strong>EuiFormControlLayout</strong> is responsible
487-
for its own padding.
488-
</p>
489-
</EuiCallOut>
490480
</>
491481
),
492482
props: {

packages/eui/src-docs/src/views/form_controls/prepend_append.js

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import React, { Fragment, useState } from 'react';
1+
import React, { useState } from 'react';
22

33
import {
4+
EuiFlexGroup,
45
EuiButtonEmpty,
56
EuiButtonIcon,
67
EuiFieldText,
@@ -19,24 +20,24 @@ export default () => {
1920
const [isReadOnly, setReadOnly] = useState(false);
2021

2122
return (
22-
<Fragment>
23-
<EuiSwitch
24-
label="compressed"
25-
checked={isCompressed}
26-
onChange={(e) => setCompressed(e.target.checked)}
27-
/>
28-
&emsp;
29-
<EuiSwitch
30-
label="disabled"
31-
checked={isDisabled}
32-
onChange={(e) => setDisabled(e.target.checked)}
33-
/>
34-
&emsp;
35-
<EuiSwitch
36-
label="readOnly"
37-
checked={isReadOnly}
38-
onChange={(e) => setReadOnly(e.target.checked)}
39-
/>
23+
<>
24+
<EuiFlexGroup responsive={false}>
25+
<EuiSwitch
26+
label="compressed"
27+
checked={isCompressed}
28+
onChange={(e) => setCompressed(e.target.checked)}
29+
/>
30+
<EuiSwitch
31+
label="disabled"
32+
checked={isDisabled}
33+
onChange={(e) => setDisabled(e.target.checked)}
34+
/>
35+
<EuiSwitch
36+
label="readOnly"
37+
checked={isReadOnly}
38+
onChange={(e) => setReadOnly(e.target.checked)}
39+
/>
40+
</EuiFlexGroup>
4041
<EuiSpacer />
4142
<EuiFieldText
4243
placeholder="String & text in a tooltip"
@@ -180,6 +181,6 @@ export default () => {
180181
readOnly={isReadOnly}
181182
aria-label="Use aria labels when no actual label is in use"
182183
/>
183-
</Fragment>
184+
</>
184185
);
185186
};

packages/eui/src-docs/src/views/super_date_picker/super_date_picker.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
EuiSpacer,
66
EuiFormControlLayoutDelimited,
77
EuiFormLabel,
8+
EuiFieldText,
89
EuiPanel,
910
EuiText,
1011
OnRefreshProps,
@@ -58,21 +59,19 @@ export default () => {
5859
<EuiFormControlLayoutDelimited
5960
prepend={<EuiFormLabel>Dates</EuiFormLabel>}
6061
startControl={
61-
<input
62+
<EuiFieldText
63+
controlOnly
6264
onChange={onStartInputChange}
63-
type="text"
6465
value={start}
6566
placeholder="start"
66-
className="euiFieldText"
6767
/>
6868
}
6969
endControl={
70-
<input
70+
<EuiFieldText
71+
controlOnly
7172
onChange={onEndInputChange}
72-
type="text"
7373
placeholder="end"
7474
value={end}
75-
className="euiFieldText"
7675
/>
7776
}
7877
/>

packages/eui/src/components/basic_table/in_memory_table.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ describe('EuiInMemoryTable', () => {
947947
// should render with all three results visible
948948
expect(component.find('.testTable EuiTableRow').length).toBe(3);
949949

950-
const searchField = component.find('EuiFieldSearch input[type="search"]');
950+
const searchField = component.find('input.euiFieldSearch');
951951

952952
searchField.simulate('keyUp', {
953953
target: {

packages/eui/src/components/color_picker/__snapshots__/color_picker.test.tsx.snap

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ exports[`renders EuiColorPicker 1`] = `
2727
<input
2828
aria-label="Press the down key to open a popover containing color options"
2929
autocomplete="off"
30-
class="euiFieldText euiColorPicker__input euiFieldText--withIcon euiFormControlLayout--1icons"
30+
class="euiFieldText euiColorPicker__input euiFormControlLayout--1icons emotion-euiFieldText-controlOnly"
3131
data-test-subj="euiColorPickerAnchor test subject string"
3232
type="text"
3333
value="#FFEEDD"
@@ -77,7 +77,7 @@ exports[`renders EuiColorPicker with a clearable input 1`] = `
7777
<input
7878
aria-label="Press the down key to open a popover containing color options"
7979
autocomplete="off"
80-
class="euiFieldText euiColorPicker__input euiFieldText--withIcon euiFormControlLayout--2icons"
80+
class="euiFieldText euiColorPicker__input euiFormControlLayout--2icons emotion-euiFieldText-controlOnly"
8181
data-test-subj="euiColorPickerAnchor test subject string"
8282
type="text"
8383
value="#FFEEDD"
@@ -137,7 +137,7 @@ exports[`renders EuiColorPicker with a color swatch when color is defined 1`] =
137137
<input
138138
aria-label="Press the down key to open a popover containing color options"
139139
autocomplete="off"
140-
class="euiFieldText euiColorPicker__input euiFieldText--withIcon euiFormControlLayout--1icons"
140+
class="euiFieldText euiColorPicker__input euiFormControlLayout--1icons emotion-euiFieldText-controlOnly"
141141
data-test-subj="euiColorPickerAnchor test subject string"
142142
type="text"
143143
value="#FFFFFF"
@@ -187,7 +187,7 @@ exports[`renders EuiColorPicker with a custom placeholder 1`] = `
187187
<input
188188
aria-label="Press the down key to open a popover containing color options"
189189
autocomplete="off"
190-
class="euiFieldText euiColorPicker__input euiFieldText--withIcon euiFormControlLayout--1icons"
190+
class="euiFieldText euiColorPicker__input euiFormControlLayout--1icons emotion-euiFieldText-controlOnly"
191191
data-test-subj="euiColorPickerAnchor test subject string"
192192
placeholder="Auto"
193193
type="text"
@@ -238,7 +238,7 @@ exports[`renders EuiColorPicker with an empty swatch when color is "" 1`] = `
238238
<input
239239
aria-label="Press the down key to open a popover containing color options"
240240
autocomplete="off"
241-
class="euiFieldText euiColorPicker__input euiFieldText--withIcon euiFormControlLayout--1icons"
241+
class="euiFieldText euiColorPicker__input euiFormControlLayout--1icons emotion-euiFieldText-controlOnly"
242242
data-test-subj="euiColorPickerAnchor test subject string"
243243
placeholder="Transparent"
244244
type="text"
@@ -289,7 +289,7 @@ exports[`renders EuiColorPicker with an empty swatch when color is null 1`] = `
289289
<input
290290
aria-label="Press the down key to open a popover containing color options"
291291
autocomplete="off"
292-
class="euiFieldText euiColorPicker__input euiFieldText--withIcon euiFormControlLayout--1icons"
292+
class="euiFieldText euiColorPicker__input euiFormControlLayout--1icons emotion-euiFieldText-controlOnly"
293293
data-test-subj="euiColorPickerAnchor test subject string"
294294
placeholder="Transparent"
295295
type="text"
@@ -345,7 +345,7 @@ exports[`renders a EuiColorPicker with a prepend and append 1`] = `
345345
<input
346346
aria-label="Press the down key to open a popover containing color options"
347347
autocomplete="off"
348-
class="euiFieldText euiColorPicker__input euiColorPicker__input--inGroup euiFieldText--withIcon euiFormControlLayout--1icons"
348+
class="euiFieldText euiColorPicker__input euiFormControlLayout--1icons emotion-euiFieldText-controlOnly"
349349
data-test-subj="euiColorPickerAnchor test subject string"
350350
type="text"
351351
value="#FFEEDD"
@@ -400,7 +400,7 @@ exports[`renders a EuiColorPicker with an alpha range selector 1`] = `
400400
<input
401401
aria-label="Press the down key to open a popover containing color options"
402402
autocomplete="off"
403-
class="euiFieldText euiColorPicker__input euiFieldText--withIcon euiFormControlLayout--1icons"
403+
class="euiFieldText euiColorPicker__input euiFormControlLayout--1icons emotion-euiFieldText-controlOnly"
404404
data-test-subj="euiColorPickerAnchor test subject string"
405405
type="text"
406406
value="#FFEEDD"
@@ -450,7 +450,7 @@ exports[`renders compressed EuiColorPicker 1`] = `
450450
<input
451451
aria-label="Press the down key to open a popover containing color options"
452452
autocomplete="off"
453-
class="euiFieldText euiColorPicker__input euiFieldText--withIcon euiFormControlLayout--1icons euiFieldText--compressed"
453+
class="euiFieldText euiColorPicker__input euiFormControlLayout--1icons emotion-euiFieldText-compressed-controlOnly"
454454
data-test-subj="euiColorPickerAnchor test subject string"
455455
type="text"
456456
value="#FFEEDD"
@@ -500,7 +500,7 @@ exports[`renders disabled EuiColorPicker 1`] = `
500500
<input
501501
aria-label="Press the down key to open a popover containing color options"
502502
autocomplete="off"
503-
class="euiFieldText euiColorPicker__input euiFieldText--withIcon euiFormControlLayout--1icons"
503+
class="euiFieldText euiColorPicker__input euiFormControlLayout--1icons emotion-euiFieldText-controlOnly"
504504
data-test-subj="euiColorPickerAnchor test subject string"
505505
disabled=""
506506
type="text"
@@ -538,7 +538,7 @@ exports[`renders fullWidth EuiColorPicker 1`] = `
538538
<input
539539
aria-label="Press the down key to open a popover containing color options"
540540
autocomplete="off"
541-
class="euiFieldText euiColorPicker__input euiFieldText--withIcon euiFormControlLayout--1icons euiFieldText--fullWidth"
541+
class="euiFieldText euiColorPicker__input euiFormControlLayout--1icons emotion-euiFieldText-fullWidth-controlOnly"
542542
data-test-subj="euiColorPickerAnchor test subject string"
543543
type="text"
544544
value="#FFEEDD"
@@ -760,7 +760,7 @@ exports[`renders readOnly EuiColorPicker 1`] = `
760760
<input
761761
aria-label="Press the down key to open a popover containing color options"
762762
autocomplete="off"
763-
class="euiFieldText euiColorPicker__input euiFieldText--withIcon euiFormControlLayout--1icons"
763+
class="euiFieldText euiColorPicker__input euiFormControlLayout--1icons emotion-euiFieldText-controlOnly"
764764
data-test-subj="euiColorPickerAnchor test subject string"
765765
readonly=""
766766
type="text"

packages/eui/src/components/color_picker/_color_picker.scss

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,10 @@
2525
padding-bottom: 0 !important;
2626
}
2727

28-
// stylelint-disable declaration-no-important
29-
.euiColorPicker__input--inGroup {
30-
height: $euiFormControlLayoutGroupInputHeight !important;
31-
box-shadow: none !important;
32-
border-radius: 0;
33-
34-
&.euiFieldText--compressed {
35-
height: $euiFormControlLayoutGroupInputCompressedHeight !important;
36-
border-radius: 0;
37-
}
28+
.euiColorPicker__input {
29+
// Manually account for custom left icon / color swatch preview
30+
--euiFormControlLeftIconsCount: 1;
3831
}
39-
// stylelint-enable declaration-no-important
4032

4133
.euiColorPicker__alphaRange {
4234
.euiRangeInput {

packages/eui/src/components/color_picker/color_palette_picker/__snapshots__/color_palette_picker.test.tsx.snap

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ exports[`EuiColorPalettePicker is rendered 1`] = `
1717
<button
1818
aria-haspopup="listbox"
1919
aria-label="aria-label"
20-
class="euiSuperSelectControl euiFormControlLayout--1icons testClass1 testClass2 emotion-euiTestCss"
20+
class="euiSuperSelectControl testClass1 testClass2 emotion-euiSuperSelect__control-euiTestCss"
2121
data-test-subj="test subject string"
2222
type="button"
2323
/>
@@ -56,7 +56,7 @@ exports[`EuiColorPalettePicker is rendered with a selected custom text 1`] = `
5656
<button
5757
aria-haspopup="listbox"
5858
aria-label="aria-label"
59-
class="euiSuperSelectControl euiFormControlLayout--1icons testClass1 testClass2 emotion-euiTestCss"
59+
class="euiSuperSelectControl testClass1 testClass2 emotion-euiSuperSelect__control-euiTestCss"
6060
data-test-subj="test subject string"
6161
type="button"
6262
>
@@ -97,7 +97,7 @@ exports[`EuiColorPalettePicker is rendered with a selected fixed palette 1`] = `
9797
<button
9898
aria-haspopup="listbox"
9999
aria-label="aria-label"
100-
class="euiSuperSelectControl euiFormControlLayout--1icons testClass1 testClass2 emotion-euiTestCss"
100+
class="euiSuperSelectControl testClass1 testClass2 emotion-euiSuperSelect__control-euiTestCss"
101101
data-test-subj="test subject string"
102102
type="button"
103103
>
@@ -166,7 +166,7 @@ exports[`EuiColorPalettePicker is rendered with a selected gradient palette 1`]
166166
<button
167167
aria-haspopup="listbox"
168168
aria-label="aria-label"
169-
class="euiSuperSelectControl euiFormControlLayout--1icons testClass1 testClass2 emotion-euiTestCss"
169+
class="euiSuperSelectControl testClass1 testClass2 emotion-euiSuperSelect__control-euiTestCss"
170170
data-test-subj="test subject string"
171171
type="button"
172172
>
@@ -215,7 +215,7 @@ exports[`EuiColorPalettePicker is rendered with a selected gradient palette with
215215
<button
216216
aria-haspopup="listbox"
217217
aria-label="aria-label"
218-
class="euiSuperSelectControl euiFormControlLayout--1icons testClass1 testClass2 emotion-euiTestCss"
218+
class="euiSuperSelectControl testClass1 testClass2 emotion-euiSuperSelect__control-euiTestCss"
219219
data-test-subj="test subject string"
220220
type="button"
221221
>
@@ -264,7 +264,7 @@ exports[`EuiColorPalettePicker is rendered with the prop selectionDisplay set as
264264
<button
265265
aria-haspopup="listbox"
266266
aria-label="aria-label"
267-
class="euiSuperSelectControl euiFormControlLayout--1icons testClass1 testClass2 emotion-euiTestCss"
267+
class="euiSuperSelectControl testClass1 testClass2 emotion-euiSuperSelect__control-euiTestCss"
268268
data-test-subj="test subject string"
269269
type="button"
270270
>
@@ -304,7 +304,7 @@ exports[`EuiColorPalettePicker more props are propagated to each option 1`] = `
304304
>
305305
<button
306306
aria-haspopup="listbox"
307-
class="euiSuperSelectControl euiFormControlLayout--1icons euiSuperSelect--isOpen__button"
307+
class="euiSuperSelectControl emotion-euiSuperSelect__control-open"
308308
data-test-subj="colorPalettePicker"
309309
type="button"
310310
>

packages/eui/src/components/color_picker/color_picker.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,7 @@ export const EuiColorPicker: FunctionComponent<EuiColorPickerProps> = ({
293293
clear: isClearable,
294294
isInvalid,
295295
});
296-
const inputClasses = classNames(
297-
'euiColorPicker__input',
298-
{ 'euiColorPicker__input--inGroup': prepend || append },
299-
// Manually account for input padding, since `controlOnly` disables that logic
300-
'euiFieldText--withIcon',
301-
numIconsClass
302-
);
296+
const inputClasses = classNames('euiColorPicker__input', numIconsClass);
303297

304298
const handleOnChange = (text: string) => {
305299
const output = getOutput(text, showAlpha);

0 commit comments

Comments
 (0)