diff --git a/packages/dnb-eufemia/src/components/date-picker/__tests__/__snapshots__/DatePicker.test.tsx.snap b/packages/dnb-eufemia/src/components/date-picker/__tests__/__snapshots__/DatePicker.test.tsx.snap index 300ea033dcd0..50e2329711ec 100644 --- a/packages/dnb-eufemia/src/components/date-picker/__tests__/__snapshots__/DatePicker.test.tsx.snap +++ b/packages/dnb-eufemia/src/components/date-picker/__tests__/__snapshots__/DatePicker.test.tsx.snap @@ -2137,6 +2137,14 @@ html:not([data-whatinput=touch]) .dnb-date-picker__container table.dnb-no-focus: background-color: transparent; } } +html:not([data-whatintent=mouse]) .dnb-date-picker__day--within-selection:not(.dnb-date-picker__day--start-date):not(.dnb-date-picker__day--end-date) .dnb-button:not(:active):not(:focus-visible) { + background-color: transparent; +} +@supports not (selector(:focus-visible)) { + html:not([data-whatintent=mouse]) .dnb-date-picker__day--within-selection:not(.dnb-date-picker__day--start-date):not(.dnb-date-picker__day--end-date) .dnb-button:not(:active) { + background-color: transparent; + } +} .dnb-date-picker__day--preview:not(.dnb-date-picker__day--inactive):not(.dnb-date-picker__day--outside-month):not(.dnb-date-picker__day--start-date):not(.dnb-date-picker__day--end-date), .dnb-date-picker__day--within-selection:not(.dnb-date-picker__day--inactive):not(.dnb-date-picker__day--outside-month):not(.dnb-date-picker__day--start-date):not(.dnb-date-picker__day--end-date) { background-color: var(--token-color-background-action-hover-subtle); } @@ -2150,13 +2158,15 @@ html:not([data-whatinput=touch]) .dnb-date-picker__container table.dnb-no-focus: .dnb-date-picker__day--start-date:not(.dnb-date-picker__day--inactive):not(.dnb-date-picker__day--outside-month):not(.dnb-date-picker__day--preview) .dnb-button:hover, .dnb-date-picker__day--end-date:not(.dnb-date-picker__day--inactive):not(.dnb-date-picker__day--outside-month):not(.dnb-date-picker__day--preview) .dnb-button:hover { box-shadow: none; } -html:not([data-whatintent=touch]) .dnb-date-picker__day--within-selection:not(.dnb-date-picker__day--start-date):not(.dnb-date-picker__day--end-date) .dnb-button:hover:not([disabled]), html:not([data-whatintent=touch]) .dnb-date-picker__day--start-date.dnb-date-picker__day--within-selection .dnb-button:hover:not([disabled]), html:not([data-whatintent=touch]) .dnb-date-picker__day--end-date.dnb-date-picker__day--within-selection .dnb-button:hover:not([disabled]) { - color: var(--token-color-text-action); - background-color: var(--token-color-background-neutral); - --border-color: var(--token-color-stroke-action-pressed); - --border-width: 0.125rem; - box-shadow: 0 0 0 var(--border-width) var(--border-color); - border-color: transparent; +@media (any-hover: hover) { + html:not([data-whatintent=touch], [data-whatintent=keyboard]) .dnb-date-picker__day--within-selection:not(.dnb-date-picker__day--start-date):not(.dnb-date-picker__day--end-date) .dnb-button:hover:not([disabled]), html:not([data-whatintent=touch], [data-whatintent=keyboard]) .dnb-date-picker__day--start-date.dnb-date-picker__day--within-selection .dnb-button:hover:not([disabled]), html:not([data-whatintent=touch], [data-whatintent=keyboard]) .dnb-date-picker__day--end-date.dnb-date-picker__day--within-selection .dnb-button:hover:not([disabled]) { + color: var(--token-color-text-action); + background-color: var(--token-color-background-neutral); + --border-color: var(--token-color-stroke-action-pressed); + --border-width: 0.125rem; + box-shadow: 0 0 0 var(--border-width) var(--border-color); + border-color: transparent; + } } html:not([data-whatintent=touch]) .dnb-date-picker__day--within-selection:not(.dnb-date-picker__day--start-date):not(.dnb-date-picker__day--end-date) .dnb-button:active:not([disabled]), html:not([data-whatintent=touch]) .dnb-date-picker__day--start-date.dnb-date-picker__day--within-selection .dnb-button:active:not([disabled]), html:not([data-whatintent=touch]) .dnb-date-picker__day--end-date.dnb-date-picker__day--within-selection .dnb-button:active:not([disabled]) { color: var(--token-color-text-action-pressed); @@ -2197,13 +2207,23 @@ html:not([data-whatintent=touch]) .dnb-date-picker__day--inactive .dnb-button[di box-shadow: none; } } -.dnb-date-picker__header__nav .dnb-button:hover:not(:active):not(:focus-visible) { - background-color: var(--token-color-background-neutral); +html:not([data-whatintent=mouse]) .dnb-date-picker__header__nav .dnb-button:not(:active):not(:focus-visible) { + box-shadow: none; } @supports not (selector(:focus-visible)) { - .dnb-date-picker__header__nav .dnb-button:hover:not(:active) { + html:not([data-whatintent=mouse]) .dnb-date-picker__header__nav .dnb-button:not(:active) { + box-shadow: none; + } +} +@media (any-hover: hover) { + html:not([data-whatintent=touch], [data-whatintent=keyboard]) .dnb-date-picker__header__nav .dnb-button:hover:not(:active):not(:focus-visible) { background-color: var(--token-color-background-neutral); } + @supports not (selector(:focus-visible)) { + html:not([data-whatintent=touch], [data-whatintent=keyboard]) .dnb-date-picker__header__nav .dnb-button:hover:not(:active) { + background-color: var(--token-color-background-neutral); + } + } } .dnb-date-picker .rtl { direction: rtl; diff --git a/packages/dnb-eufemia/src/components/date-picker/style/dnb-date-picker.scss b/packages/dnb-eufemia/src/components/date-picker/style/dnb-date-picker.scss index 7ce1a5a40ed1..71d8f5b8ca48 100644 --- a/packages/dnb-eufemia/src/components/date-picker/style/dnb-date-picker.scss +++ b/packages/dnb-eufemia/src/components/date-picker/style/dnb-date-picker.scss @@ -425,6 +425,15 @@ } } + // Touch browsers keep :hover on the last tapped element + html:not([data-whatintent='mouse']) + &--within-selection:not(#{&}--start-date):not(#{&}--end-date) + .dnb-button:not(:active) { + @include utilities.notFocusVisible() { + background-color: transparent; + } + } + &--preview:not(#{&}--inactive):not(#{&}--outside-month):not( #{&}--start-date ):not(#{&}--end-date), @@ -463,22 +472,24 @@ } // Hover states for checked date buttons - html:not([data-whatintent='touch']) - &--within-selection:not(#{&}--start-date):not(#{&}--end-date) - .dnb-button:hover:not([disabled]), - html:not([data-whatintent='touch']) - &--start-date#{&}--within-selection - .dnb-button:hover:not([disabled]), - html:not([data-whatintent='touch']) - &--end-date#{&}--within-selection - .dnb-button:hover:not([disabled]) { - color: var(--token-color-text-action); - background-color: var(--token-color-background-neutral); + @media (any-hover: hover) { + html:not([data-whatintent='touch'], [data-whatintent='keyboard']) + &--within-selection:not(#{&}--start-date):not(#{&}--end-date) + .dnb-button:hover:not([disabled]), + html:not([data-whatintent='touch'], [data-whatintent='keyboard']) + &--start-date#{&}--within-selection + .dnb-button:hover:not([disabled]), + html:not([data-whatintent='touch'], [data-whatintent='keyboard']) + &--end-date#{&}--within-selection + .dnb-button:hover:not([disabled]) { + color: var(--token-color-text-action); + background-color: var(--token-color-background-neutral); - @include utilities.fakeBorder( - var(--token-color-stroke-action-pressed), - 0.125rem - ); + @include utilities.fakeBorder( + var(--token-color-stroke-action-pressed), + 0.125rem + ); + } } // Active states for selected date buttons @@ -545,9 +556,22 @@ box-shadow: none; } } - .dnb-button:hover:not(:active) { + + // Touch browsers keep :hover on the last tapped element, so style a + // tapped button like one without the mouse over it + html:not([data-whatintent='mouse']) & .dnb-button:not(:active) { @include utilities.notFocusVisible() { - background-color: var(--token-color-background-neutral); + box-shadow: none; + } + } + + @media (any-hover: hover) { + html:not([data-whatintent='touch'], [data-whatintent='keyboard']) + & + .dnb-button:hover:not(:active) { + @include utilities.notFocusVisible() { + background-color: var(--token-color-background-neutral); + } } } }