From f5f82c6123f7f5c7059d5d1df24f071b02f7cee5 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Tue, 26 Jun 2018 16:28:07 -0400
Subject: [PATCH 01/21] Updating filter buttons and group styles
---
.../src/views/filter_group/filter_group.js | 17 +++-
.../filter_group/_filter_button.scss | 85 ++++++++-----------
.../filter_group/_filter_group.scss | 10 +--
src/components/filter_group/filter_button.js | 17 ++--
src/components/form/_mixins.scss | 4 +-
src/components/form/_variables.scss | 2 +
6 files changed, 66 insertions(+), 69 deletions(-)
diff --git a/src-docs/src/views/filter_group/filter_group.js b/src-docs/src/views/filter_group/filter_group.js
index 48a0a2b2f21..8003787cd26 100644
--- a/src-docs/src/views/filter_group/filter_group.js
+++ b/src-docs/src/views/filter_group/filter_group.js
@@ -21,9 +21,16 @@ export default class extends Component {
this.state = {
isPopoverOpen: false,
+ isFilterOn: false,
};
}
+ toggleFilter = () => {
+ this.setState({
+ isFilterOn: !this.state.isFilterOn,
+ });
+ }
+
onButtonClick() {
this.setState({
isPopoverOpen: !this.state.isPopoverOpen,
@@ -66,6 +73,7 @@ export default class extends Component {
onClick={this.onButtonClick.bind(this)}
isSelected={this.state.isPopoverOpen}
hasActiveFilters={true}
+ className="euiFilterButton--wide"
>
Composers
@@ -73,11 +81,11 @@ export default class extends Component {
return (
-
- Filter on
+
+ Filter
-
- Filter off
+
+ Filter Disabled
diff --git a/src/components/filter_group/_filter_button.scss b/src/components/filter_group/_filter_button.scss
index c0c73b4733c..93cb2729bda 100644
--- a/src/components/filter_group/_filter_button.scss
+++ b/src/components/filter_group/_filter_button.scss
@@ -1,26 +1,50 @@
+@import '../form/variables';
+@import '../form/mixins';
+
/**
- * 1. We don't want any of the animations that come inherited from the mixin.
- * These should act like normal links instead.
+ * 1. Only add the border style drop shadow
*/
+
.euiFilterButton {
- @include euiButton;
- line-height: 40px;
- border-color: transparent;
- background-color: transparent;
- box-shadow: none;
- transform: none !important; // 1
- animation: none !important; // 1
+ @include euiFormControlStyle();
+ width: auto;
+ max-width: none;
+ box-shadow: inset 0 0 0 1px $euiFormBorderColor; /* 1 */
+ text-align: center;
+
+ &:hover:not(:disabled) {
+ .euiFilterButton__textShift {
+ text-decoration: underline;
+ }
+ }
+
+ &:focus {
+ background-color: $euiFormBackgroundColor;
+ box-shadow: inset 0 0 0 1px $euiFormBorderColor; /* 1 */
+ }
+
+ &:disabled {
+ box-shadow: inset 0 0 0 1px $euiFormBorderColor--disabled; /* 1 */
+ }
+
+ &.euiFilterButton--wide {
+ width: 100%;
+ text-align: left;
+ }
.euiFilterButton__content {
@include euiButtonContent;
+ }
- padding: 0 $euiSizeS;
-
+ &.euiFilterButton--iconRight {
+ .euiFilterButton__content {
+ @include euiButtonContent($isReverse: true);
+ justify-content: space-between;
+ }
}
.euiFilterButton__textShift {
- text-align: center;
display: inline-block;
&::after {
@@ -33,31 +57,6 @@
}
}
- &.euiFilterButton--iconRight {
- .euiFilterButton__content {
- @include euiButtonContent($isReverse: true);
- }
- }
-
- &:disabled {
- color: $euiButtonColorDisabled;
- pointer-events: none;
-
- .euiFilterButton__content {
- pointer-events: auto;
- cursor: not-allowed;
- }
-
- .euiFilterButton__icon {
- fill: $euiButtonColorDisabled;
- }
-
- &:hover, &:focus {
- background-color: $euiColorEmptyShade;
- text-decoration: none;
- }
- }
-
&.euiFilterButton-isSelected {
text-decoration: underline;
}
@@ -80,17 +79,5 @@ $buttonTypes: (
@each $name, $color in $buttonTypes {
.euiFilterButton--#{$name} {
color: $color;
-
- .euiFilterButton__icon {
- fill: $color;
- }
-
- &:hover {
- background-color: transparent;
-
- @if ($name == 'disabled') {
- cursor: not-allowed;
- }
- }
}
}
diff --git a/src/components/filter_group/_filter_group.scss b/src/components/filter_group/_filter_group.scss
index 31f1cff9aac..ecf62398131 100644
--- a/src/components/filter_group/_filter_group.scss
+++ b/src/components/filter_group/_filter_group.scss
@@ -1,12 +1,10 @@
.euiFilterGroup {
- @include euiFormControlStyle;
- height: 40px;
- padding: 0px;
- width: auto;
- display: inline-block;
+ display: flex;
+ // Match just the regular box-shadow of inputs
+ box-shadow: 0 3px 2px -2px rgba($euiShadowColor, 0.2);
> * + * {
- border-left: $euiBorderThin;
+ margin-left: -1px;
}
}
diff --git a/src/components/filter_group/filter_button.js b/src/components/filter_group/filter_button.js
index 7050f750934..ee60119f433 100644
--- a/src/components/filter_group/filter_button.js
+++ b/src/components/filter_group/filter_button.js
@@ -67,6 +67,13 @@ export const EuiFilterButton = ({
);
}
+ const buttonContents = (
+
+ {buttonIcon}
+ {children}
+
+ );
+
if (href) {
const secureRel = getSecureRelForTarget(target, rel);
@@ -78,10 +85,7 @@ export const EuiFilterButton = ({
rel={secureRel}
{...rest}
>
-
- {buttonIcon}
- {children}
-
+ {buttonContents}
);
} else {
@@ -92,10 +96,7 @@ export const EuiFilterButton = ({
type={type}
{...rest}
>
-
- {buttonIcon}
- {children}
-
+ {buttonContents}
);
}
diff --git a/src/components/form/_mixins.scss b/src/components/form/_mixins.scss
index 4d76dc6bc89..dd93f5cb29c 100644
--- a/src/components/form/_mixins.scss
+++ b/src/components/form/_mixins.scss
@@ -39,7 +39,7 @@
@mixin euiFormControlDefaultShadow {
box-shadow:
0 3px 2px -2px rgba($euiShadowColor, 0.2),
- inset 0 0 0 1px transparentize($euiColorFullShade, .9),
+ inset 0 0 0 1px $euiFormBorderColor,
inset #{-$euiFormMaxWidth} 0 0 0 $euiFormBackgroundColor;
}
@@ -63,7 +63,7 @@
@mixin euiFormControlDisabledStyle {
cursor: not-allowed;
background: darken($euiColorLightestShade, 2%);
- box-shadow: inset 0 0 0 1px transparentize($euiColorFullShade, .92);
+ box-shadow: inset 0 0 0 1px $euiFormBorderColor--disabled;
color: $euiFormControlDisabledColor;
&::placeholder {
diff --git a/src/components/form/_variables.scss b/src/components/form/_variables.scss
index 86c5fbf6714..8702a7a987f 100644
--- a/src/components/form/_variables.scss
+++ b/src/components/form/_variables.scss
@@ -1,5 +1,7 @@
$euiFormMaxWidth: 400px;
$euiFormBackgroundColor: tintOrShade($euiColorLightestShade, 60%, 25%);
+$euiFormBorderColor: transparentize($euiColorFullShade, .9);
+$euiFormBorderColor--disabled: transparentize($euiColorFullShade, .92);
$euiFormCustomControlDisabledIconColor: shadeOrTint($euiColorMediumShade, 38%, 48.5%); // exact 508c foreground for $euiColorLightShade
$euiRadioSize: $euiSize;
From 8c01c9603e7a7de7bd8426908e1cf3d71769b1a9 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Tue, 26 Jun 2018 18:21:55 -0400
Subject: [PATCH 02/21] Using form layout and notifications
---
.../src/views/filter_group/filter_group.js | 5 +-
.../__snapshots__/filter_button.test.js.snap | 6 +-
.../filter_select_item.test.js.snap | 2 +-
.../filter_group/_filter_button.scss | 63 ++++++++++---------
.../filter_group/_filter_group.scss | 5 ++
src/components/filter_group/filter_button.js | 47 ++++++++------
.../filter_group/filter_select_item.js | 1 +
.../header/_header_notification.scss | 1 +
.../field_value_selection_filter.test.js.snap | 4 ++
.../field_value_toggle_filter.test.js.snap | 4 ++
...eld_value_toggle_group_filter.test.js.snap | 8 +++
.../__snapshots__/is_filter.test.js.snap | 1 +
12 files changed, 93 insertions(+), 54 deletions(-)
diff --git a/src-docs/src/views/filter_group/filter_group.js b/src-docs/src/views/filter_group/filter_group.js
index 8003787cd26..1ac38609570 100644
--- a/src-docs/src/views/filter_group/filter_group.js
+++ b/src-docs/src/views/filter_group/filter_group.js
@@ -73,7 +73,8 @@ export default class extends Component {
onClick={this.onButtonClick.bind(this)}
isSelected={this.state.isPopoverOpen}
hasActiveFilters={true}
- className="euiFilterButton--wide"
+ numFilters={2}
+ grow={true}
>
Composers
@@ -96,7 +97,7 @@ export default class extends Component {
panelPaddingSize="none"
withTitle
panelClassName="euiFilterGroup__popoverPanel"
- style={{ flexGrow: '1', fontSize: '0' }}
+ style={{ fontSize: '0' }}
>
diff --git a/src/components/filter_group/__snapshots__/filter_button.test.js.snap b/src/components/filter_group/__snapshots__/filter_button.test.js.snap
index 320e2570a0d..5443a25e5ad 100644
--- a/src/components/filter_group/__snapshots__/filter_button.test.js.snap
+++ b/src/components/filter_group/__snapshots__/filter_button.test.js.snap
@@ -7,12 +7,12 @@ exports[`EuiFilterButton is rendered 1`] = `
data-test-subj="test subject string"
type="button"
>
-
-
+
`;
diff --git a/src/components/filter_group/__snapshots__/filter_select_item.test.js.snap b/src/components/filter_group/__snapshots__/filter_select_item.test.js.snap
index 10494b47fc4..78de8ac186d 100644
--- a/src/components/filter_group/__snapshots__/filter_select_item.test.js.snap
+++ b/src/components/filter_group/__snapshots__/filter_select_item.test.js.snap
@@ -8,7 +8,7 @@ exports[`EuiFilterSelectItem is rendered 1`] = `
type="button"
>
* {
+ // defaults to growing children though filter buttons don't grow by default
+ flex-grow: 1;
+ }
+
> * + * {
margin-left: -1px;
}
diff --git a/src/components/filter_group/filter_button.js b/src/components/filter_group/filter_button.js
index ee60119f433..70480ae7a55 100644
--- a/src/components/filter_group/filter_button.js
+++ b/src/components/filter_group/filter_button.js
@@ -3,10 +3,11 @@ import PropTypes from 'prop-types';
import classNames from 'classnames';
import { getSecureRelForTarget } from '../../services';
+import { EuiFormControlLayout } from '../form/form_control_layout';
+import { EuiHeaderNotification } from '../header/header_notification';
import {
ICON_TYPES,
- EuiIcon,
} from '../icon';
const colorToClassNameMap = {
@@ -33,12 +34,14 @@ export const EuiFilterButton = ({
iconSide,
color,
hasActiveFilters,
+ numFilters,
isDisabled,
isSelected,
href,
target,
rel,
type,
+ grow,
...rest
}) => {
@@ -49,29 +52,28 @@ export const EuiFilterButton = ({
{
'euiFilterButton-isSelected': isSelected,
'euiFilterButton-hasActiveFilters': hasActiveFilters,
+ 'euiFilterButton-grow': grow,
},
className,
);
- // Add an icon to the button if one exists.
- let buttonIcon;
-
- if (iconType) {
- buttonIcon = (
-
- );
- }
+ const icon = iconType ? {
+ type: iconType,
+ side: iconSide,
+ } : undefined;
const buttonContents = (
-
- {buttonIcon}
- {children}
-
+
+
+ {children}
+ {numFilters &&
+ {numFilters}
+ }
+
+
);
if (href) {
@@ -116,6 +118,10 @@ EuiFilterButton.propTypes = {
* Bolds the button if true
*/
hasActiveFilters: PropTypes.bool,
+ /**
+ * Adds a notification with number
+ */
+ numFilters: PropTypes.number,
/**
* Applies a visual state to the button useful when using with a popover.
*/
@@ -137,10 +143,15 @@ EuiFilterButton.propTypes = {
* Defines html button input type
*/
type: PropTypes.string,
+ /**
+ * Should the button grow to fill it's container, best used for dropdown buttons
+ */
+ grow: PropTypes.bool,
};
EuiFilterButton.defaultProps = {
type: 'button',
iconSide: 'right',
color: 'text',
+ grow: false,
};
diff --git a/src/components/filter_group/filter_select_item.js b/src/components/filter_group/filter_select_item.js
index 04761c62785..0514925f66c 100644
--- a/src/components/filter_group/filter_select_item.js
+++ b/src/components/filter_group/filter_select_item.js
@@ -68,6 +68,7 @@ export class EuiFilterSelectItem extends Component {
alignItems="center"
gutterSize="s"
component="span"
+ responsive={false}
>
diff --git a/src/components/header/_header_notification.scss b/src/components/header/_header_notification.scss
index 26ddc2601f0..0535dd9993a 100644
--- a/src/components/header/_header_notification.scss
+++ b/src/components/header/_header_notification.scss
@@ -9,4 +9,5 @@
height: $euiSize;
min-width: $euiSize;
vertical-align: middle;
+ text-align: center;
}
diff --git a/src/components/search_bar/filters/__snapshots__/field_value_selection_filter.test.js.snap b/src/components/search_bar/filters/__snapshots__/field_value_selection_filter.test.js.snap
index 994cbf6970a..00698953ecf 100644
--- a/src/components/search_bar/filters/__snapshots__/field_value_selection_filter.test.js.snap
+++ b/src/components/search_bar/filters/__snapshots__/field_value_selection_filter.test.js.snap
@@ -6,6 +6,7 @@ exports[`FieldValueSelectionFilter render - all configurations 1`] = `
button={
,
,
,
,
Date: Tue, 26 Jun 2018 18:45:28 -0400
Subject: [PATCH 03/21] Fixing icon padding
---
.../__snapshots__/filter_button.test.js.snap | 2 +-
src/components/filter_group/_filter_button.scss | 15 +++++++++++++++
src/components/filter_group/filter_button.js | 6 ++++--
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/src/components/filter_group/__snapshots__/filter_button.test.js.snap b/src/components/filter_group/__snapshots__/filter_button.test.js.snap
index 5443a25e5ad..634d5d4a558 100644
--- a/src/components/filter_group/__snapshots__/filter_button.test.js.snap
+++ b/src/components/filter_group/__snapshots__/filter_button.test.js.snap
@@ -3,7 +3,7 @@
exports[`EuiFilterButton is rendered 1`] = `
diff --git a/src/components/filter_group/_filter_button.scss b/src/components/filter_group/_filter_button.scss
index 4ab1c49159e..aa7640d1eea 100644
--- a/src/components/filter_group/_filter_button.scss
+++ b/src/components/filter_group/_filter_button.scss
@@ -1,5 +1,6 @@
@import '../form/variables';
@import '../form/mixins';
+@import '../form/form_control_layout/mixins';
/**
* 1. Only add the border style drop shadow
@@ -13,6 +14,7 @@
width: auto;
max-width: none;
box-shadow: inset 0 0 0 1px $euiFormBorderColor; /* 1 */
+ white-space: nowrap;
}
&:focus .euiFilterButton__content {
@@ -84,3 +86,16 @@ $buttonTypes: (
color: $color;
}
}
+
+// Icon padding
+.euiFilterButton--iconLeft {
+ .euiFilterButton__content {
+ @include euiFormControlLayout__padding(1, "left");
+ }
+}
+
+.euiFilterButton--iconRight {
+ .euiFilterButton__content {
+ @include euiFormControlLayout__padding(1);
+ }
+}
diff --git a/src/components/filter_group/filter_button.js b/src/components/filter_group/filter_button.js
index 70480ae7a55..89c04beafeb 100644
--- a/src/components/filter_group/filter_button.js
+++ b/src/components/filter_group/filter_button.js
@@ -21,7 +21,7 @@ const colorToClassNameMap = {
export const COLORS = Object.keys(colorToClassNameMap);
const iconSideToClassNameMap = {
- left: '',
+ left: 'euiFilterButton--iconLeft',
right: 'euiFilterButton--iconRight',
};
@@ -45,10 +45,12 @@ export const EuiFilterButton = ({
...rest
}) => {
+ const iconClasses = iconType ? iconSideToClassNameMap[iconSide] : undefined;
+
const classes = classNames(
'euiFilterButton',
colorToClassNameMap[color],
- iconSideToClassNameMap[iconSide],
+ iconClasses,
{
'euiFilterButton-isSelected': isSelected,
'euiFilterButton-hasActiveFilters': hasActiveFilters,
From 70bc54d59073883420853231ea1326b1cae42a07 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Wed, 27 Jun 2018 15:12:02 -0400
Subject: [PATCH 04/21] Control groups
---
.../src/views/form_layouts/control_group.js | 50 ++++++++++++++
.../form_layouts/form_layouts_example.js | 21 ++++++
src/components/form/_index.scss | 1 +
.../form_control_group.test.js.snap | 9 +++
.../_form_control_group.scss | 68 +++++++++++++++++++
.../form/form_control_group/_index.scss | 1 +
.../form_control_group/form_control_group.js | 25 +++++++
.../form_control_group.test.js | 16 +++++
.../form/form_control_group/index.js | 3 +
src/components/form/index.js | 1 +
src/components/index.js | 1 +
11 files changed, 196 insertions(+)
create mode 100644 src-docs/src/views/form_layouts/control_group.js
create mode 100644 src/components/form/form_control_group/__snapshots__/form_control_group.test.js.snap
create mode 100644 src/components/form/form_control_group/_form_control_group.scss
create mode 100644 src/components/form/form_control_group/_index.scss
create mode 100644 src/components/form/form_control_group/form_control_group.js
create mode 100644 src/components/form/form_control_group/form_control_group.test.js
create mode 100644 src/components/form/form_control_group/index.js
diff --git a/src-docs/src/views/form_layouts/control_group.js b/src-docs/src/views/form_layouts/control_group.js
new file mode 100644
index 00000000000..1acc32f84e6
--- /dev/null
+++ b/src-docs/src/views/form_layouts/control_group.js
@@ -0,0 +1,50 @@
+import React, { Fragment } from 'react';
+import moment from 'moment';
+
+import {
+ EuiFormControlGroup,
+ EuiFormLabel,
+ EuiFieldText,
+ EuiButton,
+ EuiIcon,
+ EuiText,
+ EuiDatePicker,
+ EuiFieldNumber,
+ EuiSpacer,
+ EuiHorizontalRule,
+} from '../../../../src/components';
+
+export default () => (
+
+
+ Label:
+
+
+
+
+
+
+
+ %
+
+
+
+
+
+ Label:
+
+
+
+
+
+
+
+
+
+
+
+ →
+
+
+
+);
diff --git a/src-docs/src/views/form_layouts/form_layouts_example.js b/src-docs/src/views/form_layouts/form_layouts_example.js
index e7b45b0789e..f893644e225 100644
--- a/src-docs/src/views/form_layouts/form_layouts_example.js
+++ b/src-docs/src/views/form_layouts/form_layouts_example.js
@@ -12,6 +12,7 @@ import {
EuiFormRow,
EuiDescribedFormGroup,
EuiFieldText,
+ EuiFormControlGroup,
EuiPopover,
EuiRange,
EuiSwitch,
@@ -49,6 +50,10 @@ import FormCompressed from './form_compressed';
const formCompressedSource = require('!!raw-loader!./form_compressed');
const formCompressedHtml = renderToHtml(FormCompressed);
+import ControlGroup from './control_group';
+const controlGroupSource = require('!!raw-loader!./control_group');
+const controlGroupHtml = renderToHtml(ControlGroup);
+
export const FormLayoutsExample = {
title: 'Form layouts',
sections: [{
@@ -215,5 +220,21 @@ export const FormLayoutsExample = {
),
demo: ,
+ }, {
+ title: 'Groups',
+ source: [{
+ type: GuideSectionTypes.JS,
+ code: controlGroupSource,
+ }, {
+ type: GuideSectionTypes.HTML,
+ code: controlGroupHtml,
+ }],
+ text: (
+
+ For use in confined spaces.
+
+ ),
+ demo: ,
+ props: { EuiFormControlGroup }
}],
};
diff --git a/src/components/form/_index.scss b/src/components/form/_index.scss
index 42e041a9695..1914776056a 100644
--- a/src/components/form/_index.scss
+++ b/src/components/form/_index.scss
@@ -12,6 +12,7 @@
@import 'file_picker/index';
@import 'form';
@import 'form_control_layout/index';
+@import 'form_control_group/index';
@import 'form_error_text/index';
@import 'form_help_text/index';
@import 'form_label/index';
diff --git a/src/components/form/form_control_group/__snapshots__/form_control_group.test.js.snap b/src/components/form/form_control_group/__snapshots__/form_control_group.test.js.snap
new file mode 100644
index 00000000000..cdc7639891b
--- /dev/null
+++ b/src/components/form/form_control_group/__snapshots__/form_control_group.test.js.snap
@@ -0,0 +1,9 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`EuiFormControlGroup is rendered 1`] = `
+
+`;
diff --git a/src/components/form/form_control_group/_form_control_group.scss b/src/components/form/form_control_group/_form_control_group.scss
new file mode 100644
index 00000000000..b8e2b58b170
--- /dev/null
+++ b/src/components/form/form_control_group/_form_control_group.scss
@@ -0,0 +1,68 @@
+/**
+ * 1. Account for inner box-shadow style border
+ */
+
+.euiFormControlGroup {
+ // Match just the regular box-shadow of inputs
+ @include euiFormControlStyle();
+ display: flex;
+ padding: 1px; /* 1 */
+
+ &--focus {
+ @include euiFormControlFocusStyle();
+ }
+
+ > * {
+ // defaults to growing children though filter buttons don't grow by default
+ flex-grow: 1;
+ }
+
+ > .euiFormControlLayout {
+ max-width: none;
+ }
+
+ [class*="euiField"] {
+ box-shadow: none;
+ height: $euiFormControlHeight - 2px; /* 1 */
+ }
+
+ > .euiFormLabel {
+ flex-grow: 0;
+ white-space: nowrap;
+ margin-bottom: 0;
+ height: $euiFormControlHeight - 2px; /* 1 */
+ line-height: 1.4em;
+ padding: $euiFormControlPadding;
+ background-color: transparentize($euiColorFullShade, .95);
+ }
+
+ > .euiButton {
+ min-width: $euiSizeXL*2;
+ border: none;
+ box-shadow: none !important;
+ }
+
+ > .euiText {
+ line-height: $euiFormControlHeight - 2px !important;
+ }
+
+ .euiHorizontalRule {
+ width: 1.1px !important;
+ height: $euiFormControlHeight - 2px;
+ margin: 0;
+ }
+
+ // Date picker hack
+ .euiDatePicker {
+ // The actual input
+ .euiDatePicker {
+ text-align: center;
+ padding-left: $euiFormControlPadding;
+ }
+
+ // Force remove icon
+ .euiFormControlLayoutIcons {
+ display: none;
+ }
+ }
+}
diff --git a/src/components/form/form_control_group/_index.scss b/src/components/form/form_control_group/_index.scss
new file mode 100644
index 00000000000..fdca4d3282c
--- /dev/null
+++ b/src/components/form/form_control_group/_index.scss
@@ -0,0 +1 @@
+@import 'form_control_group';
diff --git a/src/components/form/form_control_group/form_control_group.js b/src/components/form/form_control_group/form_control_group.js
new file mode 100644
index 00000000000..eab29beae45
--- /dev/null
+++ b/src/components/form/form_control_group/form_control_group.js
@@ -0,0 +1,25 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import classNames from 'classnames';
+
+export const EuiFormControlGroup = ({
+ children,
+ className,
+ ...rest,
+}) => {
+ const classes = classNames('euiFormControlGroup', className);
+
+ return (
+
+ {children}
+
+ );
+};
+
+EuiFormControlGroup.propTypes = {
+ children: PropTypes.node,
+ className: PropTypes.string,
+};
diff --git a/src/components/form/form_control_group/form_control_group.test.js b/src/components/form/form_control_group/form_control_group.test.js
new file mode 100644
index 00000000000..f134444a77e
--- /dev/null
+++ b/src/components/form/form_control_group/form_control_group.test.js
@@ -0,0 +1,16 @@
+import React from 'react';
+import { render } from 'enzyme';
+import { requiredProps } from '../../../test';
+
+import { EuiFormControlGroup } from './form_control_group';
+
+describe('EuiFormControlGroup', () => {
+ test('is rendered', () => {
+ const component = render(
+
+ );
+
+ expect(component)
+ .toMatchSnapshot();
+ });
+});
diff --git a/src/components/form/form_control_group/index.js b/src/components/form/form_control_group/index.js
new file mode 100644
index 00000000000..323e550fa93
--- /dev/null
+++ b/src/components/form/form_control_group/index.js
@@ -0,0 +1,3 @@
+export {
+ EuiFormControlGroup,
+} from './form_control_group';
diff --git a/src/components/form/index.js b/src/components/form/index.js
index f04fdc5605b..469754f3223 100644
--- a/src/components/form/index.js
+++ b/src/components/form/index.js
@@ -9,6 +9,7 @@ export { EuiFieldSearch } from './field_search';
export { EuiFieldText } from './field_text';
export { EuiFilePicker } from './file_picker';
export { EuiForm } from './form';
+export { EuiFormControlGroup } from './form_control_group';
export { EuiFormControlLayout } from './form_control_layout';
export { EuiFormErrorText } from './form_error_text';
export { EuiFormHelpText } from './form_help_text';
diff --git a/src/components/index.js b/src/components/index.js
index 2c41840fd58..f09b158828a 100644
--- a/src/components/index.js
+++ b/src/components/index.js
@@ -120,6 +120,7 @@ export {
EuiFieldText,
EuiFilePicker,
EuiForm,
+ EuiFormControlGroup,
EuiFormControlLayout,
EuiFormErrorText,
EuiFormHelpText,
From c1b5c246aa632c1a060daa5e83963e401f50f676 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Wed, 27 Jun 2018 19:13:32 -0400
Subject: [PATCH 05/21] Simplifying from control styles
- Made botttom colored border from linear-gradient
- Allowing parameters to determine if just the borders should render
- Allowing parameters to determine if all state styles should be added
---
src/components/combo_box/_combo_box.scss | 2 +-
.../filter_group/_filter_button.scss | 13 +--
src/components/form/_mixins.scss | 99 ++++++++++++-------
src/components/form/_variables.scss | 33 ++++---
.../form/file_picker/_file_picker.scss | 6 --
5 files changed, 84 insertions(+), 69 deletions(-)
diff --git a/src/components/combo_box/_combo_box.scss b/src/components/combo_box/_combo_box.scss
index 5d63fa934a8..12d59569efb 100644
--- a/src/components/combo_box/_combo_box.scss
+++ b/src/components/combo_box/_combo_box.scss
@@ -8,7 +8,7 @@
* 3. The height on combo can be larger than normal text inputs.
*/
.euiComboBox__inputWrap {
- @include euiFormControlStyle;
+ @include euiFormControlStyle($includeStates: false);
@include euiFormControlWithIcon($isIconOptional: true);
@include euiFormControlSize(auto); /* 3 */
diff --git a/src/components/filter_group/_filter_button.scss b/src/components/filter_group/_filter_button.scss
index aa7640d1eea..983f66e97ea 100644
--- a/src/components/filter_group/_filter_button.scss
+++ b/src/components/filter_group/_filter_button.scss
@@ -10,22 +10,14 @@
flex-grow: 0; // Shrink by default
.euiFilterButton__content {
- @include euiFormControlStyle();
+ @include euiFormControlStyle($borderOnly: true, $includeStates: false);
width: auto;
max-width: none;
- box-shadow: inset 0 0 0 1px $euiFormBorderColor; /* 1 */
white-space: nowrap;
}
- &:focus .euiFilterButton__content {
- @include euiFormControlFocusStyle;
- background-color: $euiFormBackgroundColor;
- box-shadow: inset 0 0 0 1px $euiFormBorderColor; /* 1 */
- }
-
&:disabled .euiFilterButton__content {
@include euiFormControlDisabledStyle;
- box-shadow: inset 0 0 0 1px $euiFormBorderColor--disabled; /* 1 */
font-style: italic;
}
@@ -50,7 +42,8 @@
}
&.euiFilterButton-isSelected,
- &:hover:not(:disabled) {
+ &:hover:not(:disabled),
+ &:focus:not(:disabled) {
.euiFilterButton__textShift {
text-decoration: underline;
}
diff --git a/src/components/form/_mixins.scss b/src/components/form/_mixins.scss
index dd93f5cb29c..4f8ea4e66d9 100644
--- a/src/components/form/_mixins.scss
+++ b/src/components/form/_mixins.scss
@@ -2,6 +2,15 @@
* 1. Ensure the icon padding remains when in readOnly mode
*/
+@function euiFormControlGradient($color: $euiColorPrimary) {
+ @return linear-gradient(to top,
+ $color,
+ $color ($euiSizeXS / 2),
+ transparent ($euiSizeXS / 2),
+ transparent 100%
+ );
+}
+
@mixin euiFormControlSize($height: $euiFormControlHeight) {
max-width: $euiFormMaxWidth;
width: 100%;
@@ -36,35 +45,52 @@
}
}
-@mixin euiFormControlDefaultShadow {
- box-shadow:
- 0 3px 2px -2px rgba($euiShadowColor, 0.2),
- inset 0 0 0 1px $euiFormBorderColor,
- inset #{-$euiFormMaxWidth} 0 0 0 $euiFormBackgroundColor;
+@mixin euiFormControlDefaultShadow($borderOnly: false) {
+ background-color: $euiFormBackgroundColor;
+ background-repeat: no-repeat;
+ background-size: 0%;
+
+ @if ($borderOnly) {
+ box-shadow: inset 0 0 0 1px $euiFormBorderColor;
+ } @else {
+ box-shadow:
+ 0 1px 1px -1px rgba($euiShadowColor, 0.2),
+ 0 3px 2px -2px rgba($euiShadowColor, 0.2),
+ inset 0 0 0 1px $euiFormBorderColor;
+ }
+
+ transition:
+ box-shadow $euiAnimSpeedFast ease-in,
+ background-color $euiAnimSpeedFast ease-in,
+ background-image $euiAnimSpeedFast ease-in,
+ background-size $euiAnimSpeedFast ease-in;
}
-@mixin euiFormControlInvalidStyle {
- box-shadow:
- 0 $euiSizeXS $euiSizeXS (-$euiSizeXS / 2) rgba($euiShadowColor, 0.2),
- inset 0 0 0 1px transparentize($euiColorFullShade, .84),
- inset 0 0 0 0 $euiColorEmptyShade,
- inset 0 (-$euiSizeXS / 2) 0 0 $euiColorDanger;
+@mixin euiFormControlFocusStyle($borderOnly: false) {
+ background-color: tintOrShade($euiColorEmptyShade, 0%, 50%);
+ background-image: euiFormControlGradient();
+ background-size: 100%;
+
+ @if ($borderOnly) {
+ box-shadow: inset 0 0 0 1px transparentize($euiColorFullShade, .84);
+ } @else {
+ box-shadow:
+ 0 1px 1px -1px rgba($euiShadowColor, 0.2),
+ 0 4px 4px -2px rgba($euiShadowColor, 0.2),
+ inset 0 0 0 1px transparentize($euiColorFullShade, .84);
+ }
}
-@mixin euiFormControlFocusStyle {
- background: tintOrShade($euiColorEmptyShade, 0%, 20%);
- box-shadow:
- 0 4px 4px -2px rgba($euiShadowColor, 0.2),
- inset 0 0 0 1px transparentize($euiColorFullShade, .84),
- inset 0 0 0 0 tintOrShade($euiColorEmptyShade, 0%, 20%),
- inset 0 -2px 0 0 $euiColorPrimary;
+@mixin euiFormControlInvalidStyle() {
+ background-image: euiFormControlGradient($euiColorDanger);
+ background-size: 100%;
}
-@mixin euiFormControlDisabledStyle {
+@mixin euiFormControlDisabledStyle() {
cursor: not-allowed;
- background: darken($euiColorLightestShade, 2%);
- box-shadow: inset 0 0 0 1px $euiFormBorderColor--disabled;
color: $euiFormControlDisabledColor;
+ background: $euiFormBackgroundColor--disabled;
+ box-shadow: inset 0 0 0 1px $euiFormBorderColor--disabled;
&::placeholder {
color: $euiFormControlDisabledColor;
@@ -82,9 +108,9 @@
/**
* 1. Override invalid state with focus state.
*/
-@mixin euiFormControlStyle {
+@mixin euiFormControlStyle($borderOnly: false, $includeStates: true) {
@include euiFormControlSize;
- @include euiFormControlDefaultShadow;
+ @include euiFormControlDefaultShadow($borderOnly);
border: none;
font-size: $euiFontSizeS;
@@ -92,8 +118,6 @@
padding: $euiFormControlPadding;
line-height: 1em; // fixes text alignment in IE
color: $euiTextColor;
- background: $euiFormBackgroundColor;
- transition: box-shadow $euiAnimSpeedNormal ease-in, background $euiAnimSpeedNormal ease-in;
border-radius: 0;
&--fullWidth {
@@ -106,21 +130,24 @@
height: $euiFormControlHeight--compressed;
}
- &:invalid { /* 1 */
- @include euiFormControlInvalidStyle;
- }
+ @if ($includeStates) {
+ &:invalid { /* 1 */
+ @include euiFormControlInvalidStyle;
+ }
- &:focus { /* 1 */
- @include euiFormControlFocusStyle;
- }
+ &:focus { /* 1 */
+ @include euiFormControlFocusStyle($borderOnly);
+ }
- &:disabled {
- @include euiFormControlDisabledStyle;
- }
+ &:disabled {
+ @include euiFormControlDisabledStyle;
+ }
- &[readOnly] {
- @include euiFormControlReadOnlyStyle;
+ &[readOnly] {
+ @include euiFormControlReadOnlyStyle;
+ }
}
+
}
//
diff --git a/src/components/form/_variables.scss b/src/components/form/_variables.scss
index 8702a7a987f..ca5e4a012d6 100644
--- a/src/components/form/_variables.scss
+++ b/src/components/form/_variables.scss
@@ -1,21 +1,22 @@
-$euiFormMaxWidth: 400px;
-$euiFormBackgroundColor: tintOrShade($euiColorLightestShade, 60%, 25%);
-$euiFormBorderColor: transparentize($euiColorFullShade, .9);
-$euiFormBorderColor--disabled: transparentize($euiColorFullShade, .92);
-$euiFormCustomControlDisabledIconColor: shadeOrTint($euiColorMediumShade, 38%, 48.5%); // exact 508c foreground for $euiColorLightShade
+$euiFormMaxWidth: 400px !default;
+$euiFormBackgroundColor: tintOrShade($euiColorLightestShade, 60%, 25%) !default;
+$euiFormBackgroundColor--disabled: darken($euiColorLightestShade, 2%) !default;
+$euiFormBorderColor: transparentize($euiColorFullShade, .9) !default;
+$euiFormBorderColor--disabled: transparentize($euiColorFullShade, .92) !default;
+$euiFormCustomControlDisabledIconColor: shadeOrTint($euiColorMediumShade, 38%, 48.5%) !default; // exact 508c foreground for $euiColorLightShade
-$euiRadioSize: $euiSize;
-$euiCheckBoxSize: $euiSize;
+$euiRadioSize: $euiSize !default;
+$euiCheckBoxSize: $euiSize !default;
-$euiSwitchHeight: $euiSize * 1.25;
-$euiSwitchWidth: ($euiSize * 2.5) + $euiSizeXS;
-$euiSwitchThumbSize: $euiSwitchHeight;
-$euiSwitchIconHeight: $euiSize;
+$euiSwitchHeight: $euiSize * 1.25 !default;
+$euiSwitchWidth: ($euiSize * 2.5) + $euiSizeXS !default;
+$euiSwitchThumbSize: $euiSwitchHeight !default;
+$euiSwitchIconHeight: $euiSize !default;
-$euiFormControlHeight: $euiSizeXXL;
-$euiFormControlHeight--compressed: $euiSizeXL;
+$euiFormControlHeight: $euiSizeXXL !default;
+$euiFormControlHeight--compressed: $euiSizeXL !default;
-$euiFormControlPadding: $euiSizeM;
-$euiFormControlPadding--compressed: $euiSizeS;
+$euiFormControlPadding: $euiSizeM !default;
+$euiFormControlPadding--compressed: $euiSizeS !default;
-$euiFormControlDisabledColor: $euiColorMediumShade;
+$euiFormControlDisabledColor: $euiColorMediumShade !default;
diff --git a/src/components/form/file_picker/_file_picker.scss b/src/components/form/file_picker/_file_picker.scss
index ebdb69e8a7c..4823fd6f7dc 100644
--- a/src/components/form/file_picker/_file_picker.scss
+++ b/src/components/form/file_picker/_file_picker.scss
@@ -63,14 +63,8 @@
position: relative; /* 2 */
z-index: 1; /* 2 */
display: block;
- background: $euiColorLightestShade;
padding: $euiSizeL;
- background: $euiFormBackgroundColor;
text-align: center;
- transition:
- box-shadow $euiAnimSpeedNormal ease-in,
- background $euiAnimSpeedNormal ease-in,
- color $euiAnimSpeedNormal ease-in;
@at-root {
.euiFilePicker--compressed#{&} {
From abc855f768ebd4e3628a6d5a791847ed640d4b88 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Thu, 28 Jun 2018 10:56:41 -0400
Subject: [PATCH 06/21] form control layout children
---
.../form_controls/form_control_layout.js | 32 +++++++++++
.../_form_control_layout.scss | 43 ++++++++++++++
.../_form_control_layout_children.scss | 3 +
.../_form_control_layout_clear_button.scss | 7 +++
.../form/form_control_layout/_index.scss | 1 +
.../form_control_layout.js | 19 ++++++-
.../form_control_layout_children.js | 56 +++++++++++++++++++
7 files changed, 160 insertions(+), 1 deletion(-)
create mode 100644 src/components/form/form_control_layout/_form_control_layout_children.scss
create mode 100644 src/components/form/form_control_layout/form_control_layout_children.js
diff --git a/src-docs/src/views/form_controls/form_control_layout.js b/src-docs/src/views/form_controls/form_control_layout.js
index d63f24ae602..5757564d975 100644
--- a/src-docs/src/views/form_controls/form_control_layout.js
+++ b/src-docs/src/views/form_controls/form_control_layout.js
@@ -5,6 +5,9 @@ import React, {
import {
EuiFormControlLayout,
EuiSpacer,
+ EuiFormLabel,
+ EuiButtonEmpty,
+ EuiText,
} from '../../../../src/components';
export default () => (
@@ -106,5 +109,34 @@ export default () => (
>
+
+
+
+ Label}
+ >
+
+
+
+
+
+ % ,
+ side: 'right'
+ }}
+ >
+
+
+
+
+
+ {} }}
+ inlineLabel={Button }
+ >
+
+
);
diff --git a/src/components/form/form_control_layout/_form_control_layout.scss b/src/components/form/form_control_layout/_form_control_layout.scss
index 76d745fee8d..9eaab84190b 100644
--- a/src/components/form/form_control_layout/_form_control_layout.scss
+++ b/src/components/form/form_control_layout/_form_control_layout.scss
@@ -12,3 +12,46 @@
width: 100%;
max-width: 100%;
}
+
+// If it contains any inline labels,
+// make the whole layout have the form control style
+
+.euiFormControlLayout--hasLabel {
+ // Match just the regular box-shadow of inputs
+ @include euiFormControlStyle();
+ display: flex;
+ padding: 1px; /* 1 */
+
+ .euiFormControlLayout__child--noStyle {
+ flex-grow: 1;
+ height: $euiFormControlHeight - 2px; /* 1 */
+ box-shadow: none !important;
+ }
+
+ .euiFormControlLayout__inlineLabel {
+ flex-shrink: 0;
+ height: $euiFormControlHeight - 2px; /* 1 */
+ line-height: $euiFontSize;
+ border-right: 1px solid $euiFormBorderColor;
+
+ &:disabled {
+ background-color: $euiFormBackgroundColor--disabled;
+ color: $euiFormControlDisabledColor; // ensures established contrast
+ }
+
+ // This is the only way to target specific components to override styling
+ &.euiFormLabel,
+ &.euiText {
+ white-space: nowrap;
+ margin-bottom: 0;
+ padding: $euiFormControlPadding;
+ border: none;
+ background-color: $euiFormBackgroundColor--disabled;
+ line-height: $euiFontSize;
+ }
+
+ &.euiText {
+ line-height: 1em;
+ }
+ }
+}
diff --git a/src/components/form/form_control_layout/_form_control_layout_children.scss b/src/components/form/form_control_layout/_form_control_layout_children.scss
new file mode 100644
index 00000000000..50b36e8eb30
--- /dev/null
+++ b/src/components/form/form_control_layout/_form_control_layout_children.scss
@@ -0,0 +1,3 @@
+.euiFormControlLayoutChildren {
+
+}
diff --git a/src/components/form/form_control_layout/_form_control_layout_clear_button.scss b/src/components/form/form_control_layout/_form_control_layout_clear_button.scss
index 0dc57d56668..a0830685fea 100644
--- a/src/components/form/form_control_layout/_form_control_layout_clear_button.scss
+++ b/src/components/form/form_control_layout/_form_control_layout_clear_button.scss
@@ -1,3 +1,10 @@
.euiFormControlLayoutClearButton {
@include euiFormControlLayoutClearIcon('.euiFormControlLayoutClearButton__icon');
}
+
+// The 1px padding throws off the times icon
+.euiFormControlLayout--hasLabel {
+ .euiFormControlLayoutClearButton .euiFormControlLayoutClearButton__icon {
+ top: -1px;
+ }
+}
diff --git a/src/components/form/form_control_layout/_index.scss b/src/components/form/form_control_layout/_index.scss
index f5a9b5d33bc..83dac974b3d 100644
--- a/src/components/form/form_control_layout/_index.scss
+++ b/src/components/form/form_control_layout/_index.scss
@@ -3,3 +3,4 @@
@import 'form_control_layout_icons';
@import 'form_control_layout_clear_button';
@import 'form_control_layout_custom_icon';
+@import 'form_control_layout_children';
diff --git a/src/components/form/form_control_layout/form_control_layout.js b/src/components/form/form_control_layout/form_control_layout.js
index eff135c3235..029f6b95c08 100644
--- a/src/components/form/form_control_layout/form_control_layout.js
+++ b/src/components/form/form_control_layout/form_control_layout.js
@@ -3,8 +3,10 @@ import PropTypes from 'prop-types';
import classNames from 'classnames';
import { EuiFormControlLayoutIcons } from './form_control_layout_icons';
+import { EuiFormControlLayoutChildren } from './form_control_layout_children';
export const ICON_SIDES = ['left', 'right'];
+export const LABEL_SIDES = ['left', 'right'];
export const EuiFormControlLayout = ({
children,
@@ -14,6 +16,7 @@ export const EuiFormControlLayout = ({
isLoading,
compressed,
className,
+ inlineLabel,
...rest
}) => {
const classes = classNames(
@@ -21,13 +24,17 @@ export const EuiFormControlLayout = ({
{
'euiFormControlLayout--fullWidth': fullWidth,
'euiFormControlLayout--compressed': compressed,
+ 'euiFormControlLayout--hasLabel': inlineLabel,
},
className
);
return (
- {children}
+
{
+
+ const labelSide = inlineLabel && inlineLabel.side ? inlineLabel.side : 'left';
+
+ let leftLabel;
+ let rightLabel;
+ let clonedChildren;
+
+ if (inlineLabel) {
+ const labelNode = inlineLabel.node ? inlineLabel.node : inlineLabel;
+ const labelClone = cloneElement(labelNode, {
+ className: 'euiFormControlLayout__inlineLabel'
+ });
+
+ if (labelSide === 'left') {
+ leftLabel = labelClone;
+ }
+ else if (labelSide === 'right') {
+ rightLabel = labelClone;
+ }
+
+ clonedChildren = cloneElement(children, {
+ className: `${children.props.className} euiFormControlLayout__child--noStyle`,
+ });
+ }
+
+
+ return (
+
+ {leftLabel}
+ {clonedChildren || children}
+ {rightLabel}
+
+ );
+};
+
+EuiFormControlLayoutChildren.propTypes = {
+ inlineLabel: PropTypes.oneOfType([
+ PropTypes.node,
+ PropTypes.shape({
+ label: PropTypes.node,
+ side: PropTypes.oneOf(LABEL_SIDES),
+ }),
+ ]),
+};
From c2e8a73e8c780818840b57b4e9de37a71b42ae13 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Thu, 28 Jun 2018 12:00:54 -0400
Subject: [PATCH 07/21] Simplifying form control styles
- Made bottom colored border from linear-gradient
- Allowing parameters to determine if just the borders should render
- Allowing parameters to determine if all state styles should be added
- Fixing variable naming schemes
---
src/components/combo_box/_combo_box.scss | 2 +-
.../filter_group/_filter_button.scss | 88 +++++++--------
src/components/form/_mixins.scss | 106 +++++++++++-------
src/components/form/_variables.scss | 51 ++++++---
.../form/file_picker/_file_picker.scss | 21 ++--
src/components/form/select/_select.scss | 2 +-
6 files changed, 162 insertions(+), 108 deletions(-)
diff --git a/src/components/combo_box/_combo_box.scss b/src/components/combo_box/_combo_box.scss
index 5d63fa934a8..12d59569efb 100644
--- a/src/components/combo_box/_combo_box.scss
+++ b/src/components/combo_box/_combo_box.scss
@@ -8,7 +8,7 @@
* 3. The height on combo can be larger than normal text inputs.
*/
.euiComboBox__inputWrap {
- @include euiFormControlStyle;
+ @include euiFormControlStyle($includeStates: false);
@include euiFormControlWithIcon($isIconOptional: true);
@include euiFormControlSize(auto); /* 3 */
diff --git a/src/components/filter_group/_filter_button.scss b/src/components/filter_group/_filter_button.scss
index c0c73b4733c..983f66e97ea 100644
--- a/src/components/filter_group/_filter_button.scss
+++ b/src/components/filter_group/_filter_button.scss
@@ -1,27 +1,30 @@
+@import '../form/variables';
+@import '../form/mixins';
+@import '../form/form_control_layout/mixins';
+
/**
- * 1. We don't want any of the animations that come inherited from the mixin.
- * These should act like normal links instead.
+ * 1. Only add the border style drop shadow
*/
-.euiFilterButton {
- @include euiButton;
- line-height: 40px;
- border-color: transparent;
- background-color: transparent;
- box-shadow: none;
- transform: none !important; // 1
- animation: none !important; // 1
+.euiFilterButton {
+ flex-grow: 0; // Shrink by default
.euiFilterButton__content {
- @include euiButtonContent;
-
- padding: 0 $euiSizeS;
+ @include euiFormControlStyle($borderOnly: true, $includeStates: false);
+ width: auto;
+ max-width: none;
+ white-space: nowrap;
+ }
+ &:disabled .euiFilterButton__content {
+ @include euiFormControlDisabledStyle;
+ font-style: italic;
}
.euiFilterButton__textShift {
- text-align: center;
display: inline-block;
+ text-align: center;
+ vertical-align: middle;
&::after {
display: block;
@@ -33,35 +36,29 @@
}
}
- &.euiFilterButton--iconRight {
- .euiFilterButton__content {
- @include euiButtonContent($isReverse: true);
- }
+ .euiFilterButton__notification {
+ margin-left: $euiSizeS;
+ vertical-align: text-bottom;
}
- &:disabled {
- color: $euiButtonColorDisabled;
- pointer-events: none;
-
- .euiFilterButton__content {
- pointer-events: auto;
- cursor: not-allowed;
+ &.euiFilterButton-isSelected,
+ &:hover:not(:disabled),
+ &:focus:not(:disabled) {
+ .euiFilterButton__textShift {
+ text-decoration: underline;
}
+ }
- .euiFilterButton__icon {
- fill: $euiButtonColorDisabled;
- }
+ &.euiFilterButton-grow {
+ flex-grow: 1;
+ width: 100%;
- &:hover, &:focus {
- background-color: $euiColorEmptyShade;
- text-decoration: none;
+ .euiFilterButton__content {
+ width: 100%;
+ text-align: left;
}
}
- &.euiFilterButton-isSelected {
- text-decoration: underline;
- }
-
&.euiFilterButton-hasActiveFilters {
font-weight: $euiFontWeightBold;
}
@@ -80,17 +77,18 @@ $buttonTypes: (
@each $name, $color in $buttonTypes {
.euiFilterButton--#{$name} {
color: $color;
+ }
+}
- .euiFilterButton__icon {
- fill: $color;
- }
-
- &:hover {
- background-color: transparent;
+// Icon padding
+.euiFilterButton--iconLeft {
+ .euiFilterButton__content {
+ @include euiFormControlLayout__padding(1, "left");
+ }
+}
- @if ($name == 'disabled') {
- cursor: not-allowed;
- }
- }
+.euiFilterButton--iconRight {
+ .euiFilterButton__content {
+ @include euiFormControlLayout__padding(1);
}
}
diff --git a/src/components/form/_mixins.scss b/src/components/form/_mixins.scss
index 4d76dc6bc89..bb06bb87483 100644
--- a/src/components/form/_mixins.scss
+++ b/src/components/form/_mixins.scss
@@ -1,3 +1,13 @@
+
+@function euiFormControlGradient($color: $euiColorPrimary) {
+ @return linear-gradient(to top,
+ $color,
+ $color ($euiSizeXS / 2),
+ transparent ($euiSizeXS / 2),
+ transparent 100%
+ );
+}
+
/*
* 1. Ensure the icon padding remains when in readOnly mode
*/
@@ -36,35 +46,52 @@
}
}
-@mixin euiFormControlDefaultShadow {
- box-shadow:
- 0 3px 2px -2px rgba($euiShadowColor, 0.2),
- inset 0 0 0 1px transparentize($euiColorFullShade, .9),
- inset #{-$euiFormMaxWidth} 0 0 0 $euiFormBackgroundColor;
+@mixin euiFormControlDefaultShadow($borderOnly: false) {
+ background-color: $euiFormBackgroundColor;
+ background-repeat: no-repeat;
+ background-size: 0%;
+
+ @if ($borderOnly) {
+ box-shadow: inset 0 0 0 1px $euiFormBorderColor;
+ } @else {
+ box-shadow:
+ 0 1px 1px -1px rgba($euiShadowColor, 0.2),
+ 0 3px 2px -2px rgba($euiShadowColor, 0.2),
+ inset 0 0 0 1px $euiFormBorderColor;
+ }
+
+ transition:
+ box-shadow $euiAnimSpeedFast ease-in,
+ background-color $euiAnimSpeedFast ease-in,
+ background-image $euiAnimSpeedFast ease-in,
+ background-size $euiAnimSpeedFast ease-in;
}
-@mixin euiFormControlInvalidStyle {
- box-shadow:
- 0 $euiSizeXS $euiSizeXS (-$euiSizeXS / 2) rgba($euiShadowColor, 0.2),
- inset 0 0 0 1px transparentize($euiColorFullShade, .84),
- inset 0 0 0 0 $euiColorEmptyShade,
- inset 0 (-$euiSizeXS / 2) 0 0 $euiColorDanger;
+@mixin euiFormControlFocusStyle($borderOnly: false) {
+ background-color: tintOrShade($euiColorEmptyShade, 0%, 50%);
+ background-image: euiFormControlGradient();
+ background-size: 100%;
+
+ @if ($borderOnly) {
+ box-shadow: inset 0 0 0 1px transparentize($euiColorFullShade, .84);
+ } @else {
+ box-shadow:
+ 0 1px 1px -1px rgba($euiShadowColor, 0.2),
+ 0 4px 4px -2px rgba($euiShadowColor, 0.2),
+ inset 0 0 0 1px transparentize($euiColorFullShade, .84);
+ }
}
-@mixin euiFormControlFocusStyle {
- background: tintOrShade($euiColorEmptyShade, 0%, 20%);
- box-shadow:
- 0 4px 4px -2px rgba($euiShadowColor, 0.2),
- inset 0 0 0 1px transparentize($euiColorFullShade, .84),
- inset 0 0 0 0 tintOrShade($euiColorEmptyShade, 0%, 20%),
- inset 0 -2px 0 0 $euiColorPrimary;
+@mixin euiFormControlInvalidStyle() {
+ background-image: euiFormControlGradient($euiColorDanger);
+ background-size: 100%;
}
-@mixin euiFormControlDisabledStyle {
+@mixin euiFormControlDisabledStyle() {
cursor: not-allowed;
- background: darken($euiColorLightestShade, 2%);
- box-shadow: inset 0 0 0 1px transparentize($euiColorFullShade, .92);
color: $euiFormControlDisabledColor;
+ background: $euiFormBackgroundDisabledColor;
+ box-shadow: inset 0 0 0 1px $euiFormBorderDisabledColor;
&::placeholder {
color: $euiFormControlDisabledColor;
@@ -82,9 +109,9 @@
/**
* 1. Override invalid state with focus state.
*/
-@mixin euiFormControlStyle {
+@mixin euiFormControlStyle($borderOnly: false, $includeStates: true) {
@include euiFormControlSize;
- @include euiFormControlDefaultShadow;
+ @include euiFormControlDefaultShadow($borderOnly);
border: none;
font-size: $euiFontSizeS;
@@ -92,8 +119,6 @@
padding: $euiFormControlPadding;
line-height: 1em; // fixes text alignment in IE
color: $euiTextColor;
- background: $euiFormBackgroundColor;
- transition: box-shadow $euiAnimSpeedNormal ease-in, background $euiAnimSpeedNormal ease-in;
border-radius: 0;
&--fullWidth {
@@ -101,26 +126,29 @@
}
&--compressed {
- padding-top: $euiFormControlPadding--compressed;
- padding-bottom: $euiFormControlPadding--compressed;
- height: $euiFormControlHeight--compressed;
+ padding-top: $euiFormControlCompressedPadding;
+ padding-bottom: $euiFormControlCompressedPadding;
+ height: $euiFormControlCompressedHeight;
}
- &:invalid { /* 1 */
- @include euiFormControlInvalidStyle;
- }
+ @if ($includeStates) {
+ &:invalid { /* 1 */
+ @include euiFormControlInvalidStyle;
+ }
- &:focus { /* 1 */
- @include euiFormControlFocusStyle;
- }
+ &:focus { /* 1 */
+ @include euiFormControlFocusStyle($borderOnly);
+ }
- &:disabled {
- @include euiFormControlDisabledStyle;
- }
+ &:disabled {
+ @include euiFormControlDisabledStyle;
+ }
- &[readOnly] {
- @include euiFormControlReadOnlyStyle;
+ &[readOnly] {
+ @include euiFormControlReadOnlyStyle;
+ }
}
+
}
//
diff --git a/src/components/form/_variables.scss b/src/components/form/_variables.scss
index 86c5fbf6714..a29168ffb07 100644
--- a/src/components/form/_variables.scss
+++ b/src/components/form/_variables.scss
@@ -1,19 +1,42 @@
-$euiFormMaxWidth: 400px;
-$euiFormBackgroundColor: tintOrShade($euiColorLightestShade, 60%, 25%);
-$euiFormCustomControlDisabledIconColor: shadeOrTint($euiColorMediumShade, 38%, 48.5%); // exact 508c foreground for $euiColorLightShade
+// Sizing
+$euiFormMaxWidth: $euiSizeXXL * 10 !default;
+$euiFormControlHeight: $euiSizeXXL !default;
+$euiFormControlCompressedHeight: $euiSizeXL !default;
+$euiFormControlPadding: $euiSizeM !default;
+$euiFormControlCompressedPadding: $euiSizeS !default;
-$euiRadioSize: $euiSize;
-$euiCheckBoxSize: $euiSize;
+$euiRadioSize: $euiSize !default;
+$euiCheckBoxSize: $euiSize !default;
-$euiSwitchHeight: $euiSize * 1.25;
-$euiSwitchWidth: ($euiSize * 2.5) + $euiSizeXS;
-$euiSwitchThumbSize: $euiSwitchHeight;
-$euiSwitchIconHeight: $euiSize;
+$euiSwitchHeight: $euiSize * 1.25 !default;
+$euiSwitchWidth: ($euiSize * 2.5) + $euiSizeXS !default;
+$euiSwitchThumbSize: $euiSwitchHeight !default;
+$euiSwitchIconHeight: $euiSize !default;
-$euiFormControlHeight: $euiSizeXXL;
-$euiFormControlHeight--compressed: $euiSizeXL;
+// Coloring
+$euiFormBackgroundColor: tintOrShade($euiColorLightestShade, 60%, 25%) !default;
+$euiFormBackgroundDisabledColor: darken($euiColorLightestShade, 2%) !default;
+$euiFormBorderColor: transparentize($euiColorFullShade, .9) !default;
+$euiFormBorderDisabledColor: transparentize($euiColorFullShade, .92) !default;
+$euiFormCustomControlDisabledIconColor: shadeOrTint($euiColorMediumShade, 38%, 48.5%) !default; // exact 508c foreground for $euiColorLightShade
+$euiFormControlDisabledColor: $euiColorMediumShade !default;
-$euiFormControlPadding: $euiSizeM;
-$euiFormControlPadding--compressed: $euiSizeS;
+//** DEPRECATED **//
+//** DEPRECATED **//
+//** DEPRECATED **//
+//** DEPRECATED **//
-$euiFormControlDisabledColor: $euiColorMediumShade;
+@if variable-exists(euiFormControlHeight--compressed) {
+ $euiFormControlCompressedHeight: $euiFormControlHeight--compressed !global;
+ @warn '`$euiFormControlHeight--compressed` is deprecated. Please use `$euiFormControlCompressedHeight` instead';
+}
+
+@if variable-exists(euiFormControlPadding--compressed) {
+ $euiFormControlCompressedPadding: $euiFormControlPadding--compressed !global;
+ @warn '`$euiFormControlPadding--compressed` is deprecated. Please use `$euiFormControlCompressedPadding` instead';
+}
+
+@if variable-exists(euiFormBorderColor--disabled) {
+ $euiFormBorderDisabledColor: $euiFormBorderColor--disabled !global;
+ @warn '`$euiFormBorderColor--disabled` is deprecated. Please use `$euiFormBorderDisabledColor` instead';
+}
diff --git a/src/components/form/file_picker/_file_picker.scss b/src/components/form/file_picker/_file_picker.scss
index ebdb69e8a7c..ec356c1c029 100644
--- a/src/components/form/file_picker/_file_picker.scss
+++ b/src/components/form/file_picker/_file_picker.scss
@@ -55,6 +55,7 @@
* 1. Don't block the user from dropping files onto the filepicker.
* 2. Put prompt on top of input, so the clear button can intercept the click.
* 3. Ensure space for import icon and clear button (only if it has files)
+ * 4. Delay focus gradient or else it will only partially transition while file chooser opens
*/
.euiFilePicker__prompt {
@include euiFormControlDefaultShadow;
@@ -63,19 +64,19 @@
position: relative; /* 2 */
z-index: 1; /* 2 */
display: block;
- background: $euiColorLightestShade;
padding: $euiSizeL;
- background: $euiFormBackgroundColor;
text-align: center;
+
transition:
- box-shadow $euiAnimSpeedNormal ease-in,
- background $euiAnimSpeedNormal ease-in,
- color $euiAnimSpeedNormal ease-in;
+ box-shadow $euiAnimSpeedFast ease-in,
+ background-color $euiAnimSpeedFast ease-in,
+ background-image $euiAnimSpeedFast ease-in,
+ background-size $euiAnimSpeedFast ease-in $euiAnimSpeedFast; /* 4 */
@at-root {
.euiFilePicker--compressed#{&} {
- height: $euiFormControlHeight--compressed;
- padding: $euiFormControlPadding--compressed;
+ height: $euiFormControlCompressedHeight;
+ padding: $euiFormControlCompressedPadding;
@include euiFormControlWithIcon(); /* 3 */
text-align: left;
}
@@ -117,7 +118,11 @@
// Hover and focus
.euiFilePicker__input:hover:not(:disabled) + .euiFilePicker__prompt,
.euiFilePicker__input:focus + .euiFilePicker__prompt {
- text-decoration: underline;
+ .euiFilePicker__promptText {
+ // Adding the underline to the prompt text ensures the underline
+ // color is the same as the current text color
+ text-decoration: underline;
+ }
.euiFilePicker__icon {
transform: scale(1.1);
diff --git a/src/components/form/select/_select.scss b/src/components/form/select/_select.scss
index 7f8c68b47c1..7ae8163c689 100644
--- a/src/components/form/select/_select.scss
+++ b/src/components/form/select/_select.scss
@@ -14,7 +14,7 @@
padding-bottom: 0; /* 2 */
&--compressed {
- line-height: $euiFormControlHeight--compressed; /* 2 */
+ line-height: $euiFormControlCompressedHeight; /* 2 */
padding-top: 0; /* 2 */
padding-bottom: 0; /* 2 */
}
From 66647f03c0456042547158270f153617d4b60717 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Thu, 28 Jun 2018 12:07:54 -0400
Subject: [PATCH 08/21] Revert commit of filter_button.scss
---
.../filter_group/_filter_button.scss | 88 ++++++++++---------
1 file changed, 45 insertions(+), 43 deletions(-)
diff --git a/src/components/filter_group/_filter_button.scss b/src/components/filter_group/_filter_button.scss
index 983f66e97ea..c0c73b4733c 100644
--- a/src/components/filter_group/_filter_button.scss
+++ b/src/components/filter_group/_filter_button.scss
@@ -1,30 +1,27 @@
-@import '../form/variables';
-@import '../form/mixins';
-@import '../form/form_control_layout/mixins';
-
/**
- * 1. Only add the border style drop shadow
+ * 1. We don't want any of the animations that come inherited from the mixin.
+ * These should act like normal links instead.
*/
-
.euiFilterButton {
- flex-grow: 0; // Shrink by default
+ @include euiButton;
+
+ line-height: 40px;
+ border-color: transparent;
+ background-color: transparent;
+ box-shadow: none;
+ transform: none !important; // 1
+ animation: none !important; // 1
.euiFilterButton__content {
- @include euiFormControlStyle($borderOnly: true, $includeStates: false);
- width: auto;
- max-width: none;
- white-space: nowrap;
- }
+ @include euiButtonContent;
+
+ padding: 0 $euiSizeS;
- &:disabled .euiFilterButton__content {
- @include euiFormControlDisabledStyle;
- font-style: italic;
}
.euiFilterButton__textShift {
- display: inline-block;
text-align: center;
- vertical-align: middle;
+ display: inline-block;
&::after {
display: block;
@@ -36,27 +33,33 @@
}
}
- .euiFilterButton__notification {
- margin-left: $euiSizeS;
- vertical-align: text-bottom;
- }
-
- &.euiFilterButton-isSelected,
- &:hover:not(:disabled),
- &:focus:not(:disabled) {
- .euiFilterButton__textShift {
- text-decoration: underline;
+ &.euiFilterButton--iconRight {
+ .euiFilterButton__content {
+ @include euiButtonContent($isReverse: true);
}
}
- &.euiFilterButton-grow {
- flex-grow: 1;
- width: 100%;
+ &:disabled {
+ color: $euiButtonColorDisabled;
+ pointer-events: none;
.euiFilterButton__content {
- width: 100%;
- text-align: left;
+ pointer-events: auto;
+ cursor: not-allowed;
}
+
+ .euiFilterButton__icon {
+ fill: $euiButtonColorDisabled;
+ }
+
+ &:hover, &:focus {
+ background-color: $euiColorEmptyShade;
+ text-decoration: none;
+ }
+ }
+
+ &.euiFilterButton-isSelected {
+ text-decoration: underline;
}
&.euiFilterButton-hasActiveFilters {
@@ -77,18 +80,17 @@ $buttonTypes: (
@each $name, $color in $buttonTypes {
.euiFilterButton--#{$name} {
color: $color;
- }
-}
-// Icon padding
-.euiFilterButton--iconLeft {
- .euiFilterButton__content {
- @include euiFormControlLayout__padding(1, "left");
- }
-}
+ .euiFilterButton__icon {
+ fill: $color;
+ }
-.euiFilterButton--iconRight {
- .euiFilterButton__content {
- @include euiFormControlLayout__padding(1);
+ &:hover {
+ background-color: transparent;
+
+ @if ($name == 'disabled') {
+ cursor: not-allowed;
+ }
+ }
}
}
From 2eea143786d36dab6778f1638f7cfd5d270551e5 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Thu, 28 Jun 2018 12:56:56 -0400
Subject: [PATCH 09/21] Get rid of terrible IE highlight when select is focused
---
src/components/form/_mixins.scss | 15 +++++++--------
src/components/form/select/_select.scss | 5 +++++
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/components/form/_mixins.scss b/src/components/form/_mixins.scss
index bb06bb87483..cde9ea7e398 100644
--- a/src/components/form/_mixins.scss
+++ b/src/components/form/_mixins.scss
@@ -2,13 +2,13 @@
@function euiFormControlGradient($color: $euiColorPrimary) {
@return linear-gradient(to top,
$color,
- $color ($euiSizeXS / 2),
- transparent ($euiSizeXS / 2),
+ $color 2px,
+ transparent 2px,
transparent 100%
);
}
-/*
+/**
* 1. Ensure the icon padding remains when in readOnly mode
*/
@@ -107,8 +107,9 @@
}
/**
- * 1. Override invalid state with focus state.
+ * 2. Override invalid state with focus state.
*/
+
@mixin euiFormControlStyle($borderOnly: false, $includeStates: true) {
@include euiFormControlSize;
@include euiFormControlDefaultShadow($borderOnly);
@@ -132,11 +133,11 @@
}
@if ($includeStates) {
- &:invalid { /* 1 */
+ &:invalid { /* 2 */
@include euiFormControlInvalidStyle;
}
- &:focus { /* 1 */
+ &:focus { /* 2 */
@include euiFormControlFocusStyle($borderOnly);
}
@@ -151,9 +152,7 @@
}
-//
// Custom styles and states for checkboxes and radios
-//
@mixin euiCustomControl($type: null, $size: $euiSize){
diff --git a/src/components/form/select/_select.scss b/src/components/form/select/_select.scss
index 7ae8163c689..6b3933fa782 100644
--- a/src/components/form/select/_select.scss
+++ b/src/components/form/select/_select.scss
@@ -22,4 +22,9 @@
&::-ms-expand {
display: none;
}
+
+ &:focus::-ms-value {
+ color: $euiTextColor;
+ background: transparent;
+ }
}
From d48cd3e59c6153e9ce7d1b496c727473d1bc5c9e Mon Sep 17 00:00:00 2001
From: cchaos
Date: Thu, 28 Jun 2018 14:04:31 -0400
Subject: [PATCH 10/21] Squashed commit of the following:
commit 2eea143786d36dab6778f1638f7cfd5d270551e5
Author: cchaos
Date: Thu Jun 28 12:56:56 2018 -0400
Get rid of terrible IE highlight when select is focused
commit 66647f03c0456042547158270f153617d4b60717
Author: cchaos
Date: Thu Jun 28 12:07:54 2018 -0400
Revert commit of filter_button.scss
commit c2e8a73e8c780818840b57b4e9de37a71b42ae13
Author: cchaos
Date: Thu Jun 28 12:00:54 2018 -0400
Simplifying form control styles
- Made bottom colored border from linear-gradient
- Allowing parameters to determine if just the borders should render
- Allowing parameters to determine if all state styles should be added
- Fixing variable naming schemes
commit c5f0ab54bf22b819732438195466a60e0d2ef206
Author: Stacey Gammon
Date: Thu Jun 28 10:02:16 2018 -0400
add inspect to typedef file (#952)
* add inpsect to typedef file
* use the right pr number
commit c64f0551cf0fd67b26fa27e3fa95722e9ed844fa
Author: Nathan Reese
Date: Wed Jun 27 08:52:41 2018 -0600
add MutationObserver to accordion to trigger setChildContentHeight when children change (#947)
* add MutationObserver to accordion to trigger setChildContentHeight when children change
* remove requestAnimationFrame around MutationObserver registration and add comment to change log
* set up observer in ref creation function
* mock MutationObserver
---
.../src/views/accordion/accordion_grow.js | 55 +++++++++++--------
src/components/accordion/accordion.js | 16 +++++-
src/components/accordion/accordion.test.js | 12 ++++
src/components/form/_mixins.scss | 30 +++++-----
src/components/form/_variables.scss | 42 ++++++++++----
.../form/file_picker/_file_picker.scss | 17 +++++-
.../_form_control_layout.scss | 4 +-
src/components/form/select/_select.scss | 7 ++-
src/components/icon/index.d.ts | 1 +
9 files changed, 128 insertions(+), 56 deletions(-)
diff --git a/src-docs/src/views/accordion/accordion_grow.js b/src-docs/src/views/accordion/accordion_grow.js
index 89923766a88..a8933dd8bc2 100644
--- a/src-docs/src/views/accordion/accordion_grow.js
+++ b/src-docs/src/views/accordion/accordion_grow.js
@@ -1,3 +1,6 @@
+/* eslint react/no-multi-comp: 0 */
+/* eslint react/prefer-stateless-function: 0 */
+
import React, { Component } from 'react';
import {
@@ -7,18 +10,44 @@ import {
EuiText,
} from '../../../../src/components';
-
-class AccordionGrow extends Component {
+class Rows extends Component {
state = {
counter: 1
}
+ onIncrease() {
+ this.setState(prevState => ({
+ counter: prevState.counter + 1
+ }));
+ }
+
+ onDecrease() {
+ this.setState(prevState => ({
+ counter: Math.max(0, prevState.counter - 1)
+ }));
+ }
+
render() {
const rows = [];
for (let i = 1; i <= this.state.counter; i++) {
rows.push(Row {i}
);
}
+ return (
+
+
+
+ this.onIncrease()}>Increase height
+ {' '}
+ this.onDecrease()}>Decrease height
+
+ { rows }
+
+ );
+ }
+}
+class AccordionGrow extends Component {
+ render() {
return (
-
-
-
- this.onIncrease()}>Increase height
- {' '}
- this.onDecrease()}>Decrease height
-
- { rows }
-
+
);
}
-
- onIncrease() {
- this.setState(prevState => ({
- counter: prevState.counter + 1
- }));
- }
-
- onDecrease() {
- this.setState(prevState => ({
- counter: Math.max(0, prevState.counter - 1)
- }));
- }
}
export default AccordionGrow;
diff --git a/src/components/accordion/accordion.js b/src/components/accordion/accordion.js
index d470b3748cb..9152027493a 100644
--- a/src/components/accordion/accordion.js
+++ b/src/components/accordion/accordion.js
@@ -56,6 +56,20 @@ export class EuiAccordion extends Component {
}));
}
+ setChildContentRef = (node) => {
+ this.childContent = node;
+
+ if (this.observer) {
+ this.observer.disconnect();
+ this.observer = null;
+ }
+
+ if (node) {
+ this.observer = new MutationObserver(this.setChildContentHeight);
+ this.observer.observe(this.childContent, { childList: true, subtree: true });
+ }
+ }
+
render() {
const {
children,
@@ -140,7 +154,7 @@ export class EuiAccordion extends Component {
ref={node => { this.childWrapper = node; }}
id={id}
>
- { this.childContent = node; }}>
+
{children}
diff --git a/src/components/accordion/accordion.test.js b/src/components/accordion/accordion.test.js
index 2832314e9ba..3d4aa26e2b2 100644
--- a/src/components/accordion/accordion.test.js
+++ b/src/components/accordion/accordion.test.js
@@ -81,6 +81,18 @@ describe('EuiAccordion', () => {
});
describe('behavior', () => {
+ beforeAll(() => {
+ global.MutationObserver = class {
+ constructor() {}
+ disconnect() {}
+ observe() {}
+ };
+ });
+
+ afterAll(() => {
+ delete global.MutationObserver;
+ });
+
it('opens when clicked once', () => {
const component = mount(
Date: Thu, 28 Jun 2018 16:24:49 -0400
Subject: [PATCH 11/21] Updating to use prepend/append props
Had to move this logic back into the layout comp because the icons needed to be wrapped with children
---
.../form_controls/form_control_layout.js | 15 +-
.../__snapshots__/combo_box.test.js.snap | 84 ++---
src/components/combo_box/_combo_box.scss | 2 +-
.../__snapshots__/filter_button.test.js.snap | 10 +-
src/components/form/_mixins.scss | 38 +-
.../form_control_layout.test.js.snap | 338 ++++++++++++------
.../_form_control_layout.scss | 62 +++-
.../_form_control_layout_clear_button.scss | 7 -
.../form_control_layout.js | 164 ++++++---
.../form_control_layout.test.js | 46 +++
.../form_control_layout_children.js | 56 ---
11 files changed, 511 insertions(+), 311 deletions(-)
delete mode 100644 src/components/form/form_control_layout/form_control_layout_children.js
diff --git a/src-docs/src/views/form_controls/form_control_layout.js b/src-docs/src/views/form_controls/form_control_layout.js
index 5757564d975..724d70dea9c 100644
--- a/src-docs/src/views/form_controls/form_control_layout.js
+++ b/src-docs/src/views/form_controls/form_control_layout.js
@@ -113,20 +113,17 @@ export default () => (
Label}
+ prepend={Label }
>
-
+
% ,
- side: 'right'
- }}
+ append={% }
>
-
+
@@ -134,9 +131,9 @@ export default () => (
{} }}
- inlineLabel={Button }
+ prepend={Button }
>
-
+
);
diff --git a/src/components/combo_box/__snapshots__/combo_box.test.js.snap b/src/components/combo_box/__snapshots__/combo_box.test.js.snap
index 61d5b2c3973..a2ff123759b 100644
--- a/src/components/combo_box/__snapshots__/combo_box.test.js.snap
+++ b/src/components/combo_box/__snapshots__/combo_box.test.js.snap
@@ -10,54 +10,58 @@ exports[`EuiComboBox is rendered 1`] = `
class="euiFormControlLayout"
>
-
-
diff --git a/src/components/combo_box/_combo_box.scss b/src/components/combo_box/_combo_box.scss
index 12d59569efb..d448f90bbb4 100644
--- a/src/components/combo_box/_combo_box.scss
+++ b/src/components/combo_box/_combo_box.scss
@@ -8,7 +8,7 @@
* 3. The height on combo can be larger than normal text inputs.
*/
.euiComboBox__inputWrap {
- @include euiFormControlStyle($includeStates: false);
+ @include euiFormControlStyle($includeStates: false, $includeSizes:false);
@include euiFormControlWithIcon($isIconOptional: true);
@include euiFormControlSize(auto); /* 3 */
diff --git a/src/components/filter_group/__snapshots__/filter_button.test.js.snap b/src/components/filter_group/__snapshots__/filter_button.test.js.snap
index 634d5d4a558..9efa815d161 100644
--- a/src/components/filter_group/__snapshots__/filter_button.test.js.snap
+++ b/src/components/filter_group/__snapshots__/filter_button.test.js.snap
@@ -10,9 +10,13 @@ exports[`EuiFilterButton is rendered 1`] = `
`;
diff --git a/src/components/form/_mixins.scss b/src/components/form/_mixins.scss
index cde9ea7e398..aa6aaaeb610 100644
--- a/src/components/form/_mixins.scss
+++ b/src/components/form/_mixins.scss
@@ -12,10 +12,24 @@
* 1. Ensure the icon padding remains when in readOnly mode
*/
-@mixin euiFormControlSize($height: $euiFormControlHeight) {
+@mixin euiFormControlSize(
+ $height: $euiFormControlHeight,
+ $includeAlternates: false
+) {
+ // Default
max-width: $euiFormMaxWidth;
width: 100%;
height: $height;
+
+ @if ($includeAlternates) {
+ &--fullWidth {
+ max-width: 100%;
+ }
+
+ &--compressed {
+ height: $euiFormControlCompressedHeight;
+ }
+ }
}
@mixin euiFormControlWithIcon($isIconOptional: false, $side: "left") {
@@ -110,9 +124,9 @@
* 2. Override invalid state with focus state.
*/
-@mixin euiFormControlStyle($borderOnly: false, $includeStates: true) {
- @include euiFormControlSize;
- @include euiFormControlDefaultShadow($borderOnly);
+@mixin euiFormControlStyle($borderOnly: false, $includeStates: true, $includeSizes: true) {
+ @include euiFormControlSize($includeAlternates: $includeSizes);
+ @include euiFormControlDefaultShadow();
border: none;
font-size: $euiFontSizeS;
@@ -122,14 +136,11 @@
color: $euiTextColor;
border-radius: 0;
- &--fullWidth {
- max-width: 100%;
- }
-
- &--compressed {
- padding-top: $euiFormControlCompressedPadding;
- padding-bottom: $euiFormControlCompressedPadding;
- height: $euiFormControlCompressedHeight;
+ @if ($includeSizes) {
+ &--compressed {
+ padding-top: $euiFormControlCompressedPadding;
+ padding-bottom: $euiFormControlCompressedPadding;
+ }
}
@if ($includeStates) {
@@ -138,7 +149,7 @@
}
&:focus { /* 2 */
- @include euiFormControlFocusStyle($borderOnly);
+ @include euiFormControlFocusStyle();
}
&:disabled {
@@ -149,7 +160,6 @@
@include euiFormControlReadOnlyStyle;
}
}
-
}
// Custom styles and states for checkboxes and radios
diff --git a/src/components/form/form_control_layout/__snapshots__/form_control_layout.test.js.snap b/src/components/form/form_control_layout/__snapshots__/form_control_layout.test.js.snap
index 4f106845a78..9de76c91e2b 100644
--- a/src/components/form/form_control_layout/__snapshots__/form_control_layout.test.js.snap
+++ b/src/components/form/form_control_layout/__snapshots__/form_control_layout.test.js.snap
@@ -6,7 +6,11 @@ exports[`EuiFormControlLayout is rendered 1`] = `
class="euiFormControlLayout testClass1 testClass2"
data-test-subj="test subject string"
>
-
+
+
+
`;
@@ -15,34 +19,38 @@ exports[`EuiFormControlLayout props clear onClick is rendered 1`] = `
class="euiFormControlLayout"
>
`;
@@ -50,7 +58,11 @@ exports[`EuiFormControlLayout props clear onClick is rendered 1`] = `
exports[`EuiFormControlLayout props fullWidth is rendered 1`] = `
+>
+
+
`;
exports[`EuiFormControlLayout props icon is rendered as a string 1`] = `
@@ -58,32 +70,36 @@ exports[`EuiFormControlLayout props icon is rendered as a string 1`] = `
class="euiFormControlLayout"
>
`;
@@ -93,33 +109,37 @@ exports[`EuiFormControlLayout props icon is rendered as an object 1`] = `
class="euiFormControlLayout"
>
`;
@@ -129,32 +149,36 @@ exports[`EuiFormControlLayout props icon side left is rendered 1`] = `
class="euiFormControlLayout"
>
`;
@@ -164,32 +188,36 @@ exports[`EuiFormControlLayout props icon side right is rendered 1`] = `
class="euiFormControlLayout"
>
`;
@@ -199,11 +227,85 @@ exports[`EuiFormControlLayout props isLoading is rendered 1`] = `
class="euiFormControlLayout"
>
`;
+
+exports[`EuiFormControlLayout props multiple appends are rendered 1`] = `
+
+`;
+
+exports[`EuiFormControlLayout props multiple prepends are rendered 1`] = `
+
+`;
+
+exports[`EuiFormControlLayout props one append is rendered 1`] = `
+
+`;
+
+exports[`EuiFormControlLayout props one prepend is rendered 1`] = `
+
+`;
diff --git a/src/components/form/form_control_layout/_form_control_layout.scss b/src/components/form/form_control_layout/_form_control_layout.scss
index 22a959acb08..23d81f4a71c 100644
--- a/src/components/form/form_control_layout/_form_control_layout.scss
+++ b/src/components/form/form_control_layout/_form_control_layout.scss
@@ -2,37 +2,38 @@
.euiFormControlLayout {
// Let the height expand as needed
- @include euiFormControlSize(auto);
-
- display: inline-block;
- position: relative;
+ @include euiFormControlSize(auto, $includeAlternates: true);
}
-.euiFormControlLayout--fullWidth {
- width: 100%;
- max-width: 100%;
+.euiFormControlLayout__childrenWrapper {
+ position: relative;
}
-// If it contains any inline labels,
-// make the whole layout have the form control style
+/**
+ * 1. Account for inner box-shadow style border
+ */
-.euiFormControlLayout--hasLabel {
- // Match just the regular box-shadow of inputs
- @include euiFormControlStyle();
+.euiFormControlLayout--group {
+ // Match just the regular drop shadow of inputs
+ @include euiFormControlDefaultShadow();
display: flex;
padding: 1px; /* 1 */
- .euiFormControlLayout__child--noStyle {
+ .euiFormControlLayout__childrenWrapper {
flex-grow: 1;
+ }
+
+ // Change the height and remove drop shadow of the input
+ .euiFormControlLayout__child--noStyle {
height: $euiFormControlHeight - 2px; /* 1 */
box-shadow: none !important;
}
- .euiFormControlLayout__inlineLabel {
+ .euiFormControlLayout__prepend,
+ .euiFormControlLayout__append {
flex-shrink: 0;
height: $euiFormControlHeight - 2px; /* 1 */
line-height: $euiFontSize;
- border-right: 1px solid $euiFormBorderColor;
&:disabled {
background-color: $euiFormBackgroundDisabledColor;
@@ -49,9 +50,36 @@
background-color: $euiFormBackgroundDisabledColor;
line-height: $euiFontSize;
}
+ }
- &.euiText {
- line-height: 1em;
+ //
+ // Borders
+
+ .euiFormControlLayout__prepend {
+ border-right: 1px solid $euiFormBorderColor;
+ }
+
+ .euiFormControlLayout__append {
+ border-left: 1px solid $euiFormBorderColor;
+ }
+
+ //
+ // Compressed alterations
+
+ &.euiFormControlLayout--compressed {
+ .euiFormControlLayout__child--noStyle {
+ height: $euiFormControlCompressedHeight - 2px; /* 1 */
+ }
+
+ .euiFormControlLayout__prepend,
+ .euiFormControlLayout__append {
+ height: $euiFormControlCompressedHeight - 2px; /* 1 */
+
+ &.euiFormLabel,
+ &.euiText {
+ padding-top: $euiFormControlCompressedPadding;
+ padding-bottom: $euiFormControlCompressedPadding;
+ }
}
}
}
diff --git a/src/components/form/form_control_layout/_form_control_layout_clear_button.scss b/src/components/form/form_control_layout/_form_control_layout_clear_button.scss
index a0830685fea..0dc57d56668 100644
--- a/src/components/form/form_control_layout/_form_control_layout_clear_button.scss
+++ b/src/components/form/form_control_layout/_form_control_layout_clear_button.scss
@@ -1,10 +1,3 @@
.euiFormControlLayoutClearButton {
@include euiFormControlLayoutClearIcon('.euiFormControlLayoutClearButton__icon');
}
-
-// The 1px padding throws off the times icon
-.euiFormControlLayout--hasLabel {
- .euiFormControlLayoutClearButton .euiFormControlLayoutClearButton__icon {
- top: -1px;
- }
-}
diff --git a/src/components/form/form_control_layout/form_control_layout.js b/src/components/form/form_control_layout/form_control_layout.js
index 029f6b95c08..8a09f79f8c6 100644
--- a/src/components/form/form_control_layout/form_control_layout.js
+++ b/src/components/form/form_control_layout/form_control_layout.js
@@ -1,49 +1,117 @@
-import React from 'react';
+import React, {
+ cloneElement,
+ Component,
+} from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { EuiFormControlLayoutIcons } from './form_control_layout_icons';
-import { EuiFormControlLayoutChildren } from './form_control_layout_children';
export const ICON_SIDES = ['left', 'right'];
-export const LABEL_SIDES = ['left', 'right'];
-
-export const EuiFormControlLayout = ({
- children,
- icon,
- clear,
- fullWidth,
- isLoading,
- compressed,
- className,
- inlineLabel,
- ...rest
-}) => {
- const classes = classNames(
- 'euiFormControlLayout',
- {
- 'euiFormControlLayout--fullWidth': fullWidth,
- 'euiFormControlLayout--compressed': compressed,
- 'euiFormControlLayout--hasLabel': inlineLabel,
- },
- className
- );
-
- return (
-
-
-
-
-
- );
-};
+
+export class EuiFormControlLayout extends Component {
+ render() {
+ const {
+ children,
+ icon,
+ clear,
+ fullWidth,
+ isLoading,
+ compressed,
+ className,
+ prepend,
+ append,
+ ...rest
+ } = this.props;
+
+ const classes = classNames(
+ 'euiFormControlLayout',
+ {
+ 'euiFormControlLayout--fullWidth': fullWidth,
+ 'euiFormControlLayout--compressed': compressed,
+ 'euiFormControlLayout--group': prepend || append,
+ },
+ className
+ );
+
+ const prependNodes = this.renderPrepends();
+ const appendNodes = this.renderAppends();
+
+ let clonedChildren;
+ if ((prepend || append) && children) {
+ clonedChildren = cloneElement(children, {
+ className: `${children.props.className} euiFormControlLayout__child--noStyle`,
+ });
+ }
+
+ return (
+
+ {prependNodes}
+
+ {clonedChildren || children}
+
+
+
+ {appendNodes}
+
+ );
+ }
+
+ renderPrepends() {
+ const { prepend } = this.props;
+
+ if (!prepend) {
+ return;
+ }
+
+ let prependNodes;
+
+ if (Array.isArray(prepend)) {
+ prependNodes = prepend.map((item, index) => {
+ return this.createSideNode(item, 'prepend', index);
+ });
+ }
+
+ else {
+ prependNodes = this.createSideNode(prepend, 'prepend');
+ }
+
+ return prependNodes;
+ }
+
+ renderAppends() {
+ const { append } = this.props;
+
+ if (!append) {
+ return;
+ }
+
+ let appendNodes;
+
+ if (Array.isArray(append)) {
+ appendNodes = append.map((item, index) => {
+ return this.createSideNode(item, 'append', index);
+ });
+ }
+
+ else {
+ appendNodes = this.createSideNode(append, 'append');
+ }
+
+ return appendNodes;
+ }
+
+ createSideNode(node, side, key) {
+ return cloneElement(node, {
+ className: `euiFormControlLayout__${side}`,
+ key: key
+ });
+ }
+}
EuiFormControlLayout.propTypes = {
children: PropTypes.node,
@@ -63,14 +131,18 @@ EuiFormControlLayout.propTypes = {
className: PropTypes.string,
compressed: PropTypes.bool,
/**
- * Creates an input group with an inline label
+ * Creates an input group with element(s) coming before children
*/
- inlineLabel: PropTypes.oneOfType([
+ prepend: PropTypes.oneOfType([
PropTypes.node,
- PropTypes.shape({
- label: PropTypes.node,
- side: PropTypes.oneOf(LABEL_SIDES),
- }),
+ PropTypes.arrayOf(PropTypes.node),
+ ]),
+ /**
+ * Creates an input group with element(s) coming after children
+ */
+ append: PropTypes.oneOfType([
+ PropTypes.node,
+ PropTypes.arrayOf(PropTypes.node),
]),
};
diff --git a/src/components/form/form_control_layout/form_control_layout.test.js b/src/components/form/form_control_layout/form_control_layout.test.js
index 33749c6677d..08afabf4d58 100644
--- a/src/components/form/form_control_layout/form_control_layout.test.js
+++ b/src/components/form/form_control_layout/form_control_layout.test.js
@@ -135,5 +135,51 @@ describe('EuiFormControlLayout', () => {
expect(component).toMatchSnapshot();
});
+
+ test('one prepend is rendered', () => {
+ const component = render(
+ 1 }
+ />
+ );
+
+ expect(component).toMatchSnapshot();
+ });
+
+ test('one append is rendered', () => {
+ const component = render(
+ 1}
+ />
+ );
+
+ expect(component).toMatchSnapshot();
+ });
+
+ test('multiple prepends are rendered', () => {
+ const component = render(
+ 1,
+ 2
+ ]}
+ />
+ );
+
+ expect(component).toMatchSnapshot();
+ });
+
+ test('multiple appends are rendered', () => {
+ const component = render(
+ 1,
+ 2
+ ]}
+ />
+ );
+
+ expect(component).toMatchSnapshot();
+ });
});
});
diff --git a/src/components/form/form_control_layout/form_control_layout_children.js b/src/components/form/form_control_layout/form_control_layout_children.js
deleted file mode 100644
index 4a5a1a9223a..00000000000
--- a/src/components/form/form_control_layout/form_control_layout_children.js
+++ /dev/null
@@ -1,56 +0,0 @@
-import React, {
- cloneElement,
- Fragment,
-} from 'react';
-import PropTypes from 'prop-types';
-
-export const LABEL_SIDES = ['left', 'right'];
-
-export const EuiFormControlLayoutChildren = ({
- children,
- inlineLabel,
-}) => {
-
- const labelSide = inlineLabel && inlineLabel.side ? inlineLabel.side : 'left';
-
- let leftLabel;
- let rightLabel;
- let clonedChildren;
-
- if (inlineLabel) {
- const labelNode = inlineLabel.node ? inlineLabel.node : inlineLabel;
- const labelClone = cloneElement(labelNode, {
- className: 'euiFormControlLayout__inlineLabel'
- });
-
- if (labelSide === 'left') {
- leftLabel = labelClone;
- }
- else if (labelSide === 'right') {
- rightLabel = labelClone;
- }
-
- clonedChildren = cloneElement(children, {
- className: `${children.props.className} euiFormControlLayout__child--noStyle`,
- });
- }
-
-
- return (
-
- {leftLabel}
- {clonedChildren || children}
- {rightLabel}
-
- );
-};
-
-EuiFormControlLayoutChildren.propTypes = {
- inlineLabel: PropTypes.oneOfType([
- PropTypes.node,
- PropTypes.shape({
- label: PropTypes.node,
- side: PropTypes.oneOf(LABEL_SIDES),
- }),
- ]),
-};
From 88b2fdd960853f002ae5fc21dac46dc4c91d06dc Mon Sep 17 00:00:00 2001
From: cchaos
Date: Thu, 28 Jun 2018 17:32:41 -0400
Subject: [PATCH 12/21] Adding options to select, text, and number controls
---
.../src/views/form_controls/field_number.js | 12 ++++++++++++
.../form_controls/form_control_layout.js | 6 +++---
src/components/form/_mixins.scss | 13 +++++++++++++
.../form/field_number/field_number.js | 19 +++++++++++++++++++
src/components/form/field_text/field_text.js | 19 +++++++++++++++++++
.../_form_control_layout.scss | 13 ++-----------
src/components/form/select/_select.scss | 8 ++++++++
src/components/form/select/select.js | 19 +++++++++++++++++++
8 files changed, 95 insertions(+), 14 deletions(-)
diff --git a/src-docs/src/views/form_controls/field_number.js b/src-docs/src/views/form_controls/field_number.js
index b74aa14b487..307cfc119a8 100644
--- a/src-docs/src/views/form_controls/field_number.js
+++ b/src-docs/src/views/form_controls/field_number.js
@@ -6,6 +6,7 @@ import React, {
import {
EuiFieldNumber,
EuiSpacer,
+ EuiText,
} from '../../../../src/components';
export default class extends Component {
@@ -83,6 +84,17 @@ export default class extends Component {
onChange={this.onChange}
compressed
/>
+
+
+
+ % }
+ placeholder="0 - 100"
+ value={this.state.value}
+ onChange={this.onChange}
+ aria-label="Use aria labels when no actual label is in use"
+ />
);
}
diff --git a/src-docs/src/views/form_controls/form_control_layout.js b/src-docs/src/views/form_controls/form_control_layout.js
index 724d70dea9c..cc0022853f8 100644
--- a/src-docs/src/views/form_controls/form_control_layout.js
+++ b/src-docs/src/views/form_controls/form_control_layout.js
@@ -115,7 +115,7 @@ export default () => (
Label}
>
-
+
@@ -123,7 +123,7 @@ export default () => (
% }
>
-
+
@@ -133,7 +133,7 @@ export default () => (
clear={{ onClick: () => {} }}
prepend={Button }
>
-
+
);
diff --git a/src/components/form/_mixins.scss b/src/components/form/_mixins.scss
index aa6aaaeb610..8b217c53862 100644
--- a/src/components/form/_mixins.scss
+++ b/src/components/form/_mixins.scss
@@ -10,6 +10,7 @@
/**
* 1. Ensure the icon padding remains when in readOnly mode
+ * 2. Account for inner box-shadow style border when in group
*/
@mixin euiFormControlSize(
@@ -29,6 +30,14 @@
&--compressed {
height: $euiFormControlCompressedHeight;
}
+
+ &--inGroup {
+ height: $euiFormControlHeight - 2px; /* 2 */
+ }
+
+ &--inGroup#{&}--compressed {
+ height: $euiFormControlCompressedHeight - 2px; /* 2 */
+ }
}
}
@@ -141,6 +150,10 @@
padding-top: $euiFormControlCompressedPadding;
padding-bottom: $euiFormControlCompressedPadding;
}
+
+ &--inGroup {
+ box-shadow: none !important;
+ }
}
@if ($includeStates) {
diff --git a/src/components/form/field_number/field_number.js b/src/components/form/field_number/field_number.js
index a75471e455a..352ec8bd026 100644
--- a/src/components/form/field_number/field_number.js
+++ b/src/components/form/field_number/field_number.js
@@ -23,12 +23,15 @@ export const EuiFieldNumber = ({
fullWidth,
isLoading,
compressed,
+ prepend,
+ append,
...rest
}) => {
const classes = classNames('euiFieldNumber', className, {
'euiFieldNumber--withIcon': icon,
'euiFieldNumber--fullWidth': fullWidth,
'euiFieldNumber--compressed': compressed,
+ 'euiFieldNumber--inGroup': prepend || append,
'euiFieldNumber-isLoading': isLoading,
});
@@ -38,6 +41,8 @@ export const EuiFieldNumber = ({
fullWidth={fullWidth}
isLoading={isLoading}
compressed={compressed}
+ prepend={prepend}
+ append={append}
>
{
const classes = classNames('euiFieldText', className, {
'euiFieldText--withIcon': icon,
'euiFieldText--fullWidth': fullWidth,
'euiFieldText--compressed': compressed,
+ 'euiFieldText--inGroup': prepend || append,
'euiFieldText-isLoading': isLoading,
});
@@ -37,6 +40,8 @@ export const EuiFieldText = ({
fullWidth={fullWidth}
isLoading={isLoading}
compressed={compressed}
+ prepend={prepend}
+ append={append}
>
{
const classes = classNames(
@@ -30,6 +32,7 @@ export const EuiSelect = ({
{
'euiSelect--fullWidth': fullWidth,
'euiSelect--compressed': compressed,
+ 'euiSelect--inGroup': prepend || append,
'euiSelect-isLoading': isLoading,
},
className
@@ -60,6 +63,8 @@ export const EuiSelect = ({
fullWidth={fullWidth}
isLoading={isLoading}
compressed={compressed}
+ prepend={prepend}
+ append={append}
>
Date: Thu, 28 Jun 2018 20:22:48 -0400
Subject: [PATCH 13/21] changelog
---
CHANGELOG.md | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 436634f86ad..b6b5e5745b1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,8 +1,12 @@
## [`master`](https://github.com/elastic/eui/tree/master)
+- `EuiAccordion` use MutationObserver to re-calculate height when children DOM changes ([#947](https://github.com/elastic/eui/pull/947))
- Add `inspect` type option to icon typedef file. ([#952](https://github.com/elastic/eui/pull/952))
+- Simplified form control styles. ([#954](https://github.com/elastic/eui/pull/954))
-- `EuiAccordion` use MutationObserver to re-calculate height when children DOM changes ([#947](https://github.com/elastic/eui/pull/947))
+**Deprecations**
+
+- Replaced the following SASS variables have been replaced `$euiFormControlHeight--compressed`, `$euiFormControlPadding--compressed`, `euiFormBorderColor--disabled`. ([#954](https://github.com/elastic/eui/pull/954))
## [`1.0.0`](https://github.com/elastic/eui/tree/v1.0.0)
From 9802500288a63cbd74eee2d85409d8e2b891d28e Mon Sep 17 00:00:00 2001
From: cchaos
Date: Fri, 29 Jun 2018 16:56:01 -0400
Subject: [PATCH 14/21] Removing FormControlGroup
---
.../src/views/form_layouts/control_group.js | 50 --------------
.../form_layouts/form_layouts_example.js | 21 ------
src/components/form/_index.scss | 1 -
.../form_control_group.test.js.snap | 9 ---
.../_form_control_group.scss | 68 -------------------
.../form/form_control_group/_index.scss | 1 -
.../form_control_group/form_control_group.js | 25 -------
.../form_control_group.test.js | 16 -----
.../form/form_control_group/index.js | 3 -
src/components/form/index.js | 1 -
src/components/index.js | 1 -
11 files changed, 196 deletions(-)
delete mode 100644 src-docs/src/views/form_layouts/control_group.js
delete mode 100644 src/components/form/form_control_group/__snapshots__/form_control_group.test.js.snap
delete mode 100644 src/components/form/form_control_group/_form_control_group.scss
delete mode 100644 src/components/form/form_control_group/_index.scss
delete mode 100644 src/components/form/form_control_group/form_control_group.js
delete mode 100644 src/components/form/form_control_group/form_control_group.test.js
delete mode 100644 src/components/form/form_control_group/index.js
diff --git a/src-docs/src/views/form_layouts/control_group.js b/src-docs/src/views/form_layouts/control_group.js
deleted file mode 100644
index 1acc32f84e6..00000000000
--- a/src-docs/src/views/form_layouts/control_group.js
+++ /dev/null
@@ -1,50 +0,0 @@
-import React, { Fragment } from 'react';
-import moment from 'moment';
-
-import {
- EuiFormControlGroup,
- EuiFormLabel,
- EuiFieldText,
- EuiButton,
- EuiIcon,
- EuiText,
- EuiDatePicker,
- EuiFieldNumber,
- EuiSpacer,
- EuiHorizontalRule,
-} from '../../../../src/components';
-
-export default () => (
-
-
- Label:
-
-
-
-
-
-
-
- %
-
-
-
-
-
- Label:
-
-
-
-
-
-
-
-
-
-
-
- →
-
-
-
-);
diff --git a/src-docs/src/views/form_layouts/form_layouts_example.js b/src-docs/src/views/form_layouts/form_layouts_example.js
index f893644e225..e7b45b0789e 100644
--- a/src-docs/src/views/form_layouts/form_layouts_example.js
+++ b/src-docs/src/views/form_layouts/form_layouts_example.js
@@ -12,7 +12,6 @@ import {
EuiFormRow,
EuiDescribedFormGroup,
EuiFieldText,
- EuiFormControlGroup,
EuiPopover,
EuiRange,
EuiSwitch,
@@ -50,10 +49,6 @@ import FormCompressed from './form_compressed';
const formCompressedSource = require('!!raw-loader!./form_compressed');
const formCompressedHtml = renderToHtml(FormCompressed);
-import ControlGroup from './control_group';
-const controlGroupSource = require('!!raw-loader!./control_group');
-const controlGroupHtml = renderToHtml(ControlGroup);
-
export const FormLayoutsExample = {
title: 'Form layouts',
sections: [{
@@ -220,21 +215,5 @@ export const FormLayoutsExample = {
),
demo: ,
- }, {
- title: 'Groups',
- source: [{
- type: GuideSectionTypes.JS,
- code: controlGroupSource,
- }, {
- type: GuideSectionTypes.HTML,
- code: controlGroupHtml,
- }],
- text: (
-
- For use in confined spaces.
-
- ),
- demo: ,
- props: { EuiFormControlGroup }
}],
};
diff --git a/src/components/form/_index.scss b/src/components/form/_index.scss
index 1914776056a..42e041a9695 100644
--- a/src/components/form/_index.scss
+++ b/src/components/form/_index.scss
@@ -12,7 +12,6 @@
@import 'file_picker/index';
@import 'form';
@import 'form_control_layout/index';
-@import 'form_control_group/index';
@import 'form_error_text/index';
@import 'form_help_text/index';
@import 'form_label/index';
diff --git a/src/components/form/form_control_group/__snapshots__/form_control_group.test.js.snap b/src/components/form/form_control_group/__snapshots__/form_control_group.test.js.snap
deleted file mode 100644
index cdc7639891b..00000000000
--- a/src/components/form/form_control_group/__snapshots__/form_control_group.test.js.snap
+++ /dev/null
@@ -1,9 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`EuiFormControlGroup is rendered 1`] = `
-
-`;
diff --git a/src/components/form/form_control_group/_form_control_group.scss b/src/components/form/form_control_group/_form_control_group.scss
deleted file mode 100644
index b8e2b58b170..00000000000
--- a/src/components/form/form_control_group/_form_control_group.scss
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * 1. Account for inner box-shadow style border
- */
-
-.euiFormControlGroup {
- // Match just the regular box-shadow of inputs
- @include euiFormControlStyle();
- display: flex;
- padding: 1px; /* 1 */
-
- &--focus {
- @include euiFormControlFocusStyle();
- }
-
- > * {
- // defaults to growing children though filter buttons don't grow by default
- flex-grow: 1;
- }
-
- > .euiFormControlLayout {
- max-width: none;
- }
-
- [class*="euiField"] {
- box-shadow: none;
- height: $euiFormControlHeight - 2px; /* 1 */
- }
-
- > .euiFormLabel {
- flex-grow: 0;
- white-space: nowrap;
- margin-bottom: 0;
- height: $euiFormControlHeight - 2px; /* 1 */
- line-height: 1.4em;
- padding: $euiFormControlPadding;
- background-color: transparentize($euiColorFullShade, .95);
- }
-
- > .euiButton {
- min-width: $euiSizeXL*2;
- border: none;
- box-shadow: none !important;
- }
-
- > .euiText {
- line-height: $euiFormControlHeight - 2px !important;
- }
-
- .euiHorizontalRule {
- width: 1.1px !important;
- height: $euiFormControlHeight - 2px;
- margin: 0;
- }
-
- // Date picker hack
- .euiDatePicker {
- // The actual input
- .euiDatePicker {
- text-align: center;
- padding-left: $euiFormControlPadding;
- }
-
- // Force remove icon
- .euiFormControlLayoutIcons {
- display: none;
- }
- }
-}
diff --git a/src/components/form/form_control_group/_index.scss b/src/components/form/form_control_group/_index.scss
deleted file mode 100644
index fdca4d3282c..00000000000
--- a/src/components/form/form_control_group/_index.scss
+++ /dev/null
@@ -1 +0,0 @@
-@import 'form_control_group';
diff --git a/src/components/form/form_control_group/form_control_group.js b/src/components/form/form_control_group/form_control_group.js
deleted file mode 100644
index eab29beae45..00000000000
--- a/src/components/form/form_control_group/form_control_group.js
+++ /dev/null
@@ -1,25 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-import classNames from 'classnames';
-
-export const EuiFormControlGroup = ({
- children,
- className,
- ...rest,
-}) => {
- const classes = classNames('euiFormControlGroup', className);
-
- return (
-
- {children}
-
- );
-};
-
-EuiFormControlGroup.propTypes = {
- children: PropTypes.node,
- className: PropTypes.string,
-};
diff --git a/src/components/form/form_control_group/form_control_group.test.js b/src/components/form/form_control_group/form_control_group.test.js
deleted file mode 100644
index f134444a77e..00000000000
--- a/src/components/form/form_control_group/form_control_group.test.js
+++ /dev/null
@@ -1,16 +0,0 @@
-import React from 'react';
-import { render } from 'enzyme';
-import { requiredProps } from '../../../test';
-
-import { EuiFormControlGroup } from './form_control_group';
-
-describe('EuiFormControlGroup', () => {
- test('is rendered', () => {
- const component = render(
-
- );
-
- expect(component)
- .toMatchSnapshot();
- });
-});
diff --git a/src/components/form/form_control_group/index.js b/src/components/form/form_control_group/index.js
deleted file mode 100644
index 323e550fa93..00000000000
--- a/src/components/form/form_control_group/index.js
+++ /dev/null
@@ -1,3 +0,0 @@
-export {
- EuiFormControlGroup,
-} from './form_control_group';
diff --git a/src/components/form/index.js b/src/components/form/index.js
index 469754f3223..f04fdc5605b 100644
--- a/src/components/form/index.js
+++ b/src/components/form/index.js
@@ -9,7 +9,6 @@ export { EuiFieldSearch } from './field_search';
export { EuiFieldText } from './field_text';
export { EuiFilePicker } from './file_picker';
export { EuiForm } from './form';
-export { EuiFormControlGroup } from './form_control_group';
export { EuiFormControlLayout } from './form_control_layout';
export { EuiFormErrorText } from './form_error_text';
export { EuiFormHelpText } from './form_help_text';
diff --git a/src/components/index.js b/src/components/index.js
index f09b158828a..2c41840fd58 100644
--- a/src/components/index.js
+++ b/src/components/index.js
@@ -120,7 +120,6 @@ export {
EuiFieldText,
EuiFilePicker,
EuiForm,
- EuiFormControlGroup,
EuiFormControlLayout,
EuiFormErrorText,
EuiFormHelpText,
From 0af05cbf47ac2d992351a3eabf8e079ff39c1577 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Fri, 29 Jun 2018 18:54:33 -0400
Subject: [PATCH 15/21] Get rid of console error
---
src-docs/src/views/button/button_icon.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src-docs/src/views/button/button_icon.js b/src-docs/src/views/button/button_icon.js
index 524b1ff4c2b..89a21d46f60 100644
--- a/src-docs/src/views/button/button_icon.js
+++ b/src-docs/src/views/button/button_icon.js
@@ -19,8 +19,8 @@ const colors = [
export default () => (
{
- colors.map(color => (
-
+ colors.map((color, index) => (
+
Date: Fri, 29 Jun 2018 18:55:12 -0400
Subject: [PATCH 16/21] Updating filter groups
- And fixing flashing bg of empty buttons
---
.../src/views/filter_group/filter_group.js | 30 ++++-
.../button/button_empty/_button_empty.scss | 7 +-
src/components/button/button_empty/index.js | 2 +
src/components/button/index.js | 5 +-
.../__snapshots__/filter_button.test.js.snap | 14 +--
.../filter_group/_filter_button.scss | 88 ++++----------
.../filter_group/_filter_group.scss | 20 +++-
src/components/filter_group/filter_button.js | 109 +++++++-----------
8 files changed, 120 insertions(+), 155 deletions(-)
diff --git a/src-docs/src/views/filter_group/filter_group.js b/src-docs/src/views/filter_group/filter_group.js
index 1ac38609570..ee1da0bb927 100644
--- a/src-docs/src/views/filter_group/filter_group.js
+++ b/src-docs/src/views/filter_group/filter_group.js
@@ -22,13 +22,29 @@ export default class extends Component {
this.state = {
isPopoverOpen: false,
isFilterOn: false,
+ isOnFilterOn: false,
+ isOffFilterOn: false,
};
}
toggleFilter = () => {
- this.setState({
- isFilterOn: !this.state.isFilterOn,
- });
+ this.setState(prevState => ({
+ isFilterOn: !prevState.isFilterOn,
+ }));
+ }
+
+ toggleOnFilter = () => {
+ this.setState(prevState => ({
+ isOnFilterOn: !prevState.isOnFilterOn,
+ isOffFilterOn: prevState.isOffFilterOn && !prevState.isOnFilterOn ? false : prevState.isOffFilterOn,
+ }));
+ }
+
+ toggleOffFilter = () => {
+ this.setState(prevState => ({
+ isOffFilterOn: !prevState.isOffFilterOn,
+ isOnFilterOn: prevState.isOnFilterOn && !prevState.isOffFilterOn ? false : prevState.isOnFilterOn,
+ }));
}
onButtonClick() {
@@ -85,8 +101,11 @@ export default class extends Component {
Filter
-
- Filter Disabled
+
+ On
+
+
+ Off
diff --git a/src/components/button/button_empty/_button_empty.scss b/src/components/button/button_empty/_button_empty.scss
index 55da7f4b277..1e6eab90fcd 100644
--- a/src/components/button/button_empty/_button_empty.scss
+++ b/src/components/button/button_empty/_button_empty.scss
@@ -1,6 +1,7 @@
/**
* 1. We don't want any of the animations that come inherited from the mixin.
* These should act like normal links instead.
+ * 2. Change the easing, quickness to not bounce so lighter backgrounds don't flash
*/
.euiButtonEmpty {
@include euiButton;
@@ -8,8 +9,10 @@
border-color: transparent;
background-color: transparent;
box-shadow: none;
- transform: none !important; // 1
- animation: none !important; // 1
+ transform: none !important; /* 1 */
+ animation: none !important; /* 1 */
+ transition-timing-function: ease-in; /* 2 */
+ transition-duration: $euiAnimSpeedFast; /* 2 */
.euiButtonEmpty__content {
@include euiButtonContent;
diff --git a/src/components/button/button_empty/index.js b/src/components/button/button_empty/index.js
index 97b0e080c31..53d74ff8cb2 100644
--- a/src/components/button/button_empty/index.js
+++ b/src/components/button/button_empty/index.js
@@ -1,3 +1,5 @@
export {
+ COLORS,
+ ICON_SIDES,
EuiButtonEmpty,
} from './button_empty';
diff --git a/src/components/button/index.js b/src/components/button/index.js
index 31fa83f805c..96feec44188 100644
--- a/src/components/button/index.js
+++ b/src/components/button/index.js
@@ -1,4 +1,7 @@
-export { EuiButton } from './button';
+export {
+ COLORS,
+ EuiButton
+} from './button';
export {
EuiButtonEmpty,
diff --git a/src/components/filter_group/__snapshots__/filter_button.test.js.snap b/src/components/filter_group/__snapshots__/filter_button.test.js.snap
index 9efa815d161..cf3e8aaf2bc 100644
--- a/src/components/filter_group/__snapshots__/filter_button.test.js.snap
+++ b/src/components/filter_group/__snapshots__/filter_button.test.js.snap
@@ -3,20 +3,18 @@
exports[`EuiFilterButton is rendered 1`] = `
-
+
+
`;
diff --git a/src/components/filter_group/_filter_button.scss b/src/components/filter_group/_filter_button.scss
index 983f66e97ea..9f8d7267e2e 100644
--- a/src/components/filter_group/_filter_button.scss
+++ b/src/components/filter_group/_filter_button.scss
@@ -3,92 +3,52 @@
@import '../form/form_control_layout/mixins';
/**
- * 1. Only add the border style drop shadow
+ * 1. Account for inner box-shadow style border
*/
.euiFilterButton {
flex-grow: 0; // Shrink by default
+ height: $euiFormControlHeight - 2px; /* 1 */
+ font-size: $euiFontSizeS;
- .euiFilterButton__content {
- @include euiFormControlStyle($borderOnly: true, $includeStates: false);
- width: auto;
- max-width: none;
- white-space: nowrap;
+ &:not(:last-child):not(.euiFilterButton--noDivider) {
+ border-right: 1px solid $euiFormBorderColor;
}
- &:disabled .euiFilterButton__content {
- @include euiFormControlDisabledStyle;
+ &:disabled {
font-style: italic;
}
- .euiFilterButton__textShift {
- display: inline-block;
- text-align: center;
- vertical-align: middle;
-
- &::after {
- display: block;
- content: attr(data-text);
- font-weight: $euiFontWeightBold;
- height: 0;
- overflow: hidden;
- visibility: hidden;
- }
- }
-
- .euiFilterButton__notification {
- margin-left: $euiSizeS;
- vertical-align: text-bottom;
- }
-
- &.euiFilterButton-isSelected,
- &:hover:not(:disabled),
- &:focus:not(:disabled) {
- .euiFilterButton__textShift {
- text-decoration: underline;
- }
- }
-
- &.euiFilterButton-grow {
+ &.euiFilterButton--grow {
flex-grow: 1;
width: 100%;
+ text-align: left;
- .euiFilterButton__content {
- width: 100%;
- text-align: left;
+ // Force content to space out icon
+ .euiButtonEmpty__content {
+ justify-content: space-between;
}
}
&.euiFilterButton-hasActiveFilters {
- font-weight: $euiFontWeightBold;
+ font-weight: $euiFontWeightMedium;
}
-}
-// Modifier naming and colors.
-$buttonTypes: (
- primary: $euiColorPrimary,
- danger: $euiColorDanger,
- disabled: tintOrShade($euiTextColor, 70%, 80%),
- ghost: $euiColorGhost,
- text: $euiTextColor,
-);
-
-// Create button modifiders based upon the map.
-@each $name, $color in $buttonTypes {
- .euiFilterButton--#{$name} {
- color: $color;
+ .euiFilterButton__notification {
+ margin-left: $euiSizeS;
+ vertical-align: text-bottom;
}
}
-// Icon padding
-.euiFilterButton--iconLeft {
- .euiFilterButton__content {
- @include euiFormControlLayout__padding(1, "left");
- }
-}
+.euiFilterButton__textShift {
+ vertical-align: middle;
-.euiFilterButton--iconRight {
- .euiFilterButton__content {
- @include euiFormControlLayout__padding(1);
+ &::after {
+ display: block;
+ content: attr(data-text);
+ font-weight: $euiFontWeightBold;
+ height: 0;
+ overflow: hidden;
+ visibility: hidden;
}
}
diff --git a/src/components/filter_group/_filter_group.scss b/src/components/filter_group/_filter_group.scss
index 088e10e2cc3..a0b2f3b20b3 100644
--- a/src/components/filter_group/_filter_group.scss
+++ b/src/components/filter_group/_filter_group.scss
@@ -1,18 +1,26 @@
+@import '../form/mixins';
+
.euiFilterGroup {
+ // Match just the regular drop shadow of inputs
+ @include euiFormControlDefaultShadow;
+ @include euiFormControlSize;
+ max-width: none;
display: flex;
- // Match just the regular box-shadow of inputs
- box-shadow: 0 3px 2px -2px rgba($euiShadowColor, 0.2);
+ align-items: center;
+ padding: 1px; /* 1 */
> * {
- // defaults to growing children though filter buttons don't grow by default
+ // defaults to growing children
+ // though filter buttons don't grow by default
flex-grow: 1;
}
- > * + * {
- margin-left: -1px;
+ // Force popover anchors to expand for now
+ .euiPopover__anchor {
+ display: block;
}
}
.euiFilterGroup__popoverPanel {
- width: $euiSize * 20;
+ max-width: $euiSize * 20;
}
diff --git a/src/components/filter_group/filter_button.js b/src/components/filter_group/filter_button.js
index 89c04beafeb..cbcb57c41de 100644
--- a/src/components/filter_group/filter_button.js
+++ b/src/components/filter_group/filter_button.js
@@ -2,31 +2,18 @@ import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
-import { getSecureRelForTarget } from '../../services';
-import { EuiFormControlLayout } from '../form/form_control_layout';
+// import { getSecureRelForTarget } from '../../services';
import { EuiHeaderNotification } from '../header/header_notification';
+import {
+ COLORS,
+ ICON_SIDES,
+ EuiButtonEmpty,
+} from '../button/button_empty';
import {
ICON_TYPES,
} from '../icon';
-const colorToClassNameMap = {
- primary: 'euiFilterButton--primary',
- danger: 'euiFilterButton--danger',
- disabled: 'euiFilterButton--disabled',
- text: 'euiFilterButton--text',
- ghost: 'euiFilterButton--ghost',
-};
-
-export const COLORS = Object.keys(colorToClassNameMap);
-
-const iconSideToClassNameMap = {
- left: 'euiFilterButton--iconLeft',
- right: 'euiFilterButton--iconRight',
-};
-
-export const ICON_SIDES = Object.keys(iconSideToClassNameMap);
-
export const EuiFilterButton = ({
children,
className,
@@ -37,73 +24,55 @@ export const EuiFilterButton = ({
numFilters,
isDisabled,
isSelected,
- href,
- target,
- rel,
+ // href,
+ // target,
+ // rel,
type,
grow,
+ noDivider,
...rest
}) => {
- const iconClasses = iconType ? iconSideToClassNameMap[iconSide] : undefined;
-
const classes = classNames(
'euiFilterButton',
- colorToClassNameMap[color],
- iconClasses,
{
'euiFilterButton-isSelected': isSelected,
'euiFilterButton-hasActiveFilters': hasActiveFilters,
- 'euiFilterButton-grow': grow,
+ 'euiFilterButton--grow': grow,
+ 'euiFilterButton--noDivider': noDivider,
},
className,
);
- const icon = iconType ? {
- type: iconType,
- side: iconSide,
- } : undefined;
-
const buttonContents = (
-
-
- {children}
- {numFilters &&
- {numFilters}
- }
-
-
+
+ {children}
+ {numFilters &&
+ {numFilters}
+ }
+
);
- if (href) {
- const secureRel = getSecureRelForTarget(target, rel);
+ // let secureRel;
+ // if (href) {
+ // secureRel = getSecureRelForTarget(target, rel);
+ // }
- return (
-
- {buttonContents}
-
- );
- } else {
- return (
-
- {buttonContents}
-
- );
- }
+ return (
+
+ {buttonContents}
+
+ );
};
EuiFilterButton.propTypes = {
@@ -149,6 +118,10 @@ EuiFilterButton.propTypes = {
* Should the button grow to fill it's container, best used for dropdown buttons
*/
grow: PropTypes.bool,
+ /**
+ * Remove border after button, good for opposite filters
+ */
+ noDivider: PropTypes.bool,
};
EuiFilterButton.defaultProps = {
From d19c365d9fb9ef8e4a591d00dbdcee41ddae3ec6 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Mon, 2 Jul 2018 11:53:52 -0400
Subject: [PATCH 17/21] =?UTF-8?q?Updating=20`EuiSearchBar`=E2=80=99s=20usa?=
=?UTF-8?q?ge=20of=20filters?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../__snapshots__/search_filters.test.js.snap | 18 ++++--------------
.../field_value_selection_filter.test.js.snap | 16 ++++++++--------
...ield_value_toggle_group_filter.test.js.snap | 8 ++++++++
.../filters/field_value_selection_filter.js | 3 ++-
.../filters/field_value_toggle_group_filter.js | 2 ++
src/components/search_bar/search_filters.js | 6 +++---
6 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/src/components/search_bar/__snapshots__/search_filters.test.js.snap b/src/components/search_bar/__snapshots__/search_filters.test.js.snap
index 269c295f2e7..2253cdafa02 100644
--- a/src/components/search_bar/__snapshots__/search_filters.test.js.snap
+++ b/src/components/search_bar/__snapshots__/search_filters.test.js.snap
@@ -4,13 +4,8 @@ exports[`EuiSearchFilters render - no filters 1`] = ` `;
exports[`EuiSearchFilters render - with filters 1`] = `
-
-
-
+
-
+
`;
diff --git a/src/components/search_bar/filters/__snapshots__/field_value_selection_filter.test.js.snap b/src/components/search_bar/filters/__snapshots__/field_value_selection_filter.test.js.snap
index 00698953ecf..dbadf457d73 100644
--- a/src/components/search_bar/filters/__snapshots__/field_value_selection_filter.test.js.snap
+++ b/src/components/search_bar/filters/__snapshots__/field_value_selection_filter.test.js.snap
@@ -2,11 +2,11 @@
exports[`FieldValueSelectionFilter render - all configurations 1`] = `
,
@@ -17,6 +18,7 @@ Array [
hasActiveFilters={false}
iconSide="right"
key="field_value_toggle_filter_item_1"
+ noDivider={false}
onClick={[Function]}
type="button"
/>,
@@ -31,6 +33,7 @@ Array [
hasActiveFilters={true}
iconSide="right"
key="field_value_toggle_filter_item_0"
+ noDivider={true}
onClick={[Function]}
type="button"
/>,
@@ -40,6 +43,7 @@ Array [
hasActiveFilters={false}
iconSide="right"
key="field_value_toggle_filter_item_1"
+ noDivider={false}
onClick={[Function]}
type="button"
/>,
@@ -54,6 +58,7 @@ Array [
hasActiveFilters={true}
iconSide="right"
key="field_value_toggle_filter_item_0"
+ noDivider={true}
onClick={[Function]}
type="button"
/>,
@@ -63,6 +68,7 @@ Array [
hasActiveFilters={false}
iconSide="right"
key="field_value_toggle_filter_item_1"
+ noDivider={false}
onClick={[Function]}
type="button"
/>,
@@ -77,6 +83,7 @@ Array [
hasActiveFilters={false}
iconSide="right"
key="field_value_toggle_filter_item_0"
+ noDivider={true}
onClick={[Function]}
type="button"
/>,
@@ -86,6 +93,7 @@ Array [
hasActiveFilters={false}
iconSide="right"
key="field_value_toggle_filter_item_1"
+ noDivider={false}
onClick={[Function]}
type="button"
/>,
diff --git a/src/components/search_bar/filters/field_value_selection_filter.js b/src/components/search_bar/filters/field_value_selection_filter.js
index 709dee3d6e0..190233e586e 100644
--- a/src/components/search_bar/filters/field_value_selection_filter.js
+++ b/src/components/search_bar/filters/field_value_selection_filter.js
@@ -218,6 +218,7 @@ export class FieldValueSelectionFilter extends Component {
iconSide="right"
onClick={this.onButtonClick.bind(this)}
hasActiveFilters={active}
+ grow
>
{config.name}
@@ -238,7 +239,7 @@ export class FieldValueSelectionFilter extends Component {
closePopover={this.closePopover.bind(this)}
panelPaddingSize="none"
withTitle={withTitle}
- anchorPosition="downRight"
+ anchorPosition="downCenter"
panelClassName="euiFilterGroup__popoverPanel"
>
{searchBox}
diff --git a/src/components/search_bar/filters/field_value_toggle_group_filter.js b/src/components/search_bar/filters/field_value_toggle_group_filter.js
index 0c0189bfc2d..01d5819367a 100644
--- a/src/components/search_bar/filters/field_value_toggle_group_filter.js
+++ b/src/components/search_bar/filters/field_value_toggle_group_filter.js
@@ -60,11 +60,13 @@ export class FieldValueToggleGroupFilter extends Component {
this.valueChanged(item, active);
};
const key = `field_value_toggle_filter_item_${index}`;
+ const isLastItem = index === config.items.length - 1;
return (
{name}
diff --git a/src/components/search_bar/search_filters.js b/src/components/search_bar/search_filters.js
index 5586c434180..fa07d74bcdf 100644
--- a/src/components/search_bar/search_filters.js
+++ b/src/components/search_bar/search_filters.js
@@ -1,4 +1,4 @@
-import React, { Component } from 'react';
+import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import { createFilter, FilterConfigType } from './filters';
import { Query } from './query';
@@ -31,9 +31,9 @@ export class EuiSearchFilters extends Component {
const key = `filter_${index}`;
const control = createFilter(index, filterConfig, query, onChange);
controls.push(
-
+
{control}
-
+
);
return controls;
}, []);
From e0c9bfd1e503bb91cc479f912acd0e76452c0f94 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Mon, 2 Jul 2018 15:49:11 -0400
Subject: [PATCH 18/21] Added `DatePickerRange` component
to control the style of two date pickers.
---
.../views/date_picker/date_picker_example.js | 7 +-
src-docs/src/views/date_picker/range.js | 50 +++++-----
.../date_picker_range.test.js.snap | 94 +++++++++++++++++++
.../date_picker/_date_picker_range.scss | 34 +++++++
src/components/date_picker/_index.scss | 1 +
src/components/date_picker/date_picker.js | 10 +-
.../date_picker/date_picker_range.js | 78 +++++++++++++++
.../date_picker/date_picker_range.test.js | 21 +++++
src/components/date_picker/index.js | 4 +
.../_form_control_layout.scss | 1 +
src/components/index.js | 1 +
11 files changed, 271 insertions(+), 30 deletions(-)
create mode 100644 src/components/date_picker/__snapshots__/date_picker_range.test.js.snap
create mode 100644 src/components/date_picker/_date_picker_range.scss
create mode 100644 src/components/date_picker/date_picker_range.js
create mode 100644 src/components/date_picker/date_picker_range.test.js
diff --git a/src-docs/src/views/date_picker/date_picker_example.js b/src-docs/src/views/date_picker/date_picker_example.js
index 9ed74fbbff8..68f70923ad6 100644
--- a/src-docs/src/views/date_picker/date_picker_example.js
+++ b/src-docs/src/views/date_picker/date_picker_example.js
@@ -10,6 +10,7 @@ import {
EuiCode,
EuiLink,
EuiDatePicker,
+ EuiDatePickerRange,
} from '../../../../src/components';
import DatePicker from './date_picker';
@@ -144,10 +145,14 @@ export const DatePickerExample = {
text: (
By passing startDate and endDate props
- you can provide styling the range in between two dates.
+ you can provide styling the range in between two dates. To further style the
+ group as a single control, use EuiDatePickerRange and pass
+ the date picker controls into
+ the startDateControl and endDateControl props.
),
demo: ,
+ props: { EuiDatePickerRange },
}, {
title: 'Only allow specific dates and times',
source: [{
diff --git a/src-docs/src/views/date_picker/range.js b/src-docs/src/views/date_picker/range.js
index 6226ef56084..1c303a181d1 100644
--- a/src-docs/src/views/date_picker/range.js
+++ b/src-docs/src/views/date_picker/range.js
@@ -7,9 +7,7 @@ import moment from 'moment';
import {
EuiDatePicker,
- EuiFlexGroup,
- EuiFlexItem,
- EuiFormRow,
+ EuiDatePickerRange,
} from '../../../../src/components';
export default class extends Component {
@@ -39,30 +37,28 @@ export default class extends Component {
render() {
return (
-
-
-
-
-
-
-
-
-
-
-
-
+
+ }
+ endDateControl={
+
+ }
+ />
);
}
}
diff --git a/src/components/date_picker/__snapshots__/date_picker_range.test.js.snap b/src/components/date_picker/__snapshots__/date_picker_range.test.js.snap
new file mode 100644
index 00000000000..2549a3bfedb
--- /dev/null
+++ b/src/components/date_picker/__snapshots__/date_picker_range.test.js.snap
@@ -0,0 +1,94 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`EuiDatePickerRange is rendered 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+ →
+
+
+
+
+
+
+
+
+`;
diff --git a/src/components/date_picker/_date_picker_range.scss b/src/components/date_picker/_date_picker_range.scss
new file mode 100644
index 00000000000..8c931a14db5
--- /dev/null
+++ b/src/components/date_picker/_date_picker_range.scss
@@ -0,0 +1,34 @@
+@import '../form/variables';
+@import '../form/mixins';
+
+/**
+ * 1. Account for inner box-shadow style border
+ */
+
+ .euiDatePickerRange {
+ @include euiFormControlSize(auto, $includeAlternates: true);
+ // Match just the regular drop shadow of inputs
+ @include euiFormControlDefaultShadow();
+ display: flex;
+ align-items: center;
+ padding: 1px; /* 1 */
+
+ > span {
+ flex-grow: 1;
+ }
+
+ .euiDatePicker {
+ box-shadow: none !important; // including all states
+ text-align: center;
+ }
+}
+
+.euiDatePickerRange__icon {
+ padding-left: $euiFormControlPadding;
+ padding-right: $euiFormControlPadding;
+}
+
+.euiDatePickerRange__delimeter {
+ padding-left: $euiFormControlPadding/2;
+ padding-right: $euiFormControlPadding/2;
+}
diff --git a/src/components/date_picker/_index.scss b/src/components/date_picker/_index.scss
index f44d6770ed1..65219322767 100644
--- a/src/components/date_picker/_index.scss
+++ b/src/components/date_picker/_index.scss
@@ -1,2 +1,3 @@
// Uses some form mixins
@import 'date_picker';
+@import 'date_picker_range';
diff --git a/src/components/date_picker/date_picker.js b/src/components/date_picker/date_picker.js
index 332e74ed4c4..bb279fd8ec9 100644
--- a/src/components/date_picker/date_picker.js
+++ b/src/components/date_picker/date_picker.js
@@ -49,6 +49,7 @@ export class EuiDatePicker extends Component {
selected,
shadow,
shouldCloseOnSelect,
+ showIcon,
showTimeSelect,
showTimeSelectOnly,
timeFormat,
@@ -70,14 +71,14 @@ export class EuiDatePicker extends Component {
{
'euiFieldText--fullWidth': fullWidth,
'euiFieldText-isLoading': isLoading,
- 'euiFieldText--withIcon': !inline,
+ 'euiFieldText--withIcon': !inline && showIcon,
'euiFieldText-isInvalid': isInvalid,
},
className
);
let optionalIcon;
- if (inline || customInput) {
+ if (inline || customInput || !showIcon) {
optionalIcon = null;
} else if (showTimeSelectOnly) {
optionalIcon = 'clock';
@@ -268,6 +269,10 @@ EuiDatePicker.propTypes = {
* Will close the popup on selection
*/
shouldCloseOnSelect: PropTypes.bool,
+ /**
+ * Show the icon in input
+ */
+ showIcon: PropTypes.bool,
/**
* Show the time selection alongside the calendar
*/
@@ -288,5 +293,6 @@ EuiDatePicker.defaultProps = {
isLoading: false,
shadow: true,
shouldCloseOnSelect: true,
+ showIcon: true,
timeFormat: 'hh:mm A',
};
diff --git a/src/components/date_picker/date_picker_range.js b/src/components/date_picker/date_picker_range.js
new file mode 100644
index 00000000000..4ff4a15bcca
--- /dev/null
+++ b/src/components/date_picker/date_picker_range.js
@@ -0,0 +1,78 @@
+import React, {
+ cloneElement,
+} from 'react';
+import PropTypes from 'prop-types';
+import classNames from 'classnames';
+
+import { EuiText } from '../text';
+import {
+ ICON_TYPES,
+ EuiIcon,
+} from '../icon';
+
+export const EuiDatePickerRange = ({
+ className,
+ startDateControl,
+ endDateControl,
+ iconType,
+ ...rest
+}) => {
+
+ const classes = classNames(
+ 'euiDatePickerRange',
+ className
+ );
+
+ // Set the icon for the entire group instead of per control
+ let optionalIcon;
+ if (iconType) {
+ const icon = typeof iconType === 'string' ? iconType : 'calendar';
+ optionalIcon = (
+
+ );
+ } else {
+ optionalIcon = null;
+ }
+
+ const clonedStartDate = cloneElement(startDateControl, {
+ showIcon: false,
+ });
+
+ const clonedEndDate = cloneElement(endDateControl, {
+ showIcon: false,
+ });
+
+ return (
+
+ {optionalIcon}
+ {clonedStartDate}
+ →
+ {clonedEndDate}
+
+ );
+};
+
+EuiDatePickerRange.propTypes = {
+ /**
+ * The start date `EuiDatePicker` element
+ */
+ startDateControl: PropTypes.node.isRequired,
+ /**
+ * The end date `EuiDatePicker` element
+ */
+ endDateControl: PropTypes.node.isRequired,
+ /**
+ * Pass either an icon type or set to `false` to remove icon entirely
+ */
+ iconType: PropTypes.oneOfType([
+ PropTypes.bool,
+ PropTypes.oneOf(ICON_TYPES),
+ ]),
+};
+
+EuiDatePickerRange.defaultProps = {
+ iconType: true,
+};
diff --git a/src/components/date_picker/date_picker_range.test.js b/src/components/date_picker/date_picker_range.test.js
new file mode 100644
index 00000000000..72b0fea7e97
--- /dev/null
+++ b/src/components/date_picker/date_picker_range.test.js
@@ -0,0 +1,21 @@
+import React from 'react';
+import { render } from 'enzyme';
+import { requiredProps } from '../../test';
+
+import { EuiDatePickerRange } from './date_picker_range';
+import { EuiDatePicker } from './date_picker';
+
+describe('EuiDatePickerRange', () => {
+ test('is rendered', () => {
+ const component = render(
+ }
+ endDateControl={ }
+ {...requiredProps}
+ />
+ );
+
+ expect(component)
+ .toMatchSnapshot();
+ });
+});
diff --git a/src/components/date_picker/index.js b/src/components/date_picker/index.js
index a50b7176468..eb720402eec 100644
--- a/src/components/date_picker/index.js
+++ b/src/components/date_picker/index.js
@@ -1,3 +1,7 @@
export {
EuiDatePicker,
} from './date_picker';
+
+export {
+ EuiDatePickerRange,
+} from './date_picker_range';
diff --git a/src/components/form/form_control_layout/_form_control_layout.scss b/src/components/form/form_control_layout/_form_control_layout.scss
index b5d655cceb5..30f6ec1c8f0 100644
--- a/src/components/form/form_control_layout/_form_control_layout.scss
+++ b/src/components/form/form_control_layout/_form_control_layout.scss
@@ -1,4 +1,5 @@
@import '../variables';
+@import '../mixins';
.euiFormControlLayout {
// Let the height expand as needed
diff --git a/src/components/index.js b/src/components/index.js
index 2c41840fd58..26e939e255b 100644
--- a/src/components/index.js
+++ b/src/components/index.js
@@ -66,6 +66,7 @@ export {
export {
EuiDatePicker,
+ EuiDatePickerRange,
} from './date_picker';
export {
From 130d8720ed61472bb1077901cbdb18a01d3b5074 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Mon, 2 Jul 2018 16:27:22 -0400
Subject: [PATCH 19/21] Forgot to remove one more part of non-existent comp
---
.../form_control_layout/_form_control_layout_children.scss | 3 ---
src/components/form/form_control_layout/_index.scss | 1 -
2 files changed, 4 deletions(-)
delete mode 100644 src/components/form/form_control_layout/_form_control_layout_children.scss
diff --git a/src/components/form/form_control_layout/_form_control_layout_children.scss b/src/components/form/form_control_layout/_form_control_layout_children.scss
deleted file mode 100644
index 50b36e8eb30..00000000000
--- a/src/components/form/form_control_layout/_form_control_layout_children.scss
+++ /dev/null
@@ -1,3 +0,0 @@
-.euiFormControlLayoutChildren {
-
-}
diff --git a/src/components/form/form_control_layout/_index.scss b/src/components/form/form_control_layout/_index.scss
index 83dac974b3d..f5a9b5d33bc 100644
--- a/src/components/form/form_control_layout/_index.scss
+++ b/src/components/form/form_control_layout/_index.scss
@@ -3,4 +3,3 @@
@import 'form_control_layout_icons';
@import 'form_control_layout_clear_button';
@import 'form_control_layout_custom_icon';
-@import 'form_control_layout_children';
From b7af0dd8fd5525b63cb5eaafa014a0d8aed2ac93 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Mon, 2 Jul 2018 16:39:04 -0400
Subject: [PATCH 20/21] changelog
---
CHANGELOG.md | 3 +++
.../range/__snapshots__/range.test.js.snap | 26 +++++++++++--------
2 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 01c46c5e0f3..f366daf9bba 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,9 @@
## [`master`](https://github.com/elastic/eui/tree/master)
- Added more (mainly style) options to `EuiRange` ([#932](https://github.com/elastic/eui/pull/932))
+- Added `prepend` and `append` props to `EuiFormControlLayout` ([#961](https://github.com/elastic/eui/pull/961))
+- Updated style implementation of `EuiFilterGroup` and `EuiFilterGroupButton` ([#961](https://github.com/elastic/eui/pull/961))
+- Added `EuiDatePickerRange` as a way to layout two `EuiDatePicker`s. ([#961](https://github.com/elastic/eui/pull/961))
## [`1.0.1`](https://github.com/elastic/eui/tree/v1.0.1)
diff --git a/src/components/form/range/__snapshots__/range.test.js.snap b/src/components/form/range/__snapshots__/range.test.js.snap
index e9539ebbf9b..8115936460c 100644
--- a/src/components/form/range/__snapshots__/range.test.js.snap
+++ b/src/components/form/range/__snapshots__/range.test.js.snap
@@ -62,17 +62,21 @@ exports[`EuiRange props extra input should render 1`] = `
`;
From 9ba5136b09f59dbdd400f2babf4387feae7e3b66 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Fri, 13 Jul 2018 14:19:04 -0400
Subject: [PATCH 21/21] Addressed PR feedback
---
src-docs/src/views/button/button_icon.js | 4 ++--
src-docs/src/views/date_picker/range.js | 2 ++
src/components/filter_group/filter_button.js | 22 --------------------
3 files changed, 4 insertions(+), 24 deletions(-)
diff --git a/src-docs/src/views/button/button_icon.js b/src-docs/src/views/button/button_icon.js
index 89a21d46f60..8fb87a60d00 100644
--- a/src-docs/src/views/button/button_icon.js
+++ b/src-docs/src/views/button/button_icon.js
@@ -19,8 +19,8 @@ const colors = [
export default () => (
{
- colors.map((color, index) => (
-
+ colors.map((color) => (
+
this.state.endDate}
aria-label="Start date"
showTimeSelect
/>
@@ -54,6 +55,7 @@ export default class extends Component {
onChange={this.handleChangeEnd}
startDate={this.state.startDate}
endDate={this.state.endDate}
+ isInvalid={this.state.startDate > this.state.endDate}
aria-label="End date"
showTimeSelect
/>
diff --git a/src/components/filter_group/filter_button.js b/src/components/filter_group/filter_button.js
index b27c7d829ff..433099ccaf2 100644
--- a/src/components/filter_group/filter_button.js
+++ b/src/components/filter_group/filter_button.js
@@ -24,9 +24,6 @@ export const EuiFilterButton = ({
numFilters,
isDisabled,
isSelected,
- // href,
- // target,
- // rel,
type,
grow,
noDivider,
@@ -53,11 +50,6 @@ export const EuiFilterButton = ({
);
- // let secureRel;
- // if (href) {
- // secureRel = getSecureRelForTarget(target, rel);
- // }
-
return (
@@ -98,18 +88,6 @@ EuiFilterButton.propTypes = {
*/
isSelected: PropTypes.bool,
isDisabled: PropTypes.bool,
- /**
- * If passed, changes the button to an anchor tag
- */
- href: PropTypes.string,
- /**
- * Used along with href
- */
- target: PropTypes.string,
- /**
- * Used along with href
- */
- rel: PropTypes.string,
/**
* Defines html button input type
*/