@@ -34,8 +34,9 @@ import {
3434 HeightStyleI ,
3535 SetColumnFunc
3636} from "./gridUtils" ;
37- import { getThemeForScheme } from './gridUtils' ;
37+ import { getThemeForScheme , resolveColorScheme } from './gridUtils' ;
3838import { useColorScheme } from '../useColorScheme' ;
39+ import type { ThemeConfig } from './gridUtils' ;
3940
4041ModuleRegistry . registerModules ( [
4142 ClientSideRowModelModule ,
@@ -167,13 +168,24 @@ export function DFViewerInfinite({
167168 ) } , [ hsCacheKey ]
168169 ) ;
169170 const defaultActiveCol :[ string , string ] = [ "" , "" ] ;
170- const colorScheme = useColorScheme ( ) ;
171- const defaultThemeClass = colorScheme === 'light' ? 'ag-theme-alpine' : 'ag-theme-alpine-dark' ;
172- const divClass = df_viewer_config ?. component_config ?. className || defaultThemeClass ;
171+ const osColorScheme = useColorScheme ( ) ;
172+ const themeConfig = compConfig ?. theme ;
173+ const effectiveScheme = resolveColorScheme ( osColorScheme , themeConfig ) ;
174+ const defaultThemeClass = effectiveScheme === 'light' ? 'ag-theme-alpine' : 'ag-theme-alpine-dark' ;
175+ const divClass = `${ defaultThemeClass } ${ compConfig ?. className || '' } ` . trim ( ) ;
176+
177+ const themeStyle : React . CSSProperties = {
178+ ...hs . applicableStyle ,
179+ ...( themeConfig ?. accentColor ? { '--bk-accent-color' : themeConfig . accentColor } as any : { } ) ,
180+ ...( themeConfig ?. accentHoverColor ? { '--bk-accent-hover-color' : themeConfig . accentHoverColor } as any : { } ) ,
181+ ...( themeConfig ?. backgroundColor ? { '--bk-bg-color' : themeConfig . backgroundColor } as any : { } ) ,
182+ ...( themeConfig ?. foregroundColor ? { '--bk-fg-color' : themeConfig . foregroundColor } as any : { } ) ,
183+ } ;
184+
173185 return (
174186 < div className = { `df-viewer ${ hs . classMode } ${ hs . inIframe } ` } >
175187 { error_info ? < pre > { error_info } </ pre > : null }
176- < div style = { hs . applicableStyle }
188+ < div style = { themeStyle }
177189 className = { `theme-hanger ${ divClass } ` } >
178190 < DFViewerInfiniteInner
179191 data_wrapper = { data_wrapper }
@@ -184,6 +196,8 @@ export function DFViewerInfinite({
184196 outside_df_params = { outside_df_params }
185197 renderStartTime = { renderStartTime }
186198 hs = { hs }
199+ themeConfig = { themeConfig }
200+ effectiveScheme = { effectiveScheme }
187201 />
188202 </ div >
189203 </ div > )
@@ -196,7 +210,9 @@ export function DFViewerInfiniteInner({
196210 setActiveCol,
197211 outside_df_params,
198212 renderStartTime : _renderStartTime ,
199- hs
213+ hs,
214+ themeConfig,
215+ effectiveScheme
200216} : {
201217 data_wrapper : DatasourceOrRaw ;
202218 df_viewer_config : DFViewerConfig ;
@@ -208,7 +224,9 @@ export function DFViewerInfiniteInner({
208224 // them as keys to get updated data
209225 outside_df_params ?: any ;
210226 renderStartTime :any ;
211- hs :HeightStyleI
227+ hs :HeightStyleI ;
228+ themeConfig ?: ThemeConfig ;
229+ effectiveScheme ?: 'light' | 'dark' ;
212230} ) {
213231
214232
@@ -266,7 +284,7 @@ export function DFViewerInfiniteInner({
266284 }
267285 if ( activeCol === field ) {
268286 //return {background:selectBackground}
269- return { background : AccentColor }
287+ return { background : themeConfig ?. accentColor || AccentColor }
270288
271289 }
272290 return { background : "inherit" }
@@ -301,15 +319,15 @@ export function DFViewerInfiniteInner({
301319 [ outside_df_params ] ,
302320 ) ;
303321
304- const colorScheme = useColorScheme ( ) ;
305- const myTheme = useMemo ( ( ) => getThemeForScheme ( colorScheme ) . withParams ( {
322+ const resolvedScheme = effectiveScheme || 'dark' ;
323+ const myTheme = useMemo ( ( ) => getThemeForScheme ( resolvedScheme , themeConfig ) . withParams ( {
306324 headerRowBorder : true ,
307325 headerColumnBorder : true ,
308326 headerColumnResizeHandleWidth : 0 ,
309- ...( colorScheme === 'dark'
310- ? { backgroundColor : "#121212" , oddRowBackgroundColor : '#3f3f3f' }
311- : { backgroundColor : "#ffffff" , oddRowBackgroundColor : '#f0f0f0' } ) ,
312- } ) , [ colorScheme ] ) ;
327+ ...( resolvedScheme === 'dark'
328+ ? { backgroundColor : themeConfig ?. backgroundColor || "#121212" , oddRowBackgroundColor : themeConfig ?. oddRowBackgroundColor || '#3f3f3f' }
329+ : { backgroundColor : themeConfig ?. backgroundColor || "#ffffff" , oddRowBackgroundColor : themeConfig ?. oddRowBackgroundColor || '#f0f0f0' } ) ,
330+ } ) , [ resolvedScheme , themeConfig ] ) ;
313331 const gridOptions : GridOptions = useMemo ( ( ) => {
314332 return {
315333 ...outerGridOptions ( setActiveCol , df_viewer_config . extra_grid_config ) ,
0 commit comments