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

React datepicker better responsive handling when inline #1820

Merged
merged 10 commits into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from 7 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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
- Fixed `EuiFlyout` scrolling in Safari ([#2033](https://github.com/elastic/eui/pull/2033))
- Fixed `EuiCallOut` header icon alignment ([#2006](https://github.com/elastic/eui/pull/2006))
- Fixed `EuiInMemoryTable` sort value persistence through lifecycle updates ([#2035](https://github.com/elastic/eui/pull/2035))
- Fixed responsive display of inline `EuiDatePicker` ([#1820](https://github.com/elastic/eui/pull/1820))
- Removed time from default `dateFormat` of `EuiDatePicker` ([#1820](https://github.com/elastic/eui/pull/1820))

**Breaking changes**

Expand Down
3 changes: 2 additions & 1 deletion src-docs/src/views/date_picker/time_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class extends Component {
showTimeSelect
selected={this.state.startDate}
onChange={this.handleChange}
dateFormat="MM/DD/YYYY HH:mm.ss.SSS"
dateFormat="MM/DD/YYYY HH:mm A"
/>
</EuiFormRow>

Expand Down Expand Up @@ -69,6 +69,7 @@ export default class extends Component {
selected={this.state.startDate}
onChange={this.handleChange}
dateFormat="hh:mm a"
timeFormat="hh:mm a"
injectTimes={[
moment()
.hours(0)
Expand Down
4 changes: 2 additions & 2 deletions src-docs/src/views/horizontal_rule/horizontal_rule_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import HorizontalRuleMargin from './horizontal_rule_margin';
const horizontalRuleMarginSource = require('!!raw-loader!./horizontal_rule_margin');
const horizontalRuleMarginHtml = renderToHtml(HorizontalRuleMargin);

const horizontalRuleSnippet = `<EuiHorizontalRule size="quarter" />`;
const horizontalRuleMarginSnippet = `<EuiHorizontalRule margin="xs" />`;
const horizontalRuleSnippet = '<EuiHorizontalRule size="quarter" />';
const horizontalRuleMarginSnippet = '<EuiHorizontalRule margin="xs" />';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linter forced me to change these


export const HorizontalRuleExample = {
title: 'Horizontal Rule',
Expand Down
2 changes: 1 addition & 1 deletion src-docs/src/views/spacer/spacer_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Spacer from './spacer';
const spacerSource = require('!!raw-loader!./spacer');
const spacerHtml = renderToHtml(Spacer);

const spacerSnippet = `<EuiSpacer size="xs" />`;
const spacerSnippet = '<EuiSpacer size="xs" />';

export const SpacerExample = {
title: 'Spacer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exports[`EuiDatePicker is rendered 1`] = `
aria-label="aria-label"
className="euiDatePicker euiFieldText euiFieldText--withIcon testClass1 testClass2"
data-test-subj="test subject string"
dateFormat="MM/DD/YYYY hh:mm A"
dateFormat="MM/DD/YYYY"
dateFormatCalendar="MMMM YYYY"
disabled={false}
disabledKeyboardNavigation={false}
Expand Down
12 changes: 10 additions & 2 deletions src/components/date_picker/_date_picker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
&--next {
@include datePicker__arrow;
// Pixel value because of some padding on the icon
right: 10px;
right: 20px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aligned this value with the one for previous:

before:

height: $euiSize;
width: $euiSize;
transform: rotate(-90deg);
Expand Down Expand Up @@ -635,7 +635,7 @@
.react-datepicker__month--accessible:focus {
background: $euiFocusBackgroundColor;

.react-datepicker__day--in-range {
.react-datepicker__day--in-range:not(.react-datepicker__day--selected) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes this issue:

Screen Shot 2019-06-14 at 11 28 19 AM

now:

border-top-color: $euiFocusBackgroundColor;
border-bottom-color: $euiFocusBackgroundColor;
}
Expand All @@ -661,6 +661,14 @@

// We drop the time picker on mobile. They can still type in the time directly.
@include euiBreakpoint('xs','s') {

// This resizes EUI's normal form control to be the width of the calendar
.euiDatePicker--inline {
max-width: $euiDatePickerCalendarWidth;
display: block;
}

// This hides the time entirely
.react-datepicker__time-container {
display: none;
}
Expand Down
1 change: 1 addition & 0 deletions src/components/date_picker/_index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Uses some form mixins
@import 'variables';
@import 'date_picker';
@import 'date_picker_range';
@import 'super_date_picker/index';
1 change: 1 addition & 0 deletions src/components/date_picker/_variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$euiDatePickerCalendarWidth: 284px;
3 changes: 2 additions & 1 deletion src/components/date_picker/date_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,12 @@ EuiDatePicker.propTypes = {

EuiDatePicker.defaultProps = {
adjustDateOnChange: true,
dateFormat: 'MM/DD/YYYY hh:mm A',
dateFormat: 'MM/DD/YYYY',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't make sense that the default date format would show time when by default, showTimeSelect is false. So I removed the time format just from this default value.

fullWidth: false,
isLoading: false,
shadow: true,
shouldCloseOnSelect: true,
showIcon: true,
showTimeSelect: false,
timeFormat: 'hh:mm A',
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@
.euiDatePopoverContent__padded--large {
padding: $euiSize;
}

@include euiBreakpoint('xs', 's') {
.euiDatePopoverContent {
// Small screens drop the time selector
width: $euiDatePickerCalendarWidth;
}
}