Skip to content

Commit

Permalink
[Bug] Fix Global Breadcrumb Styling in dark mode (#2085) (#2098)
Browse files Browse the repository at this point in the history
Issue:
#2072

Issue with dark mode theme not being applied to breadcrumbs.

Signed-off-by: kaddy645 <[email protected]>
(cherry picked from commit 75db369)

Co-authored-by: Kartik Desai <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and kaddy645 authored Aug 9, 2022
1 parent f4a7224 commit 88f6c07
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 22 deletions.
4 changes: 4 additions & 0 deletions src/core/public/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ $osdHeaderOffset: $euiHeaderHeightCompensation;
$osdHeaderBreadcrumbBlueBackground: #b9d9eb;
$osdHeaderBreadcrumbGrayBackground: #d9e1e2;
$osdHeaderBreadcrumbCollapsedLink: #002a3a;
$osdHeaderBreadcrumbPacificSkyDarkestBackground: #163f66;
$osdHeaderBreadcrumbMidnightSkyMediumBackground: #4c636f;
$osdHeaderBreadcrumbMidnightSkyMediumLightColor: #96a0a5;
$osdHeaderBreadcrumbMidnightSkyMediumLightHoverColor: #b0b8bb;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/core/public/chrome/ui/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function Header({
const toggleCollapsibleNavRef = createRef<HTMLButtonElement & { euiAnimate: () => void }>();
const navId = htmlIdGenerator()();
const className = classnames('hide-for-sharing', 'headerGlobalNav');
const { useExpandedHeader = true } = branding;
const { useExpandedHeader = true, darkMode } = branding;

return (
<>
Expand Down Expand Up @@ -194,6 +194,7 @@ export function Header({
<HeaderBreadcrumbs
appTitle$={observables.appTitle$}
breadcrumbs$={observables.breadcrumbs$}
isDarkMode={darkMode}
/>

<EuiHeaderSectionItem border="none">
Expand Down
88 changes: 70 additions & 18 deletions src/core/public/chrome/ui/header/header_breadcrumbs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,95 @@ $breadcrumbPolygon: polygon(
0% 100%
);

.osdHeaderBreadcrumbs {
/*
filter defines a custom filter effect by grouping atomic filter primitives!
here we are using Gaussian filter with stdDeviation for applying
border-radius on clipped background.
*/

filter: url("../../public/assets/round_filter.svg#round");
/* remove background color on autofocus for euiBreadcrumbs in Popover */
.euiBreadcrumbs__inPopover {
.euiLink.euiLink--text:focus {
background: none;
}
}

.osdBreadcrumbs {
.osdHeaderBreadcrumbs {
/* common for both light & dark theme */
.osdBreadcrumbs,
&--dark .osdBreadcrumbs {
clip-path: $breadcrumbPolygon;
background-color: $osdHeaderBreadcrumbGrayBackground;
padding: $euiSizeXS - 2.5 $euiSizeL - $euiSizeXS;

&:first-child {
clip-path: $firstBreadcrumbPolygon;
}
}

.osdBreadcrumbs {
background-color: $osdHeaderBreadcrumbGrayBackground;

&:last-child {
background-color: $osdHeaderBreadcrumbBlueBackground;
}
}

.euiBreadcrumbSeparator {
display: none;
}

/* only light mode */
.euiBreadcrumb__collapsedLink {
color: $osdHeaderBreadcrumbCollapsedLink;
background: $euiColorEmptyShade;
}

.euiPopover__anchor {
padding: 0 $euiSizeS;
.euiLink.euiLink--subdued:focus {
background: $euiColorEmptyShade;
outline: $euiSizeXS - 1 solid $osdHeaderBreadcrumbBlueBackground;
}

.euiBreadcrumb:not(.euiBreadcrumb:last-child) {
margin-right: 0;
/* common for dark & light mode */
&,
&--dark {
/*
filter defines a custom filter effect by grouping atomic filter primitives!
here we are using Gaussian filter with stdDeviation for applying
border-radius on clipped background.
*/
filter: url("../../public/assets/round_filter.svg#round");

button {
line-height: inherit;
}

.euiBreadcrumbSeparator {
display: none;
}

.euiPopover__anchor {
padding: 0 $euiSizeS;
}

.euiBreadcrumb:not(.euiBreadcrumb:last-child) {
margin-right: 0;
}
}

/* only dark mode */
&--dark {
.osdBreadcrumbs {
background-color: $osdHeaderBreadcrumbMidnightSkyMediumBackground;
color: $osdHeaderBreadcrumbMidnightSkyMediumLightColor;

&:hover {
color: $osdHeaderBreadcrumbMidnightSkyMediumLightHoverColor;
}

&:last-child {
background-color: $osdHeaderBreadcrumbPacificSkyDarkestBackground;
color: $euiColorFullShade;
}
}

.euiBreadcrumb__collapsedLink {
color: $euiColorGhost;
background: $euiColorEmptyShade;
}

.euiLink.euiLink--subdued:focus {
background: $euiColorEmptyShade;
outline: $euiSizeXS - 1 solid $osdHeaderBreadcrumbPacificSkyDarkestBackground;
}
}
}
6 changes: 5 additions & 1 deletion src/core/public/chrome/ui/header/header_breadcrumbs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ describe('HeaderBreadcrumbs', () => {
it('renders updates to the breadcrumbs$ observable', () => {
const breadcrumbs$ = new BehaviorSubject([{ text: 'First' }]);
const wrapper = mount(
<HeaderBreadcrumbs appTitle$={new BehaviorSubject('')} breadcrumbs$={breadcrumbs$} />
<HeaderBreadcrumbs
appTitle$={new BehaviorSubject('')}
breadcrumbs$={breadcrumbs$}
isDarkMode={false}
/>
);
expect(wrapper.find('.euiBreadcrumb')).toMatchSnapshot();

Expand Down
6 changes: 4 additions & 2 deletions src/core/public/chrome/ui/header/header_breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ import './header_breadcrumbs.scss';
interface Props {
appTitle$: Observable<string>;
breadcrumbs$: Observable<ChromeBreadcrumb[]>;
isDarkMode?: boolean;
}

export function HeaderBreadcrumbs({ appTitle$, breadcrumbs$ }: Props) {
export function HeaderBreadcrumbs({ appTitle$, breadcrumbs$, isDarkMode }: Props) {
const appTitle = useObservable(appTitle$, 'OpenSearch Dashboards');
const breadcrumbs = useObservable(breadcrumbs$, []);
const className = isDarkMode ? 'osdHeaderBreadcrumbs--dark' : 'osdHeaderBreadcrumbs';
let crumbs = breadcrumbs;

if (breadcrumbs.length === 0 && appTitle) {
Expand All @@ -67,7 +69,7 @@ export function HeaderBreadcrumbs({ appTitle$, breadcrumbs$ }: Props) {
breadcrumbs={crumbs}
max={10}
data-test-subj="breadcrumbs"
className="osdHeaderBreadcrumbs"
className={className}
/>
);
}

0 comments on commit 88f6c07

Please sign in to comment.