Remove themeState

This commit is contained in:
Nathan Bierema 2023-12-11 21:43:15 -05:00
parent a7f8a3bd3a
commit 3a62058c1c
2 changed files with 3 additions and 22 deletions

View File

@ -123,14 +123,6 @@ function createIntermediateState<S, A extends Action<string>>(
}; };
} }
function createThemeState<S, A extends Action<string>>(
props: DevtoolsInspectorProps<S, A>,
) {
const base16Theme = getBase16Theme(props.theme, base16Themes)!;
return { base16Theme };
}
export interface ExternalProps<S, A extends Action<string>> { export interface ExternalProps<S, A extends Action<string>> {
dispatch: Dispatch< dispatch: Dispatch<
DevtoolsInspectorAction | LiftedAction<S, A, DevtoolsInspectorState> DevtoolsInspectorAction | LiftedAction<S, A, DevtoolsInspectorState>
@ -186,7 +178,6 @@ interface State<S, A extends Action<string>> {
action: A; action: A;
error: string | undefined; error: string | undefined;
isWideLayout: boolean; isWideLayout: boolean;
themeState: { base16Theme: Base16Theme };
} }
class DevtoolsInspector<S, A extends Action<string>> extends PureComponent< class DevtoolsInspector<S, A extends Action<string>> extends PureComponent<
@ -196,7 +187,6 @@ class DevtoolsInspector<S, A extends Action<string>> extends PureComponent<
state: State<S, A> = { state: State<S, A> = {
...createIntermediateState(this.props, this.props.monitorState), ...createIntermediateState(this.props, this.props.monitorState),
isWideLayout: false, isWideLayout: false,
themeState: createThemeState(this.props),
}; };
static update = reducer; static update = reducer;
@ -252,13 +242,6 @@ class DevtoolsInspector<S, A extends Action<string>> extends PureComponent<
) { ) {
this.setState(createIntermediateState(nextProps, nextMonitorState)); this.setState(createIntermediateState(nextProps, nextMonitorState));
} }
if (
this.props.theme !== nextProps.theme ||
this.props.invertTheme !== nextProps.invertTheme
) {
this.setState({ themeState: createThemeState(nextProps) });
}
} }
inspectorCreateRef: React.RefCallback<HTMLDivElement> = (node) => { inspectorCreateRef: React.RefCallback<HTMLDivElement> = (node) => {
@ -272,6 +255,7 @@ class DevtoolsInspector<S, A extends Action<string>> extends PureComponent<
computedStates, computedStates,
draggableActions, draggableActions,
tabs, tabs,
theme,
invertTheme, invertTheme,
skippedActionIds, skippedActionIds,
currentStateIndex, currentStateIndex,
@ -286,10 +270,9 @@ class DevtoolsInspector<S, A extends Action<string>> extends PureComponent<
monitorState; monitorState;
const inspectedPathType = const inspectedPathType =
tabName === 'Action' ? 'inspectedActionPath' : 'inspectedStatePath'; tabName === 'Action' ? 'inspectedActionPath' : 'inspectedStatePath';
const { themeState, isWideLayout, action, nextState, delta, error } = const { isWideLayout, action, nextState, delta, error } = this.state;
this.state;
const { base16Theme } = themeState;
const base16Theme = getBase16Theme(theme, base16Themes)!;
return ( return (
<ThemeProvider <ThemeProvider
theme={invertTheme ? invertBase16Theme(base16Theme) : base16Theme} theme={invertTheme ? invertBase16Theme(base16Theme) : base16Theme}

View File

@ -36,8 +36,6 @@ const colorMap = (theme: Base16Theme) => ({
ERROR_COLOR: theme.base08, ERROR_COLOR: theme.base08,
}); });
type Color = keyof ReturnType<typeof colorMap>;
export const inspectorCss: Interpolation<Theme> = (theme) => ({ export const inspectorCss: Interpolation<Theme> = (theme) => ({
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',