Skip to content

Commit 6f4b7e2

Browse files
authored
Fix handling of theme change (#505)
1 parent 9fde6ed commit 6f4b7e2

File tree

4 files changed

+1
-25
lines changed

4 files changed

+1
-25
lines changed

packages/base/src/3dview/mainview.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { STLLoader } from 'three/examples/jsm/loaders/STLLoader';
2525
import { ViewHelper } from 'three/examples/jsm/helpers/ViewHelper';
2626

2727
import { FloatingAnnotation } from '../annotation';
28-
import { getCSSVariableColor, isLightTheme, throttle } from '../tools';
28+
import { getCSSVariableColor, throttle } from '../tools';
2929
import {
3030
AxeHelper,
3131
CameraSettings,
@@ -63,7 +63,6 @@ interface IStates {
6363
id: string; // ID of the component, it is used to identify which component
6464
//is the source of awareness updates.
6565
loading: boolean;
66-
lightTheme: boolean;
6766
remoteUser?: User.IIdentity | null;
6867
annotations: IDict<IAnnotation>;
6968
firstLoad: boolean;
@@ -107,7 +106,6 @@ export class MainView extends React.Component<IProps, IStates> {
107106

108107
this.state = {
109108
id: this._mainViewModel.id,
110-
lightTheme: isLightTheme(),
111109
loading: true,
112110
annotations: {},
113111
firstLoad: true,
@@ -1435,15 +1433,11 @@ export class MainView extends React.Component<IProps, IStates> {
14351433
}
14361434

14371435
private _handleThemeChange = (): void => {
1438-
const lightTheme = isLightTheme();
1439-
14401436
DEFAULT_MESH_COLOR.set(getCSSVariableColor(DEFAULT_MESH_COLOR_CSS));
14411437
DEFAULT_EDGE_COLOR.set(getCSSVariableColor(DEFAULT_EDGE_COLOR_CSS));
14421438
BOUNDING_BOX_COLOR.set(getCSSVariableColor(BOUNDING_BOX_COLOR_CSS));
14431439

14441440
this._clippingPlaneMeshControl.material.color = DEFAULT_MESH_COLOR;
1445-
1446-
this.setState(old => ({ ...old, lightTheme }));
14471441
};
14481442

14491443
private _handleWindowResize = (): void => {

packages/base/src/panelview/objecttree.tsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ interface IStates {
8585
filePath?: string;
8686
jcadObject?: IJCadModel;
8787
options?: JSONObject;
88-
lightTheme: boolean;
8988
selectedNodes: string[];
9089
clientId: number | null; // ID of the yjs client
9190
id: string; // ID of the component, it is used to identify which component
@@ -142,13 +141,9 @@ class ObjectTreeReact extends React.Component<IProps, IStates> {
142141
constructor(props: IProps) {
143142
super(props);
144143

145-
const lightTheme =
146-
document.body.getAttribute('data-jp-theme-light') === 'true';
147-
148144
this.state = {
149145
filePath: this.props.cpModel.filePath,
150146
jcadObject: this.props.cpModel.jcadModel?.getAllObject(),
151-
lightTheme,
152147
selectedNodes: [],
153148
clientId: null,
154149
id: uuid(),
@@ -160,13 +155,11 @@ class ObjectTreeReact extends React.Component<IProps, IStates> {
160155
this.props.cpModel.documentChanged.connect((_, document) => {
161156
if (document) {
162157
this.props.cpModel.disconnect(this._sharedJcadModelChanged);
163-
this.props.cpModel.disconnect(this._handleThemeChange);
164158
this.props.cpModel.disconnect(this._onClientSharedStateChanged);
165159

166160
document.context.model.sharedObjectsChanged.connect(
167161
this._sharedJcadModelChanged
168162
);
169-
document.context.model.themeChanged.connect(this._handleThemeChange);
170163
document.context.model.clientStateChanged.connect(
171164
this._onClientSharedStateChanged
172165
);
@@ -231,12 +224,6 @@ class ObjectTreeReact extends React.Component<IProps, IStates> {
231224
}
232225
}
233226

234-
private _handleThemeChange = (): void => {
235-
const lightTheme =
236-
document.body.getAttribute('data-jp-theme-light') === 'true';
237-
this.setState(old => ({ ...old, lightTheme }));
238-
};
239-
240227
handleNodeClick = (objectId: string) => {
241228
const object = this.getObjectFromName(objectId);
242229

packages/base/src/sketcher/sketcherwidget.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,5 @@ export class SketcherReactWidget extends React.Component<IProps, IState> {
526526
private _divRef = React.createRef<HTMLDivElement>();
527527
private _canvasRef = React.createRef<HTMLCanvasElement>();
528528
private _panZoom: PanZoom;
529-
// private _lightTheme =
530529
// document.body.getAttribute('data-jp-theme-light') === 'true';
531530
}

packages/base/src/tools.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,3 @@ export async function requestAPI<T>(
270270

271271
return data;
272272
}
273-
274-
export function isLightTheme(): boolean {
275-
return document.body.getAttribute('data-jp-theme-light') === 'true';
276-
}

0 commit comments

Comments
 (0)