From 4976217cbefd398a9b6135fc715fd0f096e57d05 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Thu, 17 Dec 2020 14:43:42 -0500 Subject: [PATCH] [EuiFormControlLayout] Use smaller icons when in compressed size (#4374) * adjust icons for compressed * Changing some new props to `size` and reducing size of clear button too Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> Co-authored-by: cchaos --- CHANGELOG.md | 2 +- .../__snapshots__/date_picker.test.tsx.snap | 3 ++ ..._control_layout_clear_button.test.tsx.snap | 17 +++++++++-- ...m_control_layout_custom_icon.test.tsx.snap | 22 +++++++++++--- .../_form_control_layout_clear_button.scss | 4 +++ .../_form_control_layout_custom_icon.scss | 5 +--- .../form_control_layout.tsx | 1 + .../form_control_layout_clear_button.test.tsx | 21 +++++++++---- .../form_control_layout_clear_button.tsx | 20 +++++++++++-- .../form_control_layout_custom_icon.test.tsx | 30 +++++++++++++------ .../form_control_layout_custom_icon.tsx | 6 +++- .../form_control_layout_icons.tsx | 22 ++++++++++---- src/global_styling/mixins/_form.scss | 15 +++++++--- 13 files changed, 128 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c8b0ed149c..9f1c474d5e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## [`master`](https://github.com/elastic/eui/tree/master) -No public interface changes since `31.0.0`. +- Reduced the size of the icons and clear button for compressed `EuiFormControlLayout` ([#4374](https://github.com/elastic/eui/pull/4374)) ## [`31.0.0`](https://github.com/elastic/eui/tree/v31.0.0) diff --git a/src/components/date_picker/__snapshots__/date_picker.test.tsx.snap b/src/components/date_picker/__snapshots__/date_picker.test.tsx.snap index 3100f370605..3aa06328dd4 100644 --- a/src/components/date_picker/__snapshots__/date_picker.test.tsx.snap +++ b/src/components/date_picker/__snapshots__/date_picker.test.tsx.snap @@ -948,6 +948,7 @@ exports[`EuiDatePicker popoverPlacement top-end is rendered 1`] = ` className="euiFormControlLayoutIcons" > diff --git a/src/components/form/form_control_layout/form_control_layout_icons.tsx b/src/components/form/form_control_layout/form_control_layout_icons.tsx index a4dcd5d7433..405d42bc5ac 100644 --- a/src/components/form/form_control_layout/form_control_layout_icons.tsx +++ b/src/components/form/form_control_layout/form_control_layout_icons.tsx @@ -52,6 +52,7 @@ export interface EuiFormControlLayoutIconsProps { icon?: IconType | IconShape; clear?: EuiFormControlLayoutClearButtonProps; isLoading?: boolean; + compressed?: boolean; } export class EuiFormControlLayoutIcons extends Component< @@ -59,7 +60,6 @@ export class EuiFormControlLayoutIcons extends Component< > { render() { const { icon } = this.props; - const iconSide = isIconShape(icon) && icon.side ? icon.side : 'left'; const customIcon = this.renderCustomIcon(); const loadingSpinner = this.renderLoadingSpinner(); @@ -93,7 +93,7 @@ export class EuiFormControlLayoutIcons extends Component< } renderCustomIcon() { - const { icon } = this.props; + const { icon, compressed } = this.props; if (!icon) { return null; @@ -105,10 +105,15 @@ export class EuiFormControlLayoutIcons extends Component< : { type: icon, }; - const { ref: iconRef, side, ...iconRest } = iconProps; - return ; + return ( + + ); } renderLoadingSpinner() { @@ -122,11 +127,16 @@ export class EuiFormControlLayoutIcons extends Component< } renderClearButton() { - const { clear } = this.props; + const { clear, compressed } = this.props; if (!clear) { return null; } - return ; + return ( + + ); } } diff --git a/src/global_styling/mixins/_form.scss b/src/global_styling/mixins/_form.scss index a4f6b926769..a217f6e5b68 100644 --- a/src/global_styling/mixins/_form.scss +++ b/src/global_styling/mixins/_form.scss @@ -25,10 +25,16 @@ } } -@mixin euiFormControlLayoutClearIcon($iconClass) { +@mixin euiFormControlLayoutClearIcon($iconClass, $size: 'm') { $clearSize: $euiSize; - @include size($clearSize); + $clearIconStroke: 2px; + + @if ($size == 's') { + $clearSize: $euiSizeM; + $clearIconStroke: $euiSizeXS; + } + @include size($clearSize); pointer-events: all; background-color: lightOrDarkTheme($euiColorMediumShade, $euiColorDarkShade); border-radius: $clearSize; @@ -39,10 +45,11 @@ } #{$iconClass} { - @include size($euiSizeS); + @include size($clearSize / 2); fill: $euiColorEmptyShade; + // increase thickness of icon at such a small size stroke: $euiColorEmptyShade; - stroke-width: 2px; // increase thickness of icon at such a small size + stroke-width: $clearIconStroke; } }