From 649c90008a4805119ac3c61e41f6b35bcf3c8131 Mon Sep 17 00:00:00 2001 From: cchaos Date: Mon, 27 Aug 2018 12:18:16 -0400 Subject: [PATCH 1/4] Fixing buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Don’t let icon or spinner shrink - Allow empty buttons to truncate - #848 - Allow icon sizes to be passed to EuiButtonIcon --- src-docs/src/views/button/button_example.js | 4 +- src-docs/src/views/button/button_icon.js | 1 - .../collapsed_item_actions.test.js.snap | 1 + .../default_item_action.test.js.snap | 1 + .../in_memory_table.test.js.snap | 14 +++- src/components/button/_mixins.scss | 5 ++ .../__snapshots__/button_empty.test.js.snap | 68 ++++++++++++++----- .../button/button_empty/_button_empty.scss | 6 +- .../button/button_empty/button_empty.js | 4 +- .../button/button_icon/_button_icon.scss | 15 ++-- .../button/button_icon/button_icon.js | 6 +- .../__snapshots__/filter_button.test.js.snap | 4 +- .../__snapshots__/header_link.test.js.snap | 4 +- src/components/icon/index.js | 1 + .../__snapshots__/confirm_modal.test.js.snap | 4 +- .../pagination_button.test.js.snap | 4 +- .../table_sort_mobile.test.js.snap | 4 +- .../table_pagination.test.js.snap | 44 +++++++++--- 18 files changed, 137 insertions(+), 53 deletions(-) diff --git a/src-docs/src/views/button/button_example.js b/src-docs/src/views/button/button_example.js index 33792aaeb97..cf470e48f4a 100644 --- a/src-docs/src/views/button/button_example.js +++ b/src-docs/src/views/button/button_example.js @@ -165,9 +165,7 @@ export const ButtonExample = { text: (

