Skip to content

Commit cf40352

Browse files
authored
feat(theme): add CSS for global header (#735)
* feat(theme): add CSS for global header * remove height override duplicated by https://github.com/redhat-developer/rhdh/blob/main/packages/app/src/components/Root/Root.tsx * Update createComponents.ts
1 parent 7868934 commit cf40352

6 files changed

Lines changed: 31 additions & 4 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-theme': patch
3+
---
4+
5+
Add CSS for global header

workspaces/theme/plugins/theme/report.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export interface RHDHThemePalette {
8181
tabsLinkHoverBackgroundColor: string;
8282
contrastText: string;
8383
appBarBackgroundColor: string;
84+
appBarForegroundColor: string;
8485
appBarBackgroundImage: string;
8586
};
8687
// (undocumented)

workspaces/theme/plugins/theme/src/darkTheme.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export const darkThemeOverrides: Partial<ThemeConfigPalette> = {
7979
contrastText: '#FFF',
8080

8181
appBarBackgroundColor: '#151515',
82+
appBarForegroundColor: '#ffffff',
8283
appBarBackgroundImage: 'none',
8384
},
8485
primary: {

workspaces/theme/plugins/theme/src/lightTheme.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ export const lightThemeOverrides: Partial<ThemeConfigPalette> = {
7878

7979
contrastText: '#FFF',
8080

81-
appBarBackgroundColor: '#212427',
81+
appBarBackgroundColor: '#f2f2f2',
82+
appBarForegroundColor: '#1f1f1f',
8283
appBarBackgroundImage: 'none',
8384
},
8485
primary: {

workspaces/theme/plugins/theme/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export interface RHDHThemePalette {
4949
contrastText: string;
5050

5151
appBarBackgroundColor: string;
52+
appBarForegroundColor: string;
5253
appBarBackgroundImage: string;
5354
};
5455

workspaces/theme/plugins/theme/src/utils/createComponents.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -688,12 +688,29 @@ export const createComponents = (themeConfig: ThemeConfig): Components => {
688688
root: {
689689
// Controls the page inset as in PF6 -- only in desktop view
690690
'@media (min-width: 600px)': {
691+
// The size of the page inset border
692+
'--rhdh-v1-page-inset': '1.5rem',
691693
backgroundColor: general.sidebarBackgroundColor,
694+
// Cancel out the spacing produced by the page inset border when
695+
// the global header is present
696+
"& #global-header ~ main, & #global-header ~ [class*='MuiLinearProgress-root']":
697+
{
698+
marginTop: 'calc(-1 * var(--rhdh-v1-page-inset))',
699+
},
700+
// Cancel out the spacing produced by the page inset border when
701+
// the sidebar is present
702+
"& nav ~ main, & nav ~ [class*='MuiLinearProgress-root']": {
703+
marginLeft: 'calc(-1 * var(--rhdh-v1-page-inset))',
704+
},
705+
// The border + border radius emulates the PF6 page inset look without
706+
// needing to change the markup
692707
"& > [class*='MuiLinearProgress-root'], & > main": {
693-
borderRadius: '2.5rem',
694-
border: `1.5rem solid ${general.sidebarBackgroundColor}`,
695-
marginLeft: '-1.5rem',
708+
borderRadius: 'calc(1rem + var(--rhdh-v1-page-inset))',
709+
border: `var(--rhdh-v1-page-inset) solid ${general.sidebarBackgroundColor}`,
696710
},
711+
// The Backstage suspense is an MUI LinearProgress that is not wrapped by
712+
// a `main`. We need to give it 100vh height to fill the page for the page
713+
// inset to look right.
697714
"& > [class*='MuiLinearProgress-root']": {
698715
backgroundColor: general.mainSectionBackgroundColor,
699716
height: '100vh',
@@ -835,6 +852,7 @@ export const createComponents = (themeConfig: ThemeConfig): Components => {
835852
styleOverrides: {
836853
root: {
837854
height: '3px',
855+
zIndex: 1,
838856
},
839857
vertical: {
840858
width: '3px',

0 commit comments

Comments
 (0)