diff --git a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Input_With_Popover.png b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Input_With_Popover.png index 0ce6eb8a10d..e79e57f6576 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Input_With_Popover.png and b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Input_With_Popover.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiForm_EuiFormControlLayoutDelimited_Kitchen_Sink.png b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiForm_EuiFormControlLayoutDelimited_Kitchen_Sink.png new file mode 100644 index 00000000000..aede257cfe5 Binary files /dev/null and b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiForm_EuiFormControlLayoutDelimited_Kitchen_Sink.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiForm_EuiFormControlLayoutDelimited_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiForm_EuiFormControlLayoutDelimited_Playground.png index cc3441b51da..06f8ecb0be7 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiForm_EuiFormControlLayoutDelimited_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiForm_EuiFormControlLayoutDelimited_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiForm_EuiFormControlLayout_Append_Prepend.png b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiForm_EuiFormControlLayout_Append_Prepend.png index 7005743689c..b2f0be35dc8 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiForm_EuiFormControlLayout_Append_Prepend.png and b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiForm_EuiFormControlLayout_Append_Prepend.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Layout_EuiHeader_EuiHeaderLink_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Layout_EuiHeader_EuiHeaderLink_Playground.png index c984704c3ce..061bde84782 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Layout_EuiHeader_EuiHeaderLink_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Layout_EuiHeader_EuiHeaderLink_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Layout_EuiHeader_EuiHeaderLinks_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Layout_EuiHeader_EuiHeaderLinks_Playground.png index fd315956807..6653d562191 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Layout_EuiHeader_EuiHeaderLinks_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Layout_EuiHeader_EuiHeaderLinks_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Input_With_Popover.png b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Input_With_Popover.png index f0258667e15..cb8b4eb2974 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Input_With_Popover.png and b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Input_With_Popover.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiForm_EuiFormControlLayoutDelimited_Kitchen_Sink.png b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiForm_EuiFormControlLayoutDelimited_Kitchen_Sink.png new file mode 100644 index 00000000000..40578428372 Binary files /dev/null and b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiForm_EuiFormControlLayoutDelimited_Kitchen_Sink.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiForm_EuiFormControlLayoutDelimited_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiForm_EuiFormControlLayoutDelimited_Playground.png index a3fadce810f..c7a124343a9 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiForm_EuiFormControlLayoutDelimited_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiForm_EuiFormControlLayoutDelimited_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiForm_EuiFormControlLayout_Append_Prepend.png b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiForm_EuiFormControlLayout_Append_Prepend.png index c5ad244f78e..aa15cbb7eb2 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiForm_EuiFormControlLayout_Append_Prepend.png and b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiForm_EuiFormControlLayout_Append_Prepend.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Layout_EuiHeader_EuiHeaderLink_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Layout_EuiHeader_EuiHeaderLink_Playground.png index 2d0a573afa8..04dd3ca34e8 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Layout_EuiHeader_EuiHeaderLink_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Layout_EuiHeader_EuiHeaderLink_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Layout_EuiHeader_EuiHeaderLinks_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Layout_EuiHeader_EuiHeaderLinks_Playground.png index 2cd588a3021..7e8da064785 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Layout_EuiHeader_EuiHeaderLinks_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Layout_EuiHeader_EuiHeaderLinks_Playground.png differ diff --git a/packages/eui/changelogs/upcoming/7957.md b/packages/eui/changelogs/upcoming/7957.md new file mode 100644 index 00000000000..37d7ee96540 --- /dev/null +++ b/packages/eui/changelogs/upcoming/7957.md @@ -0,0 +1,9 @@ +**Bug fixes** + +- Fixed a visual bug with `` form controls + +**CSS-in-JS conversions** + +- Converted `EuiFormLayoutDelimited` to Emotion +- Fixed `cloneElementWithCss` throwing an error when used multiple times without a `key` prop +- Updated `cloneElementWithCss` utility to support a third argument that allows prepending vs. appending the cloned Emotion css className diff --git a/packages/eui/changelogs/upcoming/7961.md b/packages/eui/changelogs/upcoming/7961.md new file mode 100644 index 00000000000..204b37dc74f --- /dev/null +++ b/packages/eui/changelogs/upcoming/7961.md @@ -0,0 +1,3 @@ +- Updated `EuiHeaderLinks`'s mobile menu to set a slight popover padding by default + - This can be overridden via `popoverProps.panelPaddingSize` if needed. +- Updated `EuiHeaderLink` to default to a size of `s` (down from `m`) diff --git a/packages/eui/src-docs/src/components/guide_page/guide_page_header.tsx b/packages/eui/src-docs/src/components/guide_page/guide_page_header.tsx index 3d2429afe91..f68018f3927 100644 --- a/packages/eui/src-docs/src/components/guide_page/guide_page_header.tsx +++ b/packages/eui/src-docs/src/components/guide_page/guide_page_header.tsx @@ -1,15 +1,13 @@ -import React, { useState, useMemo } from 'react'; +import React, { useMemo } from 'react'; import { EuiBadge, - EuiButtonEmpty, - EuiFlexGroup, - EuiFlexItem, EuiHeader, + EuiHeaderLink, + EuiHeaderLinks, EuiHeaderLogo, EuiHeaderSectionItemButton, EuiIcon, - EuiPopover, EuiToolTip, } from '../../../../src/components'; import { useIsWithinBreakpoints } from '../../../../src/services'; @@ -69,14 +67,9 @@ export const GuidePageHeader: React.FunctionComponent = ({ const github = useMemo(() => { const label = 'EUI GitHub repo'; return isMobileSize ? ( - + {label} - + ) : ( @@ -90,9 +83,9 @@ export const GuidePageHeader: React.FunctionComponent = ({ const label = 'Codesandbox'; return isMobileSize ? ( - + {label} - + ) : ( @@ -105,39 +98,18 @@ export const GuidePageHeader: React.FunctionComponent = ({ ); }, [isMobileSize]); - const [mobilePopoverIsOpen, setMobilePopoverIsOpen] = useState(false); - const mobileMenu = useMemo(() => { - const button = ( - setMobilePopoverIsOpen((isOpen) => !isOpen)} - > - - ); - return ( - setMobilePopoverIsOpen(false)} + - - {github} - - - - {codesandbox} - - + {github} + + {codesandbox} + ); - }, [mobilePopoverIsOpen, codesandbox, github]); + }, [codesandbox, github]); const rightSideItems = isMobileSize ? [ diff --git a/packages/eui/src-docs/src/components/guide_theme_selector/guide_figma_link.tsx b/packages/eui/src-docs/src/components/guide_theme_selector/guide_figma_link.tsx index 05f6d9db11b..93def2d3955 100644 --- a/packages/eui/src-docs/src/components/guide_theme_selector/guide_figma_link.tsx +++ b/packages/eui/src-docs/src/components/guide_theme_selector/guide_figma_link.tsx @@ -1,15 +1,17 @@ /* eslint-disable no-restricted-globals */ import React from 'react'; -import { EuiButtonEmpty } from '../../../../src/components/button'; import { useIsWithinBreakpoints } from '../../../../src/services'; - -import { ThemeContext } from '../with_theme'; -import { EuiHeaderSectionItemButton } from '../../../../src/components/header'; +import { + EuiHeaderLink, + EuiHeaderSectionItemButton, +} from '../../../../src/components/header'; import { EuiToolTip } from '../../../../src/components/tool_tip'; import { EuiIcon } from '../../../../src/components/icon'; import logoFigma from '../../images/logo-figma.svg'; +import { ThemeContext } from '../with_theme'; + type GuideFigmaLinkProps = { context?: any; }; @@ -34,9 +36,9 @@ const GuideFigmaLinkComponent: React.FunctionComponent< const label = 'EUI Figma Design Library'; return isMobileSize ? ( - + {label} - + ) : ( ( fullWidth startControl={ } endControl={ } @@ -36,15 +36,15 @@ export default () => ( } endControl={ } @@ -54,15 +54,15 @@ export default () => ( append={px} startControl={ } endControl={ } @@ -73,14 +73,14 @@ export default () => ( startControl={ } endControl={ } @@ -91,15 +91,15 @@ export default () => ( isLoading startControl={ } endControl={ } @@ -109,15 +109,15 @@ export default () => ( isLoading startControl={ } endControl={ } @@ -127,15 +127,15 @@ export default () => ( compressed startControl={ } endControl={ } @@ -145,16 +145,16 @@ export default () => ( prepend={Add} startControl={ } delimiter="+" endControl={ } @@ -164,16 +164,16 @@ export default () => ( prepend={Merge} startControl={ } delimiter={} endControl={ } @@ -184,16 +184,16 @@ export default () => ( prepend={Read only} startControl={ } endControl={ @@ -205,16 +205,16 @@ export default () => ( prepend={Disabled} startControl={ } endControl={ diff --git a/packages/eui/src/components/date_picker/__snapshots__/date_picker.test.tsx.snap b/packages/eui/src/components/date_picker/__snapshots__/date_picker.test.tsx.snap index fc37946bb87..96942b839e9 100644 --- a/packages/eui/src/components/date_picker/__snapshots__/date_picker.test.tsx.snap +++ b/packages/eui/src/components/date_picker/__snapshots__/date_picker.test.tsx.snap @@ -5,10 +5,10 @@ exports[`EuiDatePicker localization accepts the locale prop 1`] = ` class="euiDatePicker testClass1 testClass2 emotion-euiDatePicker-inline-shadow-euiTestCss" >
@@ -72,10 +72,10 @@ exports[`EuiDatePickerRange props compressed 1`] = ` class="euiDatePickerRange emotion-euiDatePickerRange" >
@@ -137,10 +137,10 @@ exports[`EuiDatePickerRange props disabled 1`] = ` class="euiDatePickerRange emotion-euiDatePickerRange" >
@@ -269,10 +269,10 @@ exports[`EuiDatePickerRange props inline renders 1`] = ` class="euiDatePickerRange emotion-euiDatePickerRangeInline-responsive-shadow" >
@@ -1402,10 +1402,10 @@ exports[`EuiDatePickerRange props isLoading 1`] = ` class="euiDatePickerRange emotion-euiDatePickerRange" >
@@ -1476,10 +1476,10 @@ exports[`EuiDatePickerRange props readOnly 1`] = ` class="euiDatePickerRange emotion-euiDatePickerRange" >
diff --git a/packages/eui/src/components/date_picker/date_picker.spec.tsx b/packages/eui/src/components/date_picker/date_picker.spec.tsx index a319e2f0fa2..1c3246a53d2 100644 --- a/packages/eui/src/components/date_picker/date_picker.spec.tsx +++ b/packages/eui/src/components/date_picker/date_picker.spec.tsx @@ -44,7 +44,6 @@ describe('EuiDatePicker', () => { cy.get('.euiFormControlLayoutIcons') .invoke('attr', 'class') .should('contain', 'euiFormControlLayoutIcons-static'); - cy.get('.euiFormControlLayoutDelimited--isInvalid').should('exist'); }); it('renders as disabled', () => { diff --git a/packages/eui/src/components/date_picker/date_picker.styles.ts b/packages/eui/src/components/date_picker/date_picker.styles.ts index 329cdb2fb0d..90401385347 100644 --- a/packages/eui/src/components/date_picker/date_picker.styles.ts +++ b/packages/eui/src/components/date_picker/date_picker.styles.ts @@ -11,6 +11,12 @@ import { css } from '@emotion/react'; import { UseEuiTheme } from '../../services'; import { logicalCSS } from '../../global_styling'; import { euiShadowMedium } from '../../themes/amsterdam/global_styling/mixins'; +import { + euiFormControlDisabledStyles, + euiFormControlReadOnlyStyles, + euiFormControlDefaultShadow, + euiFormControlInvalidStyles, +} from '../form/form.styles'; export const euiDatePickerStyles = (euiThemeContext: UseEuiTheme) => { const { euiTheme } = euiThemeContext; @@ -19,35 +25,55 @@ export const euiDatePickerStyles = (euiThemeContext: UseEuiTheme) => { euiDatePicker: css` display: block; `, - inline: css` - .euiFormControlLayout { - ${logicalCSS('height', 'auto')} - ${logicalCSS('width', 'fit-content')} - background-color: transparent; - box-shadow: none; - padding: 0; - } - /* TODO: Extra specificity required to override .euiFormControlLayoutDelimited styles */ - .euiFormControlLayoutDelimited .euiFormControlLayout__childrenWrapper { - background-color: transparent; - flex-direction: column; /* Render form control icons below date picker */ - } + inline: { + inline: css` + .euiFormControlLayout { + ${logicalCSS('height', 'auto')} + ${logicalCSS('width', 'fit-content')} + box-shadow: none; + padding: 0; + } - .euiFormControlLayoutIcons { - justify-content: center; - ${logicalCSS('padding-bottom', euiTheme.size.s)} - } - `, - shadow: css` - .euiFormControlLayout { - ${euiShadowMedium(euiThemeContext)} - } + .euiFormControlLayout__childrenWrapper { + flex-direction: column; /* Render form control icons below date picker */ + } - /* TODO: Extra specificity required to override .euiFormControlLayoutDelimited styles */ - .euiFormControlLayoutDelimited .euiFormControlLayout__childrenWrapper { - background-color: ${euiTheme.colors.emptyShade}; - } - `, + .euiFormControlLayoutIcons { + justify-content: center; + ${logicalCSS('padding-bottom', euiTheme.size.s)} + } + `, + // Skip css`` to avoid generating an Emotion className + noShadow: ` + .euiFormControlLayout { + background-color: transparent; + } + `, + shadow: css` + .euiFormControlLayout { + background-color: ${euiTheme.colors.emptyShade}; + ${euiShadowMedium(euiThemeContext)} + } + `, + // Needs to come before shadow CSS so that it doesn't override their background-colors + invalid: css` + .euiFormControlLayout { + ${euiFormControlDefaultShadow(euiThemeContext, { withBorder: false })} + ${euiFormControlInvalidStyles(euiThemeContext)} + } + `, + // Should come after shadow CSS to override their background-colors + disabled: css` + .euiFormControlLayout { + ${euiFormControlDisabledStyles(euiThemeContext)} + } + `, + readOnly: css` + .euiFormControlLayout { + ${euiFormControlReadOnlyStyles(euiThemeContext)} + } + `, + }, }; }; diff --git a/packages/eui/src/components/date_picker/date_picker.tsx b/packages/eui/src/components/date_picker/date_picker.tsx index ae99fffe5e1..3e86e0a37df 100644 --- a/packages/eui/src/components/date_picker/date_picker.tsx +++ b/packages/eui/src/components/date_picker/date_picker.tsx @@ -188,20 +188,27 @@ export const EuiDatePicker: FunctionComponent = ({ utcOffset, ...rest }) => { + // Check for whether the passed `selected` moment date is valid + const isInvalid = + _isInvalid || (selected?.isValid() === false ? true : undefined); + const styles = useEuiMemoizedStyles(euiDatePickerStyles); const cssStyles = [ styles.euiDatePicker, - inline && styles.inline, - inline && shadow && styles.shadow, + ...(inline + ? [ + styles.inline.inline, + isInvalid && !(disabled || readOnly) && styles.inline.invalid, + shadow ? styles.inline.shadow : styles.inline.noShadow, + disabled && styles.inline.disabled, + readOnly && styles.inline.readOnly, + ] + : []), ]; const calendarStyles = useEuiMemoizedStyles(euiReactDatePickerStyles); const classes = classNames('euiDatePicker', className); - // Check for whether the passed `selected` moment date is valid - const isInvalid = - _isInvalid || (selected?.isValid() === false ? true : undefined); - // Passed to the default EuiFieldText input, not passed to custom inputs const defaultInputProps = !inline && !customInput ? { compressed, fullWidth } : undefined; @@ -297,12 +304,7 @@ export const EuiDatePicker: FunctionComponent = ({ isInvalid={isInvalid} isDisabled={disabled} readOnly={readOnly} - className={classNames({ - // Take advantage of `euiFormControlLayoutDelimited`'s replacement input styling - euiFormControlLayoutDelimited: inline, - 'euiFormControlLayoutDelimited--isInvalid': - inline && isInvalid && !disabled && !readOnly, - })} + isDelimited={inline} // Styling shortcut for inline calendars iconsPosition={inline ? 'static' : undefined} > {control} diff --git a/packages/eui/src/components/date_picker/date_picker_range.styles.ts b/packages/eui/src/components/date_picker/date_picker_range.styles.ts index c160967b251..e6cb89f7cbc 100644 --- a/packages/eui/src/components/date_picker/date_picker_range.styles.ts +++ b/packages/eui/src/components/date_picker/date_picker_range.styles.ts @@ -58,7 +58,6 @@ export const euiDatePickerRangeInlineStyles = ( ${logicalCSS('height', 'auto')} ${logicalCSS('width', 'fit-content')} ${logicalCSS('max-width', '100%')} - background-color: transparent; box-shadow: none; padding: 0; @@ -70,14 +69,6 @@ export const euiDatePickerRangeInlineStyles = ( background-color: transparent; } - /* Fix --group height when append/prepend are present */ - &.euiFormControlLayout--group { - & > *, - .euiFormControlLayoutDelimited__delimiter { - ${logicalCSS('height', 'auto')} - } - } - /* Display form control icons below both date pickers */ .euiFormControlLayoutIcons { justify-content: center; @@ -101,11 +92,18 @@ export const euiDatePickerRangeInlineStyles = ( shadow: css` .euiFormControlLayoutDelimited { ${euiShadowMedium(euiThemeContext)} - - .euiFormControlLayout__childrenWrapper { - background-color: ${euiTheme.colors.emptyShade}; - } } `, + + // Applied directly to EuiFormControlLayout so we can check if `disabled` + // and allow the disabled background-color to take precedence + formLayout: { + noShadow: css` + background-color: transparent; + `, + shadow: css` + background-color: ${euiTheme.colors.emptyShade}; + `, + }, }; }; diff --git a/packages/eui/src/components/date_picker/date_picker_range.tsx b/packages/eui/src/components/date_picker/date_picker_range.tsx index c51804c7b89..8e64e6ae760 100644 --- a/packages/eui/src/components/date_picker/date_picker_range.tsx +++ b/packages/eui/src/components/date_picker/date_picker_range.tsx @@ -216,6 +216,13 @@ export const EuiDatePickerRange: FunctionComponent = ({ isLoading={isLoading} append={inline ? undefined : append} prepend={inline ? undefined : prepend} + css={ + inline && + !disabled && + (shadow + ? inlineStyles.formLayout.shadow + : inlineStyles.formLayout.noShadow) + } /> ); diff --git a/packages/eui/src/components/date_picker/super_date_picker/__snapshots__/super_date_picker.test.tsx.snap b/packages/eui/src/components/date_picker/super_date_picker/__snapshots__/super_date_picker.test.tsx.snap index e65b659ecee..37a6e3a5b1f 100644 --- a/packages/eui/src/components/date_picker/super_date_picker/__snapshots__/super_date_picker.test.tsx.snap +++ b/packages/eui/src/components/date_picker/super_date_picker/__snapshots__/super_date_picker.test.tsx.snap @@ -768,7 +768,7 @@ exports[`EuiSuperDatePicker renders an EuiDatePickerRange 1`] = ` class="euiDatePickerRange emotion-euiDatePickerRange-euiSuperDatePicker__range-euiSuperDatePicker__formControlLayout-default" >