1- import { useMemo } from 'react ' ;
2- import * as React from 'react' ;
1+ import { ThemeOptions , ThemeProvider } from '@mui/material ' ;
2+ import { ChartThemeColor , getThemeColors } from '@patternfly/ react-charts/victory ' ;
33import {
44 ChartsProvider ,
55 generateChartsTheme ,
@@ -8,36 +8,37 @@ import {
88 SnackbarProvider ,
99 typography ,
1010} from '@perses-dev/components' ;
11- import { ThemeProvider } from '@mui/material' ;
12- import {
13- DataQueriesProvider ,
14- dynamicImportPluginLoader ,
15- PluginModuleResource ,
16- PluginRegistry ,
17- TimeRangeProviderWithQueryParams ,
18- useInitialRefreshInterval ,
19- useInitialTimeRange ,
20- usePluginBuiltinVariableDefinitions ,
21- } from '@perses-dev/plugin-system' ;
2211import {
2312 BuiltinVariableDefinition ,
13+ DashboardResource ,
2414 Definition ,
2515 DurationString ,
26- DashboardResource ,
2716 UnknownSpec ,
2817} from '@perses-dev/core' ;
29- import panelsResource from '@perses-dev/panels-plugin/plugin.json' ;
30- import prometheusResource from '@perses-dev/prometheus-plugin/plugin.json' ;
3118import {
3219 DashboardProvider ,
3320 DatasourceStoreProvider ,
3421 VariableProviderWithQueryParams ,
3522} from '@perses-dev/dashboards' ;
36- import { ChartThemeColor , getThemeColors } from '@patternfly/react-charts/victory' ;
23+ import panelsResource from '@perses-dev/panels-plugin/plugin.json' ;
24+ import {
25+ DataQueriesProvider ,
26+ dynamicImportPluginLoader ,
27+ PluginModuleResource ,
28+ PluginRegistry ,
29+ TimeRangeProviderWithQueryParams ,
30+ useInitialRefreshInterval ,
31+ useInitialTimeRange ,
32+ usePluginBuiltinVariableDefinitions ,
33+ } from '@perses-dev/plugin-system' ;
34+ import prometheusResource from '@perses-dev/prometheus-plugin/plugin.json' ;
35+ import React , { useMemo } from 'react' ;
3736import { usePatternFlyTheme } from '../../hooks/usePatternflyTheme' ;
38- import { CachedDatasourceAPI } from './perses/datasource-api' ;
3937import { OcpDatasourceApi } from './datasource-api' ;
4038import { PERSES_PROXY_BASE_PATH , useFetchPersesDashboard } from './perses-client' ;
39+ import { CachedDatasourceAPI } from './perses/datasource-api' ;
40+
41+ import { t_color_gray_95 , t_color_white } from '@patternfly/react-tokens' ;
4142
4243import { QueryParams } from '../../query-params' ;
4344import { StringParam , useQueryParam } from 'use-query-params' ;
@@ -80,18 +81,56 @@ interface PersesWrapperProps {
8081 project : string ;
8182}
8283
84+ const mapPatterflyThemeToMUI = ( theme : 'light' | 'dark' ) : ThemeOptions => {
85+ return {
86+ typography : {
87+ fontFamily : 'var(--pf-t--global--font--family--body)' ,
88+ ...typography ,
89+ } ,
90+ components : {
91+ MuiIconButton : {
92+ styleOverrides : {
93+ root : {
94+ color : theme === 'dark' ? t_color_white . value : t_color_gray_95 . value ,
95+ } ,
96+ } ,
97+ } ,
98+ } ,
99+ palette : {
100+ primary : {
101+ main : theme === 'dark' ? t_color_white . value : t_color_gray_95 . value ,
102+ } ,
103+ background : {
104+ navigation : 'var(--pf-t--global--background--color--primary--default)' ,
105+ default : 'var(--pf-t--global--background--color--primary--default)' ,
106+ paper : 'var(--pf-t--global--background--color--primary--default)' ,
107+ code : 'var(--pf-t--global--background--color--primary--default)' ,
108+ tooltip : 'var(--pf-t--global--background--color--primary--default)' ,
109+ lighter : 'var(--pf-t--global--background--color--primary--default)' ,
110+ border : 'var(--pf-t--global--background--color--primary--default)' ,
111+ } ,
112+ text : {
113+ navigation : theme === 'dark' ? t_color_white . value : t_color_gray_95 . value ,
114+ accent : theme === 'dark' ? t_color_white . value : t_color_gray_95 . value ,
115+ primary : theme === 'dark' ? t_color_white . value : t_color_gray_95 . value ,
116+ secondary : theme === 'dark' ? t_color_white . value : t_color_gray_95 . value ,
117+ disabled : theme === 'dark' ? t_color_white . value : t_color_gray_95 . value ,
118+ link : theme === 'dark' ? t_color_white . value : t_color_gray_95 . value ,
119+ linkHover : theme === 'dark' ? t_color_white . value : t_color_gray_95 . value ,
120+ } ,
121+ } ,
122+ } ;
123+ } ;
124+
83125export function PersesWrapper ( { children, project } : PersesWrapperProps ) {
84126 const { theme } = usePatternFlyTheme ( ) ;
85127 const [ dashboardName ] = useQueryParam ( QueryParams . Dashboard , StringParam ) ;
86128
87129 const muiTheme = getTheme ( theme , {
88- typography : {
89- ...typography ,
90- fontFamily : 'var(--pf-t--global--font--family--body)' ,
91- } ,
92130 shape : {
93131 borderRadius : 6 ,
94132 } ,
133+ ...mapPatterflyThemeToMUI ( theme ) ,
95134 } ) ;
96135
97136 const chartsTheme : PersesChartsTheme = generateChartsTheme ( muiTheme , {
0 commit comments