Button icons are buttons that only contain an icon - (no text). Note: the - the dark background on the ghost example is used - only for illustrative purposes. + (no text).

), props: { EuiButtonIcon }, diff --git a/src-docs/src/views/button/button_icon.js b/src-docs/src/views/button/button_icon.js index 8fb87a60d00..c15fa0d81a8 100644 --- a/src-docs/src/views/button/button_icon.js +++ b/src-docs/src/views/button/button_icon.js @@ -22,7 +22,6 @@ export default () => ( colors.map((color) => ( window.alert('Button clicked')} iconType="arrowRight" diff --git a/src/components/basic_table/__snapshots__/collapsed_item_actions.test.js.snap b/src/components/basic_table/__snapshots__/collapsed_item_actions.test.js.snap index 7f2c460a91f..e2ab243b688 100644 --- a/src/components/basic_table/__snapshots__/collapsed_item_actions.test.js.snap +++ b/src/components/basic_table/__snapshots__/collapsed_item_actions.test.js.snap @@ -8,6 +8,7 @@ exports[`CollapsedItemActions render 1`] = ` aria-label="actions" className={undefined} color="text" + iconSize="m" iconType="gear" isDisabled={false} onClick={[Function]} diff --git a/src/components/basic_table/__snapshots__/default_item_action.test.js.snap b/src/components/basic_table/__snapshots__/default_item_action.test.js.snap index 2bc22651bf9..dee76650464 100644 --- a/src/components/basic_table/__snapshots__/default_item_action.test.js.snap +++ b/src/components/basic_table/__snapshots__/default_item_action.test.js.snap @@ -19,6 +19,7 @@ exports[`DefaultItemAction render - icon 1`] = ` - + Rows per page: 2 @@ -389,6 +391,7 @@ exports[`EuiInMemoryTable behavior pagination 1`] = ` aria-label="Previous page" color="text" disabled={false} + iconSize="m" iconType="arrowLeft" onClick={[Function]} type="button" @@ -480,7 +483,9 @@ exports[`EuiInMemoryTable behavior pagination 1`] = ` - + 1 @@ -515,7 +520,9 @@ exports[`EuiInMemoryTable behavior pagination 1`] = ` - + 2 @@ -526,6 +533,7 @@ exports[`EuiInMemoryTable behavior pagination 1`] = ` aria-label="Next page" color="text" disabled={true} + iconSize="m" iconType="arrowRight" onClick={[Function]} type="button" diff --git a/src/components/button/_mixins.scss b/src/components/button/_mixins.scss index 794b81f8a9a..a8b4fd559f1 100644 --- a/src/components/button/_mixins.scss +++ b/src/components/button/_mixins.scss @@ -40,6 +40,11 @@ width: 100%; vertical-align: middle; + .euiButton__icon, + .euiButton__spinner { + flex-shrink: 0; // Ensures the icons/spinner don't scale down below their intended size + } + @if ($isReverse) { flex-direction: row-reverse; diff --git a/src/components/button/button_empty/__snapshots__/button_empty.test.js.snap b/src/components/button/button_empty/__snapshots__/button_empty.test.js.snap index 63c8430286e..cb829362ba3 100644 --- a/src/components/button/button_empty/__snapshots__/button_empty.test.js.snap +++ b/src/components/button/button_empty/__snapshots__/button_empty.test.js.snap @@ -10,7 +10,9 @@ exports[`EuiButtonEmpty is rendered 1`] = ` - + Content @@ -25,7 +27,9 @@ exports[`EuiButtonEmpty props color danger is rendered 1`] = ` - + `; @@ -38,7 +42,9 @@ exports[`EuiButtonEmpty props color disabled is rendered 1`] = ` - + `; @@ -51,7 +57,9 @@ exports[`EuiButtonEmpty props color ghost is rendered 1`] = ` - + `; @@ -64,7 +72,9 @@ exports[`EuiButtonEmpty props color primary is rendered 1`] = ` - + `; @@ -77,7 +87,9 @@ exports[`EuiButtonEmpty props color text is rendered 1`] = ` - + `; @@ -90,7 +102,9 @@ exports[`EuiButtonEmpty props flush left is rendered 1`] = ` - + `; @@ -103,7 +117,9 @@ exports[`EuiButtonEmpty props flush right is rendered 1`] = ` - + `; @@ -118,7 +134,9 @@ exports[`EuiButtonEmpty props href secures the rel attribute when the target is - + `; @@ -151,7 +169,9 @@ exports[`EuiButtonEmpty props iconSide left is rendered 1`] = ` /> - + Content @@ -186,7 +206,9 @@ exports[`EuiButtonEmpty props iconSide right is rendered 1`] = ` /> - + Content @@ -221,7 +243,9 @@ exports[`EuiButtonEmpty props iconType is rendered 1`] = ` /> - + `; @@ -235,7 +259,9 @@ exports[`EuiButtonEmpty props isDisabled is rendered 1`] = ` - + `; @@ -249,7 +275,9 @@ exports[`EuiButtonEmpty props isDisabled renders a button even when href is defi - + `; @@ -262,7 +290,9 @@ exports[`EuiButtonEmpty props size l is rendered 1`] = ` - + `; @@ -275,7 +305,9 @@ exports[`EuiButtonEmpty props size s is rendered 1`] = ` - + `; @@ -288,7 +320,9 @@ exports[`EuiButtonEmpty props size xs is rendered 1`] = ` - + `; diff --git a/src/components/button/button_empty/_button_empty.scss b/src/components/button/button_empty/_button_empty.scss index 1e6eab90fcd..a594c820c1f 100644 --- a/src/components/button/button_empty/_button_empty.scss +++ b/src/components/button/button_empty/_button_empty.scss @@ -16,10 +16,14 @@ .euiButtonEmpty__content { @include euiButtonContent; - padding: 0 $euiSizeS; } + .euiButtonEmpty__text { + text-overflow: ellipsis; + overflow: hidden; + } + &.euiButtonEmpty--small { height: $euiButtonHeightSmall; } diff --git a/src/components/button/button_empty/button_empty.js b/src/components/button/button_empty/button_empty.js index 3ed06daf3fc..799db99bf2a 100644 --- a/src/components/button/button_empty/button_empty.js +++ b/src/components/button/button_empty/button_empty.js @@ -112,7 +112,7 @@ export const EuiButtonEmpty = ({ > {buttonIcon} - {children} + {children} ); @@ -127,7 +127,7 @@ export const EuiButtonEmpty = ({ > {buttonIcon} - {children} + {children} ); diff --git a/src/components/button/button_icon/_button_icon.scss b/src/components/button/button_icon/_button_icon.scss index 5c2b849a92d..cca1af101bc 100644 --- a/src/components/button/button_icon/_button_icon.scss +++ b/src/components/button/button_icon/_button_icon.scss @@ -1,19 +1,16 @@ .euiButtonIcon { @include euiButton; - border-color: transparent; + border: none; background-color: transparent; box-shadow: none; - height: $euiSizeL; - width: $euiSizeL; - line-height: $euiSizeL; + height: auto; + min-height: $euiSizeL; + min-width: $euiSizeL; + line-height: 0; // ensures the icon creates the line-height and so it's always vertically centered + padding: $euiSizeXS; border-radius: $euiBorderRadius; - // Account for border. - .euiButtonIcon__icon { - transform: translateY(-2px); - } - &:disabled { color: $euiButtonColorDisabled; pointer-events: none; diff --git a/src/components/button/button_icon/button_icon.js b/src/components/button/button_icon/button_icon.js index 9726a1a8e73..1e0c4db90cf 100644 --- a/src/components/button/button_icon/button_icon.js +++ b/src/components/button/button_icon/button_icon.js @@ -5,6 +5,7 @@ import classNames from 'classnames'; import { getSecureRelForTarget } from '../../../services'; import { + ICON_SIZES, ICON_TYPES, EuiIcon, } from '../../icon'; @@ -40,6 +41,7 @@ export const COLORS = Object.keys(colorToClassNameMap); export const EuiButtonIcon = ({ className, iconType, + iconSize, color, isDisabled, href, @@ -64,7 +66,7 @@ export const EuiButtonIcon = ({