Skip to content

Commit

Permalink
Adapt FilterNavigatorBar to High Contrast Mode.
Browse files Browse the repository at this point in the history
This ensures the different items are properly rendered in HCM:
- the items gets a button color, and have a distinct hovered style
- the selected item looks selected
- the separator are visible (light and dark HCM-specific version of the existing image were added)
- the disabled items have full opacity and use a gray text
  • Loading branch information
nchevobbe committed Jan 16, 2025
1 parent 9175e24 commit 033a323
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 6 deletions.
8 changes: 8 additions & 0 deletions res/img/svg/scope-bar-separator-hcm-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions res/img/svg/scope-bar-separator-hcm-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/components/app/ProfileFilterNavigator.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
margin: 5px 5px 0;
color: var(--internal-selected-color);
content: '';

/* opt-out of forced color so the arrow is visible */
forced-color-adjust: none;
inset-block-start: 4px;
inset-inline-start: 4px;
}
Expand All @@ -29,3 +32,13 @@ span.profileFilterNavigator--tab-selector::before {
/* Disabled tab selector indicates this with a grayed out arrow. */
color: var(--grey-30);
}

@media (forced-colors: active) {
.profileFilterNavigator--tab-selector::before {
color: currentcolor;
}

span.profileFilterNavigator--tab-selector::before {
color: GrayText;
}
}
75 changes: 69 additions & 6 deletions src/components/shared/FilterNavigatorBar.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

.filterNavigatorBar {
--internal-background-color: transparent;
--internal-hover-background-color: rgb(0 0 0 / 0.1);
--internal-hover-color: inherit;
--internal-active-background-color: rgb(0 0 0 / 0.2);
--internal-selected-background-color: transparent;
--internal-selected-color: var(--selected-color, var(--blue-60));
--internal-separator-img: url(firefox-profiler-res/img/svg/scope-bar-separator.svg);

display: flex;
height: 24px;
Expand All @@ -28,6 +34,11 @@
border-width: 0 8px 0 6px;
border-right-color: transparent !important;
background-clip: padding-box;
background-color: var(--internal-background-color);

/* Make sure the design also works in High Contrast Mode. The colors are overriden
in the forced colors media query. */
forced-color-adjust: none;
line-height: 24px;
transition:
opacity 250ms var(--animation-curve),
Expand Down Expand Up @@ -88,7 +99,7 @@

.filterNavigatorBarItem:not(.filterNavigatorBarLeafItem)::after {
animation: fadeIn 250ms var(--animation-curve);
background-image: url(../../../res/img/svg/scope-bar-separator.svg);
background-image: var(--internal-separator-img);
background-position: -18px -12px;
background-repeat: no-repeat;
background-size: 24px 24px;
Expand All @@ -104,33 +115,48 @@
}
}

.filterNavigatorBarSelectedItem {
.filterNavigatorBarItem:not(
.filterNavigatorBarRootItem,
.filterNavigatorBarLeafItem
)::before,
.filterNavigatorBarItem:not(.filterNavigatorBarLeafItem)::after {
border-color: var(--internal-background-color);
}

.filterNavigatorBarItem.filterNavigatorBarSelectedItem {
background-color: var(--internal-selected-background-color);
color: var(--internal-selected-color);
}

.filterNavigatorBarSelectedItem:not(.filterNavigatorBarRootItem)::before,
.filterNavigatorBarSelectedItem:not(:first-of-type:last-of-type)::after {
border-color: var(--internal-selected-background-color);
}

.filterNavigatorBarItem:not(.filterNavigatorBarLeafItem):hover,
.filterNavigatorBarItem:has(button.profileFilterNavigator--tab-selector):hover {
background-color: rgb(0 0 0 / 0.1);
background-color: var(--internal-hover-background-color);
color: var(--internal-hover-color);
}

.filterNavigatorBarItem:not(
.filterNavigatorBarRootItem,
.filterNavigatorBarLeafItem
):hover::before,
.filterNavigatorBarItem:not(.filterNavigatorBarLeafItem):hover::after {
border-color: rgb(0 0 0 / 0.1);
border-color: var(--internal-hover-background-color);
}

.filterNavigatorBarItem:not(.filterNavigatorBarLeafItem):active:hover {
background-color: rgb(0 0 0 / 0.2);
background-color: var(--internal-hover-background-color);
}

.filterNavigatorBarItem:not(
.filterNavigatorBarRootItem,
.filterNavigatorBarLeafItem
):active:hover::before,
.filterNavigatorBarItem:not(.filterNavigatorBarLeafItem):active:hover::after {
border-color: rgb(0 0 0 / 0.2);
border-color: var(--internal-hover-background-color);
}

.filterNavigatorBarUncommittedItem {
Expand Down Expand Up @@ -176,3 +202,40 @@
transition: none;
}
}

@media (forced-colors: active) {
.filterNavigatorBar {
--internal-background-color: ButtonFace;
--internal-hover-background-color: SelectedItemText;
--internal-hover-color: SelectedItem;
--internal-active-background-color: SelectedItemText;
--internal-selected-background-color: SelectedItem;
--internal-selected-color: SelectedItemText;
--internal-separator-img: url(firefox-profiler-res/img/svg/scope-bar-separator-hcm-light.svg);
}

.filterNavigatorBarItem {
color: ButtonText;
}

/* When the tab selector is active, we want the item to look like a button */
.filterNavigatorBarSelectedItem:has(
button.profileFilterNavigator--tab-selector
) {
background-color: ButtonFace;
color: ButtonText;
}

/* In regular mode, the opacity is tweaked, which isn't suited for High Contrast Mode.
Here we want the full opacity and a gray text */
.filterNavigatorBarUncommittedItem {
color: GrayText;
opacity: 1;
}

@media (prefers-color-scheme: dark) {
.filterNavigatorBar {
--internal-separator-img: url(firefox-profiler-res/img/svg/scope-bar-separator-hcm-dark.svg);
}
}
}

0 comments on commit 033a323

Please sign in to comment.