From 3a3bdddb3043fd67fb949733eee1ec3975f172f6 Mon Sep 17 00:00:00 2001 From: cchaos Date: Fri, 4 May 2018 18:57:39 -0400 Subject: [PATCH 1/9] Added `compressed` props to - `euiFormControlLayout`: for shifting the icons (and loading and clear) and reducing width - `field_search`, `field_text`, `field_number`, `field_password`, `select`, `checkbox`, `checkbox_group`, `radio`, `radio_group` - __NOT__ to `text_area`, `switch` - `file_picker` needed some extra work to make just look like a normal input field that is compressed. May want to consider also allowing for a non-compressed but but normal input style as well. --- src-docs/src/views/form_controls/checkbox.js | 10 ++++ .../src/views/form_controls/checkbox_group.js | 18 +++++++ .../src/views/form_controls/field_number.js | 9 ++++ .../src/views/form_controls/field_password.js | 9 ++++ .../src/views/form_controls/field_search.js | 9 ++++ .../src/views/form_controls/field_text.js | 9 ++++ .../src/views/form_controls/file_picker.js | 10 ++++ src-docs/src/views/form_controls/radio.js | 10 ++++ .../src/views/form_controls/radio_group.js | 18 +++++++ src-docs/src/views/form_controls/select.js | 9 ++++ .../__snapshots__/basic_table.test.js.snap | 28 ++++++++++ .../__snapshots__/date_picker.test.js.snap | 1 + src/components/form/_mixins.scss | 6 +++ src/components/form/checkbox/_checkbox.scss | 8 ++- .../form/checkbox/_checkbox_group.scss | 4 ++ src/components/form/checkbox/checkbox.js | 10 +++- .../form/checkbox/checkbox_group.js | 9 +++- .../__snapshots__/field_number.test.js.snap | 6 +++ .../form/field_number/field_number.js | 8 +++ .../__snapshots__/field_password.test.js.snap | 4 ++ .../form/field_password/field_password.js | 8 +++ .../__snapshots__/field_search.test.js.snap | 4 ++ .../form/field_search/field_search.js | 12 ++++- .../__snapshots__/field_text.test.js.snap | 4 ++ src/components/form/field_text/field_text.js | 8 +++ .../form/file_picker/_file_picker.scss | 53 +++++++++++++++++-- .../form/file_picker/file_picker.js | 44 +++++++++++---- .../_form_control_layout.scss | 26 +++++---- .../form/form_control_layout/_index.scss | 1 + .../form/form_control_layout/_mixins.scss | 16 ++++++ .../form_control_layout.js | 15 +++++- src/components/form/radio/_radio.scss | 8 ++- src/components/form/radio/_radio_group.scss | 4 ++ src/components/form/radio/radio.js | 10 +++- src/components/form/radio/radio_group.js | 8 +++ .../__snapshots__/search_box.test.js.snap | 2 + src/global_styling/variables/_typography.scss | 12 ++--- 37 files changed, 387 insertions(+), 43 deletions(-) create mode 100644 src/components/form/form_control_layout/_mixins.scss diff --git a/src-docs/src/views/form_controls/checkbox.js b/src-docs/src/views/form_controls/checkbox.js index 02b988bd683..73acf8e3320 100644 --- a/src-docs/src/views/form_controls/checkbox.js +++ b/src-docs/src/views/form_controls/checkbox.js @@ -44,6 +44,16 @@ export default class extends Component { onChange={this.onChange} disabled /> + + + + ); } diff --git a/src-docs/src/views/form_controls/checkbox_group.js b/src-docs/src/views/form_controls/checkbox_group.js index fbacff5c3f8..6f91c718240 100644 --- a/src-docs/src/views/form_controls/checkbox_group.js +++ b/src-docs/src/views/form_controls/checkbox_group.js @@ -6,6 +6,7 @@ import React, { import { EuiCheckboxGroup, EuiSpacer, + EuiTitle, } from '../../../../src/components'; import makeId from '../../../../src/components/form/form_row/make_id'; @@ -55,12 +56,29 @@ export default class extends Component { +

Disabled

+ + + + + + +

Compressed

+ + + + ); } diff --git a/src-docs/src/views/form_controls/field_number.js b/src-docs/src/views/form_controls/field_number.js index f8a164810dc..c365e1301fd 100644 --- a/src-docs/src/views/form_controls/field_number.js +++ b/src-docs/src/views/form_controls/field_number.js @@ -69,6 +69,15 @@ export default class extends Component { onChange={this.onChange} readOnly /> + + + + ); } diff --git a/src-docs/src/views/form_controls/field_password.js b/src-docs/src/views/form_controls/field_password.js index 4c1c5e1ac5a..ced47a8897b 100644 --- a/src-docs/src/views/form_controls/field_password.js +++ b/src-docs/src/views/form_controls/field_password.js @@ -59,6 +59,15 @@ export default class extends Component { isLoading disabled /> + + + + ); } diff --git a/src-docs/src/views/form_controls/field_search.js b/src-docs/src/views/form_controls/field_search.js index 4781eeeed2f..fe6974416cc 100644 --- a/src-docs/src/views/form_controls/field_search.js +++ b/src-docs/src/views/form_controls/field_search.js @@ -68,6 +68,15 @@ export default class extends Component { onChange={this.onChange} readOnly /> + + + + ); } diff --git a/src-docs/src/views/form_controls/field_text.js b/src-docs/src/views/form_controls/field_text.js index b165642648a..e3f4e3e8236 100644 --- a/src-docs/src/views/form_controls/field_text.js +++ b/src-docs/src/views/form_controls/field_text.js @@ -68,6 +68,15 @@ export default class extends Component { onChange={this.onChange} readOnly /> + + + + ); } diff --git a/src-docs/src/views/form_controls/file_picker.js b/src-docs/src/views/form_controls/file_picker.js index 295bfc0ef30..bd68e23d134 100644 --- a/src-docs/src/views/form_controls/file_picker.js +++ b/src-docs/src/views/form_controls/file_picker.js @@ -65,6 +65,16 @@ export class FilePicker extends Component { disabled initialPromptText="Disabled" /> + + + + { this.onChange(files); }} + /> ); } diff --git a/src-docs/src/views/form_controls/radio.js b/src-docs/src/views/form_controls/radio.js index d802d906506..645e2e2429d 100644 --- a/src-docs/src/views/form_controls/radio.js +++ b/src-docs/src/views/form_controls/radio.js @@ -44,6 +44,16 @@ export default class extends Component { onChange={this.onChange} disabled /> + + + + ); } diff --git a/src-docs/src/views/form_controls/radio_group.js b/src-docs/src/views/form_controls/radio_group.js index 73c6e925033..b96f0e57516 100644 --- a/src-docs/src/views/form_controls/radio_group.js +++ b/src-docs/src/views/form_controls/radio_group.js @@ -6,6 +6,7 @@ import React, { import { EuiRadioGroup, EuiSpacer, + EuiTitle, } from '../../../../src/components'; import makeId from '../../../../src/components/form/form_row/make_id'; @@ -49,12 +50,29 @@ export default class extends Component { +

Disabled

+ + + + + + +

Compressed

+ + + + ); } diff --git a/src-docs/src/views/form_controls/select.js b/src-docs/src/views/form_controls/select.js index 7771bf7266d..eca3118fa0a 100644 --- a/src-docs/src/views/form_controls/select.js +++ b/src-docs/src/views/form_controls/select.js @@ -65,6 +65,15 @@ export default class extends Component { isLoading disabled /> + + + + ); } diff --git a/src/components/basic_table/__snapshots__/basic_table.test.js.snap b/src/components/basic_table/__snapshots__/basic_table.test.js.snap index 4f2bcb28d97..f8b9fb5ca9c 100644 --- a/src/components/basic_table/__snapshots__/basic_table.test.js.snap +++ b/src/components/basic_table/__snapshots__/basic_table.test.js.snap @@ -484,6 +484,7 @@ exports[`EuiBasicTable with pagination and selection 1`] = ` > { const classes = classNames( 'euiCheckbox', typeToClassNameMap[type], { - 'euiCheckbox--noLabel': !label + 'euiCheckbox--noLabel': !label, + 'euiCheckbox--compressed': compressed }, className ); @@ -69,9 +71,15 @@ EuiCheckbox.propTypes = { onChange: PropTypes.func.isRequired, type: PropTypes.oneOf(TYPES), disabled: PropTypes.bool, + /** + * when `true` creates a shorter height checkbox row + * and decreases font size + */ + compressed: PropTypes.bool, }; EuiCheckbox.defaultProps = { checked: false, disabled: false, + compressed: false, }; diff --git a/src/components/form/checkbox/checkbox_group.js b/src/components/form/checkbox/checkbox_group.js index d7c6d66de3b..7ce03282390 100644 --- a/src/components/form/checkbox/checkbox_group.js +++ b/src/components/form/checkbox/checkbox_group.js @@ -9,6 +9,7 @@ export const EuiCheckboxGroup = ({ onChange, className, disabled, + compressed, ...rest }) => (
@@ -22,6 +23,7 @@ export const EuiCheckboxGroup = ({ label={option.label} disabled={disabled} onChange={onChange.bind(null, option.id)} + compressed={compressed} /> ); })} @@ -37,9 +39,14 @@ EuiCheckboxGroup.propTypes = { ).isRequired, idToSelectedMap: PropTypes.objectOf(PropTypes.bool).isRequired, onChange: PropTypes.func.isRequired, + /** + * Tightens up the spacing between checkbox rows and sends down the + * compressed prop to the checkbox itself + */ + compressed: PropTypes.bool, }; EuiCheckboxGroup.defaultProps = { options: [], - idToSelectedMap: {}, + idToSelectedMap: {} }; diff --git a/src/components/form/field_number/__snapshots__/field_number.test.js.snap b/src/components/form/field_number/__snapshots__/field_number.test.js.snap index ae14364da23..18847581463 100644 --- a/src/components/form/field_number/__snapshots__/field_number.test.js.snap +++ b/src/components/form/field_number/__snapshots__/field_number.test.js.snap @@ -2,6 +2,7 @@ exports[`EuiFieldNumber is rendered 1`] = ` @@ -39,6 +41,7 @@ exports[`EuiFieldNumber props fullWidth is rendered 1`] = ` exports[`EuiFieldNumber props isInvalid is rendered 1`] = ` @@ -55,6 +58,7 @@ exports[`EuiFieldNumber props isInvalid is rendered 1`] = ` exports[`EuiFieldNumber props isLoading is rendered 1`] = ` @@ -69,6 +73,7 @@ exports[`EuiFieldNumber props isLoading is rendered 1`] = ` exports[`EuiFieldNumber props value no initial value 1`] = ` @@ -84,6 +89,7 @@ exports[`EuiFieldNumber props value no initial value 1`] = ` exports[`EuiFieldNumber props value value is number 1`] = ` diff --git a/src/components/form/field_number/field_number.js b/src/components/form/field_number/field_number.js index 0eb246fb9de..a75471e455a 100644 --- a/src/components/form/field_number/field_number.js +++ b/src/components/form/field_number/field_number.js @@ -22,11 +22,13 @@ export const EuiFieldNumber = ({ isInvalid, fullWidth, isLoading, + compressed, ...rest }) => { const classes = classNames('euiFieldNumber', className, { 'euiFieldNumber--withIcon': icon, 'euiFieldNumber--fullWidth': fullWidth, + 'euiFieldNumber--compressed': compressed, 'euiFieldNumber-isLoading': isLoading, }); @@ -35,6 +37,7 @@ export const EuiFieldNumber = ({ icon={icon} fullWidth={fullWidth} isLoading={isLoading} + compressed={compressed} > { const classes = classNames( 'euiFieldPassword', { 'euiFieldPassword--fullWidth': fullWidth, + 'euiFieldPassword--compressed': compressed, 'euiFieldPassword-isLoading': isLoading, }, className @@ -35,6 +37,7 @@ export const EuiFieldPassword = ({ icon="lock" fullWidth={fullWidth} isLoading={isLoading} + compressed={compressed} > @@ -37,6 +39,7 @@ exports[`EuiFieldText props fullWidth is rendered 1`] = ` exports[`EuiFieldText props isInvalid is rendered 1`] = ` @@ -53,6 +56,7 @@ exports[`EuiFieldText props isInvalid is rendered 1`] = ` exports[`EuiFieldText props isLoading is rendered 1`] = ` diff --git a/src/components/form/field_text/field_text.js b/src/components/form/field_text/field_text.js index e4436716290..7fb91cd72f9 100644 --- a/src/components/form/field_text/field_text.js +++ b/src/components/form/field_text/field_text.js @@ -21,11 +21,13 @@ export const EuiFieldText = ({ inputRef, fullWidth, isLoading, + compressed, ...rest }) => { const classes = classNames('euiFieldText', className, { 'euiFieldText--withIcon': icon, 'euiFieldText--fullWidth': fullWidth, + 'euiFieldText--compressed': compressed, 'euiFieldText-isLoading': isLoading, }); @@ -34,6 +36,7 @@ export const EuiFieldText = ({ icon={icon} fullWidth={fullWidth} isLoading={isLoading} + compressed={compressed} > - Remove - - ); + if (compressed) { + clearButton = ( + + ) + } else { + clearButton = ( + + Remove + + ); + } } else { clearButton = null; } @@ -125,7 +147,7 @@ export class EuiFilePicker extends Component {