File tree Expand file tree Collapse file tree
code-studio/src/styleguide Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 GridThemeType ,
66 MockGridModel ,
77 MockTreeGridModel ,
8- GridThemeContext ,
8+ ThemeContext ,
99} from '@deephaven/grid' ;
1010import { IrisGrid } from '@deephaven/iris-grid' ;
1111import { useApi } from '@deephaven/jsapi-bootstrap' ;
@@ -38,7 +38,7 @@ function Grids(): ReactElement {
3838 } ) ;
3939 return (
4040 < div >
41- < GridThemeContext . Provider value = { contextTheme } >
41+ < ThemeContext . Provider value = { contextTheme } >
4242 < h2 className = "ui-title" > Grid</ h2 >
4343 < Flex { ...sampleSectionIdAndClassesSpectrum ( 'grids-grid' ) } >
4444 < Grid model = { model } theme = { theme } />
@@ -81,7 +81,7 @@ function Grids(): ReactElement {
8181 < Flex { ...sampleSectionIdAndClassesSpectrum ( 'grids-iris' ) } height = { 500 } >
8282 < IrisGrid model = { irisGridModel } />
8383 </ Flex >
84- </ GridThemeContext . Provider >
84+ </ ThemeContext . Provider >
8585 </ div >
8686 ) ;
8787}
Original file line number Diff line number Diff line change 11/* eslint-disable react/jsx-props-no-spreading */
2- import React , { useEffect , useState } from 'react' ;
2+ import React , { useMemo } from 'react' ;
33import { Tooltip , useTheme } from '@deephaven/components' ;
44import { ColorUtils } from '@deephaven/utils' ;
55import palette from '@deephaven/components/src/theme/theme-dark/theme-dark-palette.css?inline' ;
@@ -28,16 +28,8 @@ function buildSwatchDataGroups() {
2828}
2929
3030export function ThemeColors ( ) : JSX . Element {
31- const [ swatchDataGroups , setSwatchDataGroups ] = useState (
32- buildSwatchDataGroups
33- ) ;
34-
3531 const { selectedThemeKey } = useTheme ( ) ;
36-
37- useEffect ( ( ) => {
38- // Rebuild swatches when themes change
39- setSwatchDataGroups ( buildSwatchDataGroups ( ) ) ;
40- } , [ selectedThemeKey ] ) ;
32+ const swatchDataGroups = useMemo ( buildSwatchDataGroups , [ selectedThemeKey ] ) ;
4133
4234 return (
4335 < >
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ import {
5757} from './EditableGridModel' ;
5858import { EventHandlerResultOptions } from './EventHandlerResult' ;
5959import { assertIsDefined } from './errors' ;
60- import GridThemeContext from './GridThemeContext ' ;
60+ import ThemeContext from './ThemeContext ' ;
6161import { DraggingColumn } from './mouse-handlers/GridColumnMoveMouseHandler' ;
6262import {
6363 EditingCell ,
@@ -211,7 +211,7 @@ export type GridState = {
211211 * Can also add onClick and onContextMenu handlers to add custom functionality and menus.
212212 */
213213class Grid extends PureComponent < GridProps , GridState > {
214- static contextType = GridThemeContext ;
214+ static contextType = ThemeContext ;
215215
216216 static defaultProps = {
217217 canvasOptions : { alpha : false } as CanvasRenderingContext2DSettings ,
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { GridTheme as GridThemeType } from './GridTheme' ;
3+
4+ export type ThemeContextValue = Partial < GridThemeType > ;
5+
6+ export const ThemeContext : React . Context < ThemeContextValue > =
7+ React . createContext ( { } ) ;
8+
9+ export default ThemeContext ;
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export * from './key-handlers';
2525export * from './mouse-handlers' ;
2626export * from './errors' ;
2727export * from './EventHandlerResult' ;
28- export * from './GridThemeContext ' ;
28+ export * from './ThemeContext ' ;
2929export type { default as CellRenderer , CellRenderType } from './CellRenderer' ;
3030export { default as TextCellRenderer } from './TextCellRenderer' ;
3131export { default as DataBarCellRenderer } from './DataBarCellRenderer' ;
You can’t perform that action at this time.
0 commit comments