/*! * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. * * Modifications Copyright OpenSearch Contributors. See * GitHub history for details. */ /* This file is a heavy retheme of react-datepicker's Sass as of v1.4.0 ** https://github.com/Hacker0x01/react-datepicker ** ** In places where features were disabled, I've commented out the original Sass ** selectors rather than removing it so we can better understand what's changed. ** Commented out selectors that don't have properties indicate that we are not ** using those dom elements for styling of any kind. For example, react-datepicker ** has lots of pointer arrows attached to its popovers, but we choose not to render ** then in any way. ** ** Similarly, you will also find several times where we use display: none to ** completely remove extraneous UI (they had some overly obvious legends for example). */ // Because we don't have control over react-datepicker's dom we use SVG URIs for the navigation arrows. // There is one for light and dark. @mixin datePicker__arrow { background-position: center; @if (lightness($ouiColorEmptyShade) > 50) { background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiI+ICA8ZGVmcz4gICAgPHBhdGggaWQ9ImFycm93X2Rvd24tYSIgZD0iTTEzLjA2ODg1MDgsNS4xNTcyNTAzOCBMOC4zODQyMzk3NSw5Ljc2ODI3NDI4IEM4LjE3MDU0NDE1LDkuOTc4NjEzMDggNy44Mjk5OTIxNCw5Ljk3OTE0MDk1IDcuNjE1NzYwMjUsOS43NjgyNzQyOCBMMi45MzExNDkxNSw1LjE1NzI1MDM4IEMyLjcxODEzNTksNC45NDc1ODMyMSAyLjM3Mjc3MzE5LDQuOTQ3NTgzMjEgMi4xNTk3NTk5NCw1LjE1NzI1MDM4IEMxLjk0Njc0NjY5LDUuMzY2OTE3NTYgMS45NDY3NDY2OSw1LjcwNjg1NTIyIDIuMTU5NzU5OTQsNS45MTY1MjI0IEw2Ljg0NDM3MTA0LDEwL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LDUuOTE2NTIyNCBMNi44NDQzNzEwNCwxMC41Mjc1NDYzIEM3LjQ4NTE3NDI0LDExLjE1ODI4MzYgOC41MTY0NDk3OSwxMS4xNTY2ODUxIDkuMTU1NjI4OTYsMTAuNTI3NTQ2MyBMMTMuODQwMjQwMSw1LjkxNjUyMjQgQzE0LjA1MzI1MzMsNS43MDY4NTUyMiAxNC4wNTMyNTMzLDUuMzY2OTE3NTYgMTMuODQwMjQwMSw1LjE1NzI1MDM4IEMxMy42MjcyMjY4LDQuOTQ3NTgzMjEgMTMuMjgxODY0MSw0Ljk0NzU4MzIxIDEzLjA2ODg1MDgsNS4xNTcyNTAzOCBaIi8+ICA8L2RlZnM+ICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPiAgICA8dXNlIGZpbGw9IiNGRkYiIGZpbGwtcnVsZT0ibm9uemVybyIgeGxpbms6aHJlZj0iI2Rvd25hcnJvd3doaXRlLWEiLz4gIDwvZz48L3N2Zz4=); } } // The only "new" css in this component is a wrapper class for dealing with shadows. // This is mostly here so that we can provide an inline version that doesn't have the // shadows and depth. .ouiDatePicker { .ouiFormControlLayout { height: auto; } &.ouiDatePicker--shadow { .react-datepicker-popper { @include ouiBottomShadowMedium; border: $ouiBorderThin; background-color: $ouiColorEmptyShade; border-radius: 0 0 $ouiBorderRadius $ouiBorderRadius; } // If the shadow is on, and it is inline, we need to put the shadow on the datepicker // itself rather than the popper. &.ouiDatePicker--inline { .react-datepicker { @include ouiBottomShadowMedium; border: $ouiBorderThin; background-color: $ouiColorEmptyShade; border-radius: $ouiBorderRadius; } } } } // .react-datepicker-wrapper { // } .react-datepicker { @include ouiFont; font-size: $ouiFontSizeXS; color: $ouiColorFullShade; display: flex; position: relative; border-radius: $ouiBorderRadius; } // When in time only mode we make the dropdown look more like the combo box styling. .react-datepicker--time-only { .react-datepicker__time-container { .react-datepicker__time { .react-datepicker__time-box { width: 100%; .react-datepicker__time-list li.react-datepicker__time-list-item { font-size: $ouiFontSizeS; text-align: left; padding-left: $ouiSizeXL + $ouiSizeXS; padding-right: $ouiSizeXL + $ouiSizeXS; color: $ouiTextColor; &.react-datepicker__time-list-item--selected { color: $ouiColorGhost; } &.react-datepicker__time-list-item--disabled{ color: $ouiColorDisabledText } } } } } .react-datepicker__time-container { border-left: 0; } // .react-datepicker__triangle { // } // .react-datepicker__time { // } // .react-datepicker__time-box { // } } // .react-datepicker__triangle { // } .ouiDatePicker.ouiDatePicker--shadow .react-datepicker-popper { z-index: $ouiZContentMenu; animation: ouiAnimFadeIn $ouiAnimSpeedFast ease-in; &[data-placement^="bottom"] { // .react-datepicker__triangle { // } } &[data-placement^="top"] { @include ouiBottomShadowFlat; border-radius: $ouiBorderRadius $ouiBorderRadius 0 0; // .react-datepicker__triangle { // } } &[data-placement^="right"] { margin-left: 0; // .react-datepicker__triangle { // } } &[data-placement^="left"] { margin-right: 0; // .react-datepicker__triangle { // } } } .react-datepicker__header { text-align: center; border-top-left-radius: $ouiBorderRadius; border-top-right-radius: $ouiBorderRadius; &--time { display: none; } } .react-datepicker__header__dropdown { padding: $ouiSize 0 $ouiSizeS 0; } .react-datepicker__year-dropdown-container--select, .react-datepicker__month-dropdown-container--select, .react-datepicker__month-year-dropdown-container--select, .react-datepicker__year-dropdown-container--scroll, .react-datepicker__month-dropdown-container--scroll, .react-datepicker__month-year-dropdown-container--scroll { display: inline-block; margin: 0 $ouiSizeXS; } .react-datepicker__current-month, .react-datepicker-time__header { display: none; } .react-datepicker-time__header { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; } .react-datepicker__navigation { cursor: pointer; position: absolute; // Pixel pushing because these are icons against text top: $ouiSize + ($ouiSizeXS / 2); width: 0; padding: 0; z-index: 1; text-indent: -999em; overflow: hidden; &--previous { @include datePicker__arrow; left: $ouiSize + $ouiSizeXS; height: $ouiSize; width: $ouiSize; transform: rotate(90deg); transition: transform $ouiAnimSpeedExtraFast ease-in-out; &:hover, &:focus { border-radius: $ouiBorderRadius; transform: scale(1.2) rotate(90deg); } &:hover { background-color: $ouiColorLightestShade; box-shadow: 0 0 0 ($ouiSizeXS / 2) $ouiColorLightestShade; } &:focus { background-color: $ouiFocusBackgroundColor; box-shadow: 0 0 0 ($ouiSizeXS / 2) $ouiFocusBackgroundColor; } &--disabled, &--disabled:hover { cursor: not-allowed ; opacity: .2; } } &--next { @include datePicker__arrow; // Pixel value because of some padding on the icon right: 20px; height: $ouiSize; width: $ouiSize; transform: rotate(-90deg); &--with-time:not(&--with-today-button) { // This a pixel value against the width of the cal. It needs // to be left because the timepicker adds more width left: 248px; } &:hover, &:focus { border-radius: $ouiBorderRadius; transform: scale(1.2) rotate(-90deg); } &:hover { background-color: $ouiColorLightestShade; box-shadow: 0 0 0 ($ouiSizeXS / 2) $ouiColorLightestShade; } &:focus { background-color: $ouiFocusBackgroundColor; box-shadow: 0 0 0 ($ouiSizeXS / 2) $ouiFocusBackgroundColor; } &--disabled, &--disabled:hover { cursor: not-allowed ; opacity: .2; } } &--years { position: relative; top: 0; display: block; margin-left: auto; margin-right: auto; &-previous { top: $ouiSizeXS; border-top-color: $ouiColorLightestShade; &:hover { border-top-color: darken($ouiColorLightestShade, 10%); } } &-upcoming { top: -$ouiSizeXS; border-bottom-color: $ouiColorLightestShade; &:hover { border-bottom-color: darken($ouiColorLightestShade, 10%); } } } } // .react-datepicker__month-container { // } .react-datepicker__month { margin: 0 $ouiSize $ouiSize $ouiSize; text-align: center; border-radius: $ouiBorderRadius; } .react-datepicker__time-container { border-left: $ouiBorderColor; width: auto; display: flex; padding: $ouiSize 0; border-radius: 0 $ouiBorderRadius $ouiBorderRadius 0; flex-grow: 1; // &--with-today-button { // } .react-datepicker__time { position: relative; flex-grow: 1; display: flex; padding-left: $ouiSizeXS; flex-direction: column; .react-datepicker__time-box { width: auto; display: flex; flex-direction: column; flex-grow: 1; ul.react-datepicker__time-list { @include ouiScrollBar; height: 204px !important; display: flex; flex-direction: column; flex-grow: 1; overflow-y: auto; align-items: center; li.react-datepicker__time-list-item { padding: $ouiSizeXS $ouiSizeS; margin-bottom: $ouiSizeXS; text-align: right; color: $ouiColorDarkShade; white-space: nowrap; // IE needs this to fix collapsing flex line-height: $ouiSizeM; &:hover, &:focus { cursor: pointer; text-decoration: underline; } &--selected { background-color: $ouiColorPrimary; color: white; border-radius: $ouiBorderRadius / 2; &:hover { background-color: $ouiColorPrimary; } } &--disabled { color: $ouiColorLightShade; &:hover { cursor: not-allowed; text-decoration: none; background-color: transparent; } } } } } } } .react-datepicker__week-number { color: $ouiColorLightestShade; display: inline-block; width: $ouiSizeXL; line-height: $ouiSizeXL - $ouiSizeXS; text-align: center; margin: 0 $ouiSizeXS; &.react-datepicker__week-number--clickable { cursor: pointer; &:hover { border-radius: $ouiBorderRadius; background-color: $ouiColorEmptyShade; } } } .react-datepicker__day-names, .react-datepicker__week { white-space: nowrap; } .react-datepicker__day-name, .react-datepicker__day, .react-datepicker__time-name { color: $ouiColorFullShade; display: inline-block; width: $ouiSizeXL; line-height: $ouiSizeXL - $ouiSizeXS; text-align: center; margin: 0 $ouiSizeXS / 2; } .react-datepicker__day-name { color: $ouiColorDarkShade; text-transform: uppercase; } .react-datepicker__day { cursor: pointer; border: solid 2px transparent; transition: transform $ouiAnimSpeedExtraFast ease-in-out; &:hover:not(&--disabled) { text-decoration: underline; font-weight: $ouiFontWeightBold; transform: scale(1.2); } &--today { font-weight: bold; color: $ouiColorPrimary; } &--outside-month { color: $ouiColorDarkShade; } &--highlighted { border-radius: $ouiBorderRadius; background-color: $ouiColorSecondary; color: $ouiColorGhost; &:hover { background-color: darken($ouiColorSecondary, 5%); } } &--in-range { background-color: transparentize($ouiColorPrimary, .9); color: $ouiColorFullShade; border-radius: 0; border-top: solid 6px $ouiColorEmptyShade; border-bottom: solid 6px $ouiColorEmptyShade; border-right: none; border-left: none; line-height: $ouiSizeL - $ouiSizeXS; } &--selected, &--in-selecting-range { height: $ouiSizeXL; margin: 0 $ouiSizeXS / 2; border-radius: $ouiBorderRadius; background-color: $ouiColorPrimary; line-height: $ouiSizeL + $ouiSizeXS; border: solid $ouiSizeXS / 2 $ouiColorPrimary; color: $ouiColorGhost; &:hover { background-color: darken($ouiColorPrimary, 5%); } } &--keyboard-selected { border-radius: $ouiBorderRadius; border: solid $ouiSizeXS / 2 $ouiColorPrimary; font-weight: $ouiFontWeightBold; &:hover { background-color: darken($ouiColorPrimary, 5%); color: $ouiColorGhost; } } &--in-selecting-range:not(&--in-range) { background-color: rgba($ouiColorPrimary, 0.5); } &--in-range:not(&--in-selecting-range) { .react-datepicker__month--selecting-range & { background-color: $ouiColorEmptyShade; color: $ouiColorFullShade; } } &--disabled { cursor: not-allowed; color: $ouiColorLightShade; &:hover { background-color: transparent; } } } .react-datepicker__input-container { position: relative; } .react-datepicker__year-read-view { font-weight: $ouiFontWeightLight; color: $ouiColorDarkShade; } .react-datepicker__month-read-view { font-weight: $ouiFontWeightMedium; } .react-datepicker__year-read-view, .react-datepicker__month-read-view, .react-datepicker__month-year-read-view { font-size: $ouiFontSizeL; &:hover { cursor: pointer; color: $ouiColorPrimary; .react-datepicker__year-read-view--down-arrow, .react-datepicker__month-read-view--down-arrow { border-top-color: darken($ouiColorLightestShade, 10%); } } &--down-arrow { display: none; } } .react-datepicker__year-dropdown, .react-datepicker__month-dropdown, .react-datepicker__month-year-dropdown { background-color: $ouiColorEmptyShade; position: absolute; width: 100%; height: 100%; left: 0; top: 0; bottom: 0; right: 0; z-index: 1; text-align: center; border-radius: $ouiBorderRadius; display: flex; flex-wrap: wrap; animation: ouiAnimFadeIn $ouiAnimSpeedFast ease-in; align-content: space-around; align-items: center; padding: $ouiSizeS; &:hover { cursor: pointer; } // &--scrollable { // height: 150px; // overflow-y: scroll; // } } // Strike that, reverse it Willy Wonka style .react-datepicker__year-dropdown { flex-wrap: wrap-reverse; flex-direction: row-reverse; justify-content: flex-end; } .react-datepicker__year-option { &:first-of-type, &:last-of-type { display: none; } } .react-datepicker__year-option, .react-datepicker__month-option, .react-datepicker__month-year-option { font-size: $ouiFontSizeXS; padding: $ouiSizeS; color: $ouiColorDarkestShade; flex-basis: 33.3%; &:first-of-type { border-top-left-radius: $ouiBorderRadius; border-top-right-radius: $ouiBorderRadius; } &:last-of-type { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; border-bottom-left-radius: $ouiBorderRadius; border-bottom-right-radius: $ouiBorderRadius; } &:hover { background-color: $ouiColorLightestShade; .react-datepicker__navigation--years-upcoming { border-bottom-color: darken($ouiColorLightestShade, 10%); } .react-datepicker__navigation--years-previous { border-top-color: darken($ouiColorLightestShade, 10%); } } &--selected { display: none; } } .react-datepicker__screenReaderOnly { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; } .react-datepicker__year-option--preselected, .react-datepicker__month-option--preselected { background: $ouiFocusBackgroundColor; } .react-datepicker__year-option--selected_year.react-datepicker__year-option--preselected, .react-datepicker__month-option--selected_month.react-datepicker__month-option--preselected{ background: $ouiColorPrimary; } .react-datepicker__time-list-item--preselected, .react-datepicker__year-option--preselected, .react-datepicker__month-option--preselected { background: darken($ouiFocusBackgroundColor, 5%); } .react-datepicker__time-container--focus { background: $ouiFocusBackgroundColor; } .react-datepicker__month-read-view:focus, .react-datepicker__year-read-view:focus { text-decoration: underline; } .react-datepicker__month--accessible:focus { background: $ouiFocusBackgroundColor; .react-datepicker__day--in-range:not(.react-datepicker__day--selected) { border-top-color: $ouiFocusBackgroundColor; border-bottom-color: $ouiFocusBackgroundColor; } } .react-datepicker__navigation:focus { background-color: $ouiFocusBackgroundColor; } // These selectors are not a typo. react-datepicker has a bug where these selectors // output as "--selected_year". Sass has trouble compiling .--selected_year, so instead // we use this generic selector get around it. .react-datepicker__year-option--selected_year, .react-datepicker__month-option--selected_month { background: $ouiColorPrimary; color: $ouiColorEmptyShade; font-weight: $ouiFontWeightBold; border-radius: $ouiBorderRadius; } .react-datepicker__focusTrap { display: flex; } // The below is for the portal version of react-datepicker which we do not use. // It is shown here just to know what their baseline includes. // .react-datepicker__close-icon { // background-color: transparent; // border: 0; // cursor: pointer; // display: inline-block; // height: 0; // outline: 0; // padding: 0; // vertical-align: middle; // // &::after { // background-color: $ouiColorPrimary; // border-radius: 50%; // bottom: 0; // box-sizing: border-box; // color: #fff; // content: "\00d7"; // cursor: pointer; // font-size: 12px; // height: 16px; // width: 16px; // line-height: 1; // margin: -8px auto 0; // padding: 2px; // position: absolute; // right: 7px; // text-align: center; // top: 50%; // } // } // // .react-datepicker__today-button { // background: $ouiColorEmptyShade; // border-top: 1px solid $ouiBorderColor; // cursor: pointer; // text-align: center; // font-weight: bold; // padding: 5px 0; // clear: left; // } // // .react-datepicker__portal { // position: fixed; // width: 100vw; // height: 100vh; // background-color: rgba(0, 0, 0, 0.8); // left: 0; // top: 0; // justify-content: center; // align-items: center; // display: flex; // z-index: 2147483647; // // .react-datepicker__day-name, // .react-datepicker__day, // .react-datepicker__time-name { // width: 3rem; // line-height: 3rem; // } // // // Resize for small screens // @media (max-width: 400px), (max-height: 550px) { // .react-datepicker__day-name, // .react-datepicker__day, // .react-datepicker__time-name { // width: 2rem; // line-height: 2rem; // } // } // // .react-datepicker__current-month, // .react-datepicker-time__header { // font-size: $ouiFontSizeXS * 1.8; // } // // .react-datepicker__navigation { // border: 1.8 * $ouiSize solid transparent; // } // // .react-datepicker__navigation--previous { // border-right-color: $ouiColorLightestShade; // // &:hover { // border-right-color: darken($ouiColorLightestShade, 10%); // } // // &--disabled, // &--disabled:hover { // border-right-color: $datepicker__navigation-disabled-color; // cursor: default; // } // } // // .react-datepicker__navigation--next { // border-left-color: $ouiColorLightestShade; // // &:hover { // border-left-color: darken($ouiColorLightestShade, 10%); // } // // &--disabled, // &--disabled:hover { // border-left-color: $datepicker__navigation-disabled-color; // cursor: default; // } // } // }