Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiDatePickerRange] Add support for compressed display #7058

Merged
merged 4 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src-docs/src/views/date_picker/range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default () => {

return (
/* DisplayToggles wrapper for Docs only */
<DisplayToggles canCompressed={false} canPrepend={true} canAppend={true}>
<DisplayToggles canPrepend={true} canAppend={true}>
<EuiDatePickerRange
startDateControl={
<EuiDatePicker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,79 @@ exports[`EuiDatePickerRange is rendered 1`] = `
</span>
`;

exports[`EuiDatePickerRange props compressed 1`] = `
<span
class="euiDatePickerRange emotion-euiDatePickerRange"
>
<div
class="euiFormControlLayout euiFormControlLayout--compressed euiFormControlLayoutDelimited"
>
<div
class="euiFormControlLayout__childrenWrapper"
>
<div
class="euiFormControlLayoutIcons euiFormControlLayoutIcons--left euiFormControlLayoutIcons--static"
>
<span
class="euiFormControlLayoutCustomIcon"
>
<span
aria-hidden="true"
class="euiFormControlLayoutCustomIcon__icon"
data-euiicon-type="calendar"
/>
</span>
</div>
<div
class="euiPopover emotion-euiPopover"
>
<div
class="euiPopover__anchor css-zih94u-render"
>
<div
class="react-datepicker__input-container"
>
<input
aria-label="Press the down key to open a popover containing a calendar."
class="euiDatePicker euiFieldText euiDatePickerRange__start euiFormControlLayoutDelimited__input"
type="text"
value=""
/>
</div>
</div>
</div>
<div
class="euiText euiFormControlLayoutDelimited__delimiter emotion-euiText-s-euiTextColor-subdued"
>
<span
data-euiicon-type="sortRight"
>
to
</span>
</div>
<div
class="euiPopover emotion-euiPopover"
>
<div
class="euiPopover__anchor css-zih94u-render"
>
<div
class="react-datepicker__input-container"
>
<input
aria-label="Press the down key to open a popover containing a calendar."
class="euiDatePicker euiFieldText euiDatePickerRange__end euiFormControlLayoutDelimited__input"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</div>
</span>
`;

exports[`EuiDatePickerRange props disabled 1`] = `
<span
class="euiDatePickerRange emotion-euiDatePickerRange"
Expand Down
12 changes: 12 additions & 0 deletions src/components/date_picker/date_picker_range.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ describe('EuiDatePickerRange', () => {
expect(container.firstChild).toMatchSnapshot();
});

test('compressed', () => {
const { container } = render(
<EuiDatePickerRange
startDateControl={<EuiDatePicker />}
endDateControl={<EuiDatePicker />}
compressed
/>
);

expect(container.firstChild).toMatchSnapshot();
});

test('readOnly', () => {
const { container } = render(
<EuiDatePickerRange
Expand Down
13 changes: 11 additions & 2 deletions src/components/date_picker/date_picker_range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ import { EuiDatePickerProps } from './date_picker';
export type EuiDatePickerRangeProps = CommonProps &
Pick<
EuiFormControlLayoutDelimitedProps,
'isLoading' | 'isInvalid' | 'readOnly' | 'fullWidth' | 'prepend' | 'append'
| 'isLoading'
| 'isInvalid'
| 'readOnly'
| 'fullWidth'
| 'compressed'
| 'prepend'
| 'append'
> & {
/**
* Including any children will replace all innards with the provided children
Expand Down Expand Up @@ -100,6 +106,7 @@ export const EuiDatePickerRange: FunctionComponent<EuiDatePickerRangeProps> = ({
inline,
shadow = true,
fullWidth: _fullWidth,
compressed: _compressed,
isCustom,
readOnly,
isLoading,
Expand All @@ -111,8 +118,9 @@ export const EuiDatePickerRange: FunctionComponent<EuiDatePickerRangeProps> = ({
prepend,
...rest
}) => {
// `fullWidth` should not affect inline datepickers (matches non-range behavior)
// `fullWidth` and `compressed` should not affect inline datepickers (matches non-range behavior)
const fullWidth = _fullWidth && !inline;
const compressed = _compressed && !inline;

const classes = classNames('euiDatePickerRange', className);

Expand Down Expand Up @@ -206,6 +214,7 @@ export const EuiDatePickerRange: FunctionComponent<EuiDatePickerRangeProps> = ({
startControl={startControl}
endControl={endControl}
fullWidth={fullWidth}
compressed={compressed}
readOnly={readOnly}
isDisabled={disabled}
isInvalid={isInvalid}
Expand Down
5 changes: 5 additions & 0 deletions upcoming_changelogs/7058.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Updated `EuiDatePickerRange` to support `compressed` display

**Bug fixes**

- Fixed `EuiSuperDatePicker`'s `compressed` display