diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c9cacc7047..376c6055d15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Added `onFocus` prop to `EuiComboBox` ([#1375](https://github.com/elastic/eui/pull/1375)) - Added `DisambiguateSet` and `ExclusiveUnion` utility types ([#1368](https://github.com/elastic/eui/pull/1368)) - Added `EuiSuperDatePicker` component ([#1351](https://github.com/elastic/eui/pull/1351)) +- Fixed up styles for `EuiSuperDatePicker` ([#1389](https://github.com/elastic/eui/pull/1389)) - Altered a few icons and added more: `crossInACircleFilled`, `editorRedo`, `editorUndo`, `grabHorizontal`, `minusInCircleFilled`, `plusInCircleFilled`, `sortable`, `starEmptySpace`, `starFilledSpace`, `starFilled`, `starMinusEmpty`, `starMinusFilled`, `starPlusEmpty`, `pinFilled` ([#1374](https://github.com/elastic/eui/pull/1374)) **Bug fixes** diff --git a/src/components/date_picker/super_date_picker/__snapshots__/super_date_picker.test.js.snap b/src/components/date_picker/super_date_picker/__snapshots__/super_date_picker.test.js.snap index 5147c25d067..ef2a7b9e8fd 100644 --- a/src/components/date_picker/super_date_picker/__snapshots__/super_date_picker.test.js.snap +++ b/src/components/date_picker/super_date_picker/__snapshots__/super_date_picker.test.js.snap @@ -86,42 +86,18 @@ exports[`EuiSuperDatePicker is rendered 1`] = ` isCustom={true} startDateControl={
} > - - Last 15 minutes - - - Show dates - + Last 15 minutes + + Show dates + + @@ -242,42 +218,18 @@ exports[`EuiSuperDatePicker isLoading 1`] = ` isCustom={true} startDateControl={
} > - - Last 15 minutes - - - Show dates - + Last 15 minutes + + Show dates + + diff --git a/src/components/date_picker/super_date_picker/_index.scss b/src/components/date_picker/super_date_picker/_index.scss index 6382670c4bf..87d6056d51a 100644 --- a/src/components/date_picker/super_date_picker/_index.scss +++ b/src/components/date_picker/super_date_picker/_index.scss @@ -1 +1,5 @@ +@import 'mixins'; + +@import 'date_popover/index'; +@import 'quick_select_popover/index'; @import 'super_date_picker'; diff --git a/src/components/date_picker/super_date_picker/_mixins.scss b/src/components/date_picker/super_date_picker/_mixins.scss new file mode 100644 index 00000000000..02db2c4fd55 --- /dev/null +++ b/src/components/date_picker/super_date_picker/_mixins.scss @@ -0,0 +1,10 @@ +@mixin euiSuperDatePickerText { + @include euiFormControlText; + display: block; + width: 100%; + padding: 0 $euiSizeS; + line-height: $euiFormControlHeight - 2px; + height: $euiFormControlHeight - 2px; + word-break: break-all; + transition: background $euiAnimSpeedFast ease-in; +} diff --git a/src/components/date_picker/super_date_picker/_super_date_picker.scss b/src/components/date_picker/super_date_picker/_super_date_picker.scss index 16bdde5cf33..cd9c89b5c5b 100644 --- a/src/components/date_picker/super_date_picker/_super_date_picker.scss +++ b/src/components/date_picker/super_date_picker/_super_date_picker.scss @@ -1,16 +1,7 @@ // sass-lint:disable no-important -.euiSuperDatePicker__quickSelectButton { - // Override prepend border since button already lives inside another prepend - border-right: none !important; - - .euiSuperDatePicker__quickSelectButtonText { - // Override specificity from universal and sibiling selectors - margin-right: $euiSizeXS !important; - } -} - -.euiSuperDatePicker.euiFormControlLayout { - max-width: 480px; +.euiSuperDatePicker { + // Allow it to always grow to fit the container since the default form max width is too small + max-width: 100% !important; > .euiFormControlLayout__childrenWrapper { flex: 1 1 100%; @@ -19,59 +10,28 @@ > .euiDatePickerRange { max-width: none; width: auto; - - // sass-lint:disable nesting-depth - .euiPopover__anchor { - display: block; - } } } } -.euiSuperDatePicker__dateText { - @include euiFormControlText; - display: block; - width: 100%; - padding: 0 $euiSizeS; - line-height: $euiFormControlHeight - 2px; - height: $euiFormControlHeight - 2px; - word-break: break-all; - transition: background $euiAnimSpeedFast ease-in; -} - -.euiSuperDatePicker__dateButton { - $backgroundColor: tintOrShade($euiColorSuccess, 90%, 70%); - $textColor: makeHighContrastColor($euiColorSuccess, $backgroundColor); +.euiSuperDatePicker__prettyFormat { + @include euiSuperDatePickerText; + display: flex; + justify-content: space-between; + text-align: left; - &-isSelected, - &-needsUpdating, &:hover, &:focus { - background-color: $backgroundColor; - } + text-decoration: none; - &-needsUpdating { - color: $textColor; - } - - &-isInvalid { - $backgroundColor: tintOrShade($euiColorDanger, 90%, 70%); - $textColor: makeHighContrastColor($euiColorDanger, $backgroundColor); - background-color: $backgroundColor; - color: $textColor; - } - - .euiFormControlLayout__prepend { - border: none; + .euiSuperDatePicker__prettyFormatLink { + text-decoration: underline; + } } } -.euiSuperDatePicker__dateButton--start { - text-align: right; -} - -.euiSuperDatePicker__dateButton--end { - text-align: left; +.euiSuperDatePicker__prettyFormatLink { + color: $euiLinkColor; } .euiSuperDatePicker__updateButton { @@ -79,13 +39,6 @@ min-width: $euiButtonMinWidth + ($euiSizeXS * 1.5); } -.euiSuperDatePicker__popoverSection { - @include euiScrollBar; - max-height: $euiSizeM * 11; - overflow: hidden; - overflow-y: auto; -} - @include euiBreakpoint('xs', 's') { .euiSuperDatePicker__updateButton { min-width: 0; diff --git a/src/components/date_picker/super_date_picker/date_popover/_date_popover_button.scss b/src/components/date_picker/super_date_picker/date_popover/_date_popover_button.scss new file mode 100644 index 00000000000..b779c68eccf --- /dev/null +++ b/src/components/date_picker/super_date_picker/date_popover/_date_popover_button.scss @@ -0,0 +1,36 @@ +.euiDatePopoverButton__popover .euiDatePopoverButton__popoverAnchor { + display: block; +} + +.euiDatePopoverButton { + @include euiSuperDatePickerText; + + $backgroundColor: tintOrShade($euiColorSuccess, 90%, 70%); + $textColor: makeHighContrastColor($euiColorSuccess, $backgroundColor); + + &-isSelected, + &-needsUpdating, + &:hover, + &:focus { + background-color: $backgroundColor; + } + + &-needsUpdating { + color: $textColor; + } + + &-isInvalid { + $backgroundColor: tintOrShade($euiColorDanger, 90%, 70%); + $textColor: makeHighContrastColor($euiColorDanger, $backgroundColor); + background-color: $backgroundColor; + color: $textColor; + } +} + +.euiDatePopoverButton--start { + text-align: right; +} + +.euiDatePopoverButton--end { + text-align: left; +} diff --git a/src/components/date_picker/super_date_picker/date_popover/_date_popover_content.scss b/src/components/date_picker/super_date_picker/date_popover/_date_popover_content.scss new file mode 100644 index 00000000000..ca1f42ecb23 --- /dev/null +++ b/src/components/date_picker/super_date_picker/date_popover/_date_popover_content.scss @@ -0,0 +1,8 @@ +.euiDatePopoverContent { + width: $euiFormMaxWidth; + max-width: 100%; +} + +.euiDatePopoverContent__padded { + padding: $euiSizeS; +} diff --git a/src/components/date_picker/super_date_picker/date_popover/_index.scss b/src/components/date_picker/super_date_picker/date_popover/_index.scss new file mode 100644 index 00000000000..d8a2dc7d5a5 --- /dev/null +++ b/src/components/date_picker/super_date_picker/date_popover/_index.scss @@ -0,0 +1,2 @@ +@import 'date_popover_button'; +@import 'date_popover_content'; diff --git a/src/components/date_picker/super_date_picker/date_popover/absolute_tab.js b/src/components/date_picker/super_date_picker/date_popover/absolute_tab.js index cd3c78fe4d4..352ca015852 100644 --- a/src/components/date_picker/super_date_picker/date_popover/absolute_tab.js +++ b/src/components/date_picker/super_date_picker/date_popover/absolute_tab.js @@ -48,7 +48,7 @@ export class EuiAbsoluteTab extends Component { render() { return ( -
+
diff --git a/src/components/date_picker/super_date_picker/date_popover/date_popover_button.js b/src/components/date_picker/super_date_picker/date_popover/date_popover_button.js index 6619aa81333..5080e931696 100644 --- a/src/components/date_picker/super_date_picker/date_popover/date_popover_button.js +++ b/src/components/date_picker/super_date_picker/date_popover/date_popover_button.js @@ -48,13 +48,12 @@ export class EuiDatePopoverButton extends Component { } = this.props; const classes = classNames([ - 'euiSuperDatePicker__dateText', - 'euiSuperDatePicker__dateButton', - `euiSuperDatePicker__dateButton--${position}`, + 'euiDatePopoverButton', + `euiDatePopoverButton--${position}`, { - 'euiSuperDatePicker__dateButton-isSelected': this.state.isOpen, - 'euiSuperDatePicker__dateButton-isInvalid': isInvalid, - 'euiSuperDatePicker__dateButton-needsUpdating': needsUpdating + 'euiDatePopoverButton-isSelected': this.state.isOpen, + 'euiDatePopoverButton-isInvalid': isInvalid, + 'euiDatePopoverButton-needsUpdating': needsUpdating } ]); @@ -79,10 +78,12 @@ export class EuiDatePopoverButton extends Component { return ( +

Setting the time to "Now" means that on every refresh this time will be set to the time of the refresh. @@ -76,6 +76,7 @@ export function EuiDatePopoverContent({ value, roundUp, onChange, dateFormat }) return ( + diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap b/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap index 95e30574a8e..12d0b8b97f2 100644 --- a/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap +++ b/src/components/date_picker/super_date_picker/quick_select_popover/__snapshots__/quick_select.test.js.snap @@ -191,17 +191,13 @@ exports[`EuiSuperDatePicker is rendered 1`] = ` hasEmptyLabelSpace={false} > Apply @@ -407,17 +403,13 @@ exports[`EuiSuperDatePicker prevQuickSelect 1`] = ` hasEmptyLabelSpace={false} > Apply diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/_index.scss b/src/components/date_picker/super_date_picker/quick_select_popover/_index.scss new file mode 100644 index 00000000000..4fc081c561d --- /dev/null +++ b/src/components/date_picker/super_date_picker/quick_select_popover/_index.scss @@ -0,0 +1,3 @@ +@import 'quick_select_popover'; +@import 'quick_select'; +@import 'refresh_interval'; diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/_quick_select.scss b/src/components/date_picker/super_date_picker/quick_select_popover/_quick_select.scss new file mode 100644 index 00000000000..4a5b8ed06f6 --- /dev/null +++ b/src/components/date_picker/super_date_picker/quick_select_popover/_quick_select.scss @@ -0,0 +1,5 @@ + +.euiQuickSelect__applyButton { + // Allow the button to shrink + min-width: 0; +} diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/_quick_select_popover.scss b/src/components/date_picker/super_date_picker/quick_select_popover/_quick_select_popover.scss new file mode 100644 index 00000000000..cbf1e8ee1ee --- /dev/null +++ b/src/components/date_picker/super_date_picker/quick_select_popover/_quick_select_popover.scss @@ -0,0 +1,17 @@ +.euiQuickSelectPopover__content { + width: $euiFormMaxWidth; + max-width: 100%; +} + +.euiQuickSelectPopover__section { + @include euiScrollBar; + max-height: $euiSizeM * 11; + overflow: hidden; + overflow-y: auto; +} + +// sass-lint:disable no-important +.euiQuickSelectPopover__buttonText { + // Override specificity from universal and sibiling selectors + margin-right: $euiSizeXS !important; +} diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/_refresh_interval.scss b/src/components/date_picker/super_date_picker/quick_select_popover/_refresh_interval.scss new file mode 100644 index 00000000000..e002eddc4ca --- /dev/null +++ b/src/components/date_picker/super_date_picker/quick_select_popover/_refresh_interval.scss @@ -0,0 +1,4 @@ +.euiRefreshInterval__startButton { + // Just enough to keep it the same size for "Start" and "Stop" + min-width: 90px; +} diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/commonly_used_time_ranges.js b/src/components/date_picker/super_date_picker/quick_select_popover/commonly_used_time_ranges.js index a80774719e4..5cd9a1edc07 100644 --- a/src/components/date_picker/super_date_picker/quick_select_popover/commonly_used_time_ranges.js +++ b/src/components/date_picker/super_date_picker/quick_select_popover/commonly_used_time_ranges.js @@ -31,7 +31,7 @@ export function EuiCommonlyUsedTimeRanges({ applyTime, commonlyUsedRanges }) { Commonly used - + {links} diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/quick_select.js b/src/components/date_picker/super_date_picker/quick_select_popover/quick_select.js index 3d06c1dfa9b..95462ff963e 100644 --- a/src/components/date_picker/super_date_picker/quick_select_popover/quick_select.js +++ b/src/components/date_picker/super_date_picker/quick_select_popover/quick_select.js @@ -166,9 +166,9 @@ export class EuiQuickSelect extends Component { Apply diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/quick_select_popover.js b/src/components/date_picker/super_date_picker/quick_select_popover/quick_select_popover.js index 889f5ba3f34..d4899d372da 100644 --- a/src/components/date_picker/super_date_picker/quick_select_popover/quick_select_popover.js +++ b/src/components/date_picker/super_date_picker/quick_select_popover/quick_select_popover.js @@ -52,8 +52,8 @@ export class EuiQuickSelectPopover extends Component { render() { const quickSelectButton = (

Recently used date ranges - + {links} diff --git a/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js b/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js index 59f741b060c..92ffa01bc8a 100644 --- a/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js +++ b/src/components/date_picker/super_date_picker/quick_select_popover/refresh_interval.js @@ -113,10 +113,10 @@ export class EuiRefreshInterval extends Component { diff --git a/src/components/date_picker/super_date_picker/super_date_picker.js b/src/components/date_picker/super_date_picker/super_date_picker.js index 97756ccd20b..641eb0d8bce 100644 --- a/src/components/date_picker/super_date_picker/super_date_picker.js +++ b/src/components/date_picker/super_date_picker/super_date_picker.js @@ -11,7 +11,7 @@ import { EuiDatePopoverButton } from './date_popover/date_popover_button'; import { EuiDatePickerRange } from '../date_picker_range'; import { EuiFormControlLayout } from '../../form'; -import { EuiButton, EuiButtonEmpty } from '../../button'; +import { EuiButton } from '../../button'; import { EuiFlexGroup, EuiFlexItem } from '../../flex'; import { EuiToolTip } from '../../tool_tip'; @@ -193,22 +193,14 @@ export class EuiSuperDatePicker extends Component { startDateControl={
} endDateControl={
} > - {prettyDuration(start, end, this.props.commonlyUsedRanges, this.props.dateFormat)} - - - Show dates - + Show dates + ); } @@ -248,10 +240,18 @@ export class EuiSuperDatePicker extends Component { if (this.state.hasChanged || this.props.isLoading) { buttonText = this.props.isLoading ? 'Updating' : 'Update'; } + + let tooltipContent; + if (this.state.isInvalid) { + tooltipContent = 'Can\'t update, dates are invalid'; + } else if (this.state.hasChanged && !this.props.isLoading) { + tooltipContent = 'Click to apply'; + } + return (