Skip to content

Commit f917029

Browse files
cchaoscchaos
authored andcommitted
[Feature branch] Compressed form rows (#2181)
* Removed padding from compressed form row * Create mixin for `euiTextBreakWord` * Added option for horizontal compressed style Breaking: `compressed` is no longer passed to children * [Docs] Final compressed doc example changes * Fix combobox height * Fixed usages where spacers were needed * Deprecated `displayOnly` for `display: center`
1 parent 87c3df7 commit f917029

File tree

32 files changed

+602
-257
lines changed

32 files changed

+602
-257
lines changed

src-docs/src/components/guide_locale_selector/guide_locale_selector.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export const GuideLocaleSelector = ({ selectedLocale, onToggleLocale }) => {
1212
onChange={() =>
1313
onToggleLocale(selectedLocale === 'en' ? 'en-xa' : 'en')
1414
}
15-
compressed={true}
1615
/>
1716
</EuiFormRow>
1817
);

src-docs/src/components/guide_page/guide_page_chrome.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,10 @@ export class GuidePageChrome extends Component {
166166
selectedTheme={this.props.selectedTheme}
167167
/>
168168
{location.host === 'localhost:8030' ? ( // eslint-disable-line no-restricted-globals
169-
<EuiFlexItem grow={false}>
170-
<GuideLocaleSelector
171-
onToggleLocale={this.props.onToggleLocale}
172-
selectedLocale={this.props.selectedLocale}
173-
/>
174-
</EuiFlexItem>
169+
<GuideLocaleSelector
170+
onToggleLocale={this.props.onToggleLocale}
171+
selectedLocale={this.props.selectedLocale}
172+
/>
175173
) : null}
176174
</div>
177175
</EuiPopover>

src-docs/src/views/color_picker/custom_button.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
EuiFormRow,
66
EuiColorPickerSwatch,
77
EuiBadge,
8+
EuiSpacer,
89
} from '../../../../src/components';
910

1011
import { isValidHex } from '../../../../src/services';
@@ -43,6 +44,7 @@ export class CustomButton extends Component {
4344
}
4445
/>
4546
</EuiFormRow>
47+
<EuiSpacer />
4648
<EuiColorPicker
4749
onChange={this.handleChange}
4850
color={this.state.color}

src-docs/src/views/combo_box/containers.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ export default class extends Component {
161161
{comboBox}
162162
</EuiFormRow>
163163

164+
<EuiSpacer />
165+
164166
<EuiPopover
165167
id="popover"
166168
ownFocus

src-docs/src/views/context/context.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ export default class extends Component {
8585
</EuiI18n>
8686
</EuiFormRow>
8787

88+
<EuiSpacer />
89+
8890
<EuiButton>{action}</EuiButton>
8991
</Fragment>
9092
)}

src-docs/src/views/context_menu/context_menu.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
EuiIcon,
88
EuiPopover,
99
EuiSwitch,
10+
EuiSpacer,
1011
} from '../../../../src/components';
1112

1213
function flattenPanelTree(tree, array = []) {
@@ -87,6 +88,7 @@ export default class extends Component {
8788
label="Current time range"
8889
/>
8990
</EuiFormRow>
91+
<EuiSpacer />
9092
<EuiButton fill>Copy iFrame code</EuiButton>
9193
</div>
9294
),

src-docs/src/views/flyout/flyout_complicated.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ export class FlyoutComplicated extends Component {
195195
<SuperSelectComplexExample />
196196
</EuiFormRow>
197197
</EuiForm>
198+
<EuiSpacer />
198199
{flyoutContent}
199200
<EuiCodeBlock language="html">{htmlCode}</EuiCodeBlock>
200201
</EuiFlyoutBody>

src-docs/src/views/form_layouts/form_compressed.js

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
EuiFilePicker,
1111
EuiRange,
1212
EuiSelect,
13+
EuiSpacer,
1314
EuiSwitch,
1415
EuiPanel,
1516
} from '../../../../src/components';
@@ -57,9 +58,16 @@ export default class extends Component {
5758
],
5859
radioIdSelected: `${idPrefix}5`,
5960
comboBoxSelectionOptions: [],
61+
value: '20',
6062
};
6163
}
6264

