Skip to content

Commit

Permalink
fix: enhance scrollbar appearance (#2046)
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed May 31, 2023
1 parent adc0e47 commit 237331a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1396,10 +1396,9 @@ exports[`Tabs scss have to match snapshot 1`] = `
flex: 0 1 auto;
overflow-x: auto;
overscroll-behavior: contain;
scrollbar-width: thin;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: auto;
scrollbar-color: var(--color-sea-green) transparent;
scrollbar-color: var(--scrollbar-thumb-color, #888) transparent;
/* Hide scrollbar for Chrome, Safari */
/* stylelint-disable-next-line */
-ms-overflow-style: none; /* IE and Edge */
Expand All @@ -1418,20 +1417,21 @@ html:not([data-visual-test]) .dnb-tabs__tabs__tablist {
}
@supports not (scrollbar-color: auto) {
.dnb-tabs__tabs__tablist::-webkit-scrollbar {
background-color: var(--color-black-8);
border-radius: var(--scrollbar-thumb-width, 0.5rem);
background-color: var(--scrollbar-track-color, #eee);
}
.dnb-tabs__tabs__tablist::-webkit-scrollbar:vertical {
width: 0.5rem;
width: var(--scrollbar-track-width, 0.5rem);
}
.dnb-tabs__tabs__tablist::-webkit-scrollbar:horizontal {
height: 0.5rem;
height: var(--scrollbar-track-width, 0.5rem);
}
.dnb-tabs__tabs__tablist::-webkit-scrollbar-thumb {
background-color: var(--color-sea-green);
border-radius: 0.5rem;
background-color: var(--scrollbar-thumb-color, #888);
border-radius: var(--scrollbar-thumb-width, 0.5rem);
}
.dnb-tabs__tabs__tablist::-webkit-scrollbar-thumb:hover {
background-color: var(--color-emerald-green);
background-color: var(--scrollbar-thumb-hover-color, #666);
}
}
.dnb-tabs__tabs__tablist::-webkit-scrollbar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,9 @@ exports[`Textarea scss have to match default theme snapshot 1`] = `
background-color: var(--color-white);
overflow-y: auto;
overscroll-behavior: contain;
scrollbar-width: thin;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: auto;
scrollbar-color: var(--color-sea-green) transparent;
scrollbar-color: var(--scrollbar-thumb-color, #888) transparent;
}
.dnb-textarea__textarea ::selection {
background-color: var(--color-mint-green);
Expand All @@ -174,20 +173,21 @@ html:not([data-visual-test]) .dnb-textarea__textarea {
}
@supports not (scrollbar-color: auto) {
.dnb-textarea__textarea::-webkit-scrollbar {
background-color: var(--color-black-8);
border-radius: var(--scrollbar-thumb-width, 0.5rem);
background-color: var(--scrollbar-track-color, #eee);
}
.dnb-textarea__textarea::-webkit-scrollbar:vertical {
width: 0.5rem;
width: var(--scrollbar-track-width, 0.5rem);
}
.dnb-textarea__textarea::-webkit-scrollbar:horizontal {
height: 0.5rem;
height: var(--scrollbar-track-width, 0.5rem);
}
.dnb-textarea__textarea::-webkit-scrollbar-thumb {
background-color: var(--color-sea-green);
border-radius: 0.5rem;
background-color: var(--scrollbar-thumb-color, #888);
border-radius: var(--scrollbar-thumb-width, 0.5rem);
}
.dnb-textarea__textarea::-webkit-scrollbar-thumb:hover {
background-color: var(--color-emerald-green);
background-color: var(--scrollbar-thumb-hover-color, #666);
}
}
.dnb-textarea__placeholder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1099,30 +1099,30 @@ html[data-visual-test] .dnb-drawer-list__portal__style {
transition: max-height 300ms var(--easing-default);
overflow-y: auto;
overscroll-behavior: contain;
scrollbar-width: thin;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: auto;
scrollbar-color: var(--color-sea-green) transparent;
scrollbar-color: var(--scrollbar-thumb-color, #888) transparent;
}
html:not([data-visual-test]) .dnb-drawer-list--scroll .dnb-drawer-list__options {
scroll-behavior: smooth;
}
@supports not (scrollbar-color: auto) {
.dnb-drawer-list--scroll .dnb-drawer-list__options::-webkit-scrollbar {
background-color: var(--color-black-8);
border-radius: var(--scrollbar-thumb-width, 0.5rem);
background-color: var(--scrollbar-track-color, #eee);
}
.dnb-drawer-list--scroll .dnb-drawer-list__options::-webkit-scrollbar:vertical {
width: 0.5rem;
width: var(--scrollbar-track-width, 0.5rem);
}
.dnb-drawer-list--scroll .dnb-drawer-list__options::-webkit-scrollbar:horizontal {
height: 0.5rem;
height: var(--scrollbar-track-width, 0.5rem);
}
.dnb-drawer-list--scroll .dnb-drawer-list__options::-webkit-scrollbar-thumb {
background-color: var(--color-sea-green);
border-radius: 0.5rem;
background-color: var(--scrollbar-thumb-color, #888);
border-radius: var(--scrollbar-thumb-width, 0.5rem);
}
.dnb-drawer-list--scroll .dnb-drawer-list__options::-webkit-scrollbar-thumb:hover {
background-color: var(--color-emerald-green);
background-color: var(--scrollbar-thumb-hover-color, #666);
}
}
html[data-visual-test] .dnb-drawer-list--scroll .dnb-drawer-list__options, .dnb-drawer-list--scroll.dnb-drawer-list--no-animation .dnb-drawer-list__options {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

@import '../../../../style/core/utilities.scss';

// :root {
// }

// .dnb-scroll-view {
// }
:root {
--scrollbar-track-width: 0.5rem;
--scrollbar-thumb-width: 0.5rem;
--scrollbar-track-color: var(--color-black-8);
--scrollbar-thumb-color: var(--color-sea-green);
--scrollbar-thumb-hover-color: var(--color-emerald-green);
}
24 changes: 15 additions & 9 deletions packages/dnb-eufemia/src/style/core/utilities.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,36 +147,42 @@ $focusRingColor: var(--color-emerald-green);
}

@mixin scrollbarAppearance() {
scrollbar-width: thin;

// older iOS safari
-webkit-overflow-scrolling: touch;

// show scrollbar in IE & Edge
-ms-overflow-style: auto;

scrollbar-color: var(--color-sea-green) transparent;
// NB: We have used "scrollbar-track-width: auto;" before,
// first, it only effects Firefox.
// But "thin" changes the behavior in Windows,
// so it has no arrow buttons, and a weird "pressed" color.
// Also, on macOS, it changes the scrollbar to be so small,
// that e.g. the textarea resize grabber gets way smaller.

scrollbar-color: var(--scrollbar-thumb-color, #888) transparent;

@supports not (scrollbar-color: auto) {
// stylelint-disable
&::-webkit-scrollbar {
&:vertical {
width: 0.5rem;
width: var(--scrollbar-track-width, 0.5rem);
}
&:horizontal {
height: 0.5rem;
height: var(--scrollbar-track-width, 0.5rem);
}

background-color: var(--color-black-8);
border-radius: var(--scrollbar-thumb-width, 0.5rem);
background-color: var(--scrollbar-track-color, #eee);
}
&::-webkit-scrollbar-thumb {
background-color: var(--color-sea-green);
background-color: var(--scrollbar-thumb-color, #888);

&:hover {
background-color: var(--color-emerald-green);
background-color: var(--scrollbar-thumb-hover-color, #666);
}

border-radius: 0.5rem;
border-radius: var(--scrollbar-thumb-width, 0.5rem);
}
// stylelint-enable
}
Expand Down

0 comments on commit 237331a

Please sign in to comment.