diff --git a/src-docs/src/views/date_picker/states.js b/src-docs/src/views/date_picker/states.js index dbca3463c0d..8d4276764d7 100644 --- a/src-docs/src/views/date_picker/states.js +++ b/src-docs/src/views/date_picker/states.js @@ -22,7 +22,7 @@ export default () => { return ( /* DisplayToggles wrapper for Docs only */
- + { expect(container.firstChild).toMatchSnapshot(); }); + test('compressed', () => { + const { container } = render(); + // TODO: Should probably be a visual snapshot test + expect(container.innerHTML).toContain('--compressed'); + }); + // TODO: These tests/snapshots don't really do anything in Jest without // the corresponding popover opening. Should be switched to an E2E test instead describe.skip('popoverPlacement', () => { diff --git a/src/components/date_picker/date_picker.tsx b/src/components/date_picker/date_picker.tsx index 4c41d516553..5867a4224dc 100644 --- a/src/components/date_picker/date_picker.tsx +++ b/src/components/date_picker/date_picker.tsx @@ -72,9 +72,13 @@ interface EuiExtendedDatePickerProps dayClassName?: (date: Moment) => string | null; /** - * Makes the input full width + * Renders the input as full width */ fullWidth?: boolean; + /** + * Renders the input with compressed height and sizing + */ + compressed?: boolean; /** * ref for the ReactDatePicker instance @@ -147,6 +151,7 @@ export const EuiDatePicker: FunctionComponent = ({ adjustDateOnChange = true, calendarClassName, className, + compressed, controlOnly, customInput, dateFormat = euiDatePickerDefaultDateFormat, @@ -199,11 +204,12 @@ export const EuiDatePicker: FunctionComponent = ({ 'euiDatePicker', 'euiFieldText', numIconsClass, - { + !inline && { 'euiFieldText--fullWidth': fullWidth, 'euiFieldText-isLoading': isLoading, - 'euiFieldText--withIcon': !inline && showIcon, - 'euiFieldText--isClearable': !inline && selected && onClear, + 'euiFieldText--compressed': compressed, + 'euiFieldText--withIcon': showIcon, + 'euiFieldText--isClearable': selected && onClear, }, className ); @@ -288,7 +294,8 @@ export const EuiDatePicker: FunctionComponent = ({