65+
onRangeChange = e => {
66+
this.setState({
67+
value: e.target.value,
68+
});
69+
};
70+
6371
onSwitchChange = () => {
6472
this.setState({
6573
isSwitchChecked: !this.state.isSwitchChecked,
@@ -92,45 +100,58 @@ export default class extends Component {
92100
<EuiFormRow
93101
label="Text field"
94102
helpText="I am some friendly help text."
95-
compressed>
96-
<EuiFieldText name="first" isLoading />
103+
display="columnCompressed">
104+
<EuiFieldText name="first" isLoading compressed />
97105
</EuiFormRow>
98106

99-
<EuiFormRow label="Select" compressed>
107+
<EuiFormRow label="Select" display="columnCompressed">
100108
<EuiSelect
101109
options={[
102110
{ value: 'option_one', text: 'Option one' },
103111
{ value: 'option_two', text: 'Option two' },
104112
{ value: 'option_three', text: 'Option three' },
105113
]}
114+
compressed
106115
/>
107116
</EuiFormRow>
108117

109-
<EuiFormRow label="File picker" compressed>
110-
<EuiFilePicker />
118+
<EuiFormRow label="File picker" display="columnCompressed">
119+
<EuiFilePicker compressed display="default" />
111120
</EuiFormRow>
112121

113-
<EuiFormRow label="Combo box" compressed>
122+
<EuiFormRow
123+
label="Comboboxwithalonglabelname"
124+
display="columnCompressed">
114125
<EuiComboBox
115126
options={[
116127
{ label: 'Option one' },
117128
{ label: 'Option two' },
118129
{ label: 'Option three' },
119130
]}
131+
compressed
120132
selectedOptions={this.state.comboBoxSelectionOptions}
121133
onChange={comboBoxSelectionOptions =>
122134
this.setState({ comboBoxSelectionOptions })
123135
}
124136
/>
125137
</EuiFormRow>
126138

127-
<EuiFormRow label="Range" compressed>
128-
<EuiRange min={0} max={100} name="range" id="range" />
139+
<EuiFormRow label="Range" display="columnCompressed">
140+
<EuiRange
141+
min={0}
142+
max={100}
143+
name="range"
144+
id="range"
145+
showInput
146+
compressed
147+
value={this.state.value}
148+
onChange={this.onRangeChange}
149+
/>
129150
</EuiFormRow>
130151

131152
<EuiFormRow
132153
label="Use a switch instead of a single checkbox"
133-
compressed>
154+
display="rowCompressed">
134155
<EuiSwitch
135156
label="Should we do this?"
136157
name="switch"
@@ -139,14 +160,17 @@ export default class extends Component {
139160
/>
140161
</EuiFormRow>
141162

142-
<EuiFormRow label="Checkboxes" compressed>
163+
<EuiFormRow label="Checkboxes" display="rowCompressed">
143164
<EuiCheckboxGroup
144165
options={this.state.checkboxes}
145166
idToSelectedMap={this.state.checkboxIdToSelectedMap}
146167
onChange={this.onCheckboxChange}
168+
compressed
147169
/>
148170
</EuiFormRow>
149171

172+
<EuiSpacer size="s" />
173+
150174
<EuiButton type="submit" size="s" fill>
151175
Save form
152176
</EuiButton>

src-docs/src/views/form_layouts/form_layouts_example.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export const FormLayoutsExample = {
108108
</EuiFormRow>`,
109109
},
110110
{
111-
title: 'Compressed',
111+
title: 'Compressed and horizontal',
112112
source: [
113113
{
114114
type: GuideSectionTypes.JS,
@@ -122,21 +122,33 @@ export const FormLayoutsExample = {
122122
text: (
123123
<p>
124124
If the particular form is in an area with a small amount of real
125-
estate, you can add the prop <EuiCode>compressed</EuiCode> to the{' '}
126-
<EuiCode>EuiFormRow</EuiCode>s and it will pass down to the form
127-
controls.
125+
estate, you can pass{' '}
126+
<EuiCode>display=&quot;rowCompressed&quot;</EuiCode> to the{' '}
127+
<EuiCode>EuiFormRow</EuiCode>s but you will also need to pass{' '}
128+
<EuiCode>compressed=true</EuiCode> to the form controls themselves.
129+
For editor style controls, pass{' '}
130+
<EuiCode>display=&quot;columnCompressed&quot;</EuiCode> to align the
131+
labels and inputs horizontally.
128132
</p>
129133
),
130134
props: {
131135
EuiFormRow,
132136
},
133137
demo: <FormCompressed />,
134-
snippet: `<EuiFormRow
138+
snippet: [
139+
`<EuiFormRow
135140
label="Text field"
136-
compressed
141+
display="rowCompressed"
137142
>
138-
<EuiFieldText />
143+
<EuiFieldText compressed />
139144
</EuiFormRow>`,
145+
`<EuiFormRow
146+
label="Text field"
147+
display="columnCompressed"
148+
>
149+
<EuiFieldText compressed />
150+
</EuiFormRow>`,
151+
],
140152
},
141153
{
142154
title: 'Described form groups',
@@ -224,12 +236,16 @@ export const FormLayoutsExample = {
224236
<p>
225237
When supplying children to an EuiFormRow that is{' '}
226238
<strong>not</strong> a form control, and you need to the content to
227-
vertically center with the other form controls, add the prop{' '}
228-
<EuiCode>displayOnly</EuiCode>.
239+
vertically center with the other form controls, change the{' '}
240+
<EuiCode>display</EuiCode> prop to <EuiCode>center</EuiCode> or{' '}
241+
<EuiCode>centerCompressed</EuiCode>.
229242
</p>
230243
</Fragment>
231244
),
232245
demo: <InlineSizing />,
246+
snippet: `<EuiFormRow label="Avatar" display="centerCompressed">
247+
<EuiAvatar name="John Doe" size="s" />
248+
</EuiFormRow>`,
233249
},
234250
{
235251
title: 'In a popover',

src-docs/src/views/form_layouts/form_rows.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
EuiLink,
1111
EuiRange,
1212
EuiSelect,
13+
EuiSpacer,
1314
EuiSwitch,
1415
EuiText,
1516
} from '../../../../src/components';
@@ -135,6 +136,8 @@ export default class extends Component {
135136
/>
136137
</EuiFormRow>
137138

139+
<EuiSpacer />
140+
138141
<EuiButton type="submit" fill>
139142
Save form
140143
</EuiButton>

0 commit comments

Comments
 (0)