mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-27 00:19:55 +03:00
Start conversion
This commit is contained in:
parent
5d6b5869be
commit
3890495587
|
@ -2,6 +2,7 @@ import React, { PureComponent } from 'react';
|
||||||
import { Base16Theme } from 'redux-devtools-themes';
|
import { Base16Theme } from 'redux-devtools-themes';
|
||||||
import {
|
import {
|
||||||
getBase16Theme,
|
getBase16Theme,
|
||||||
|
invertBase16Theme,
|
||||||
invertTheme,
|
invertTheme,
|
||||||
StylingFunction,
|
StylingFunction,
|
||||||
} from 'react-base16-styling';
|
} from 'react-base16-styling';
|
||||||
|
@ -15,6 +16,8 @@ import { Delta, DiffContext } from 'jsondiffpatch';
|
||||||
import {
|
import {
|
||||||
createStylingFromTheme,
|
createStylingFromTheme,
|
||||||
base16Themes,
|
base16Themes,
|
||||||
|
inspectorCss,
|
||||||
|
inspectorWideCss,
|
||||||
} from './utils/createStylingFromTheme';
|
} from './utils/createStylingFromTheme';
|
||||||
import ActionList from './ActionList';
|
import ActionList from './ActionList';
|
||||||
import ActionPreview, { Tab } from './ActionPreview';
|
import ActionPreview, { Tab } from './ActionPreview';
|
||||||
|
@ -26,6 +29,7 @@ import {
|
||||||
reducer,
|
reducer,
|
||||||
updateMonitorState,
|
updateMonitorState,
|
||||||
} from './redux';
|
} from './redux';
|
||||||
|
import { ThemeProvider } from '@emotion/react';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||||
|
@ -296,68 +300,69 @@ class DevtoolsInspector<S, A extends Action<string>> extends PureComponent<
|
||||||
const { base16Theme, styling } = themeState;
|
const { base16Theme, styling } = themeState;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<ThemeProvider
|
||||||
key="inspector"
|
theme={invertTheme ? invertBase16Theme(base16Theme) : base16Theme}
|
||||||
data-testid="inspector"
|
|
||||||
ref={this.inspectorCreateRef}
|
|
||||||
{...styling(
|
|
||||||
['inspector', isWideLayout && 'inspectorWide'],
|
|
||||||
isWideLayout,
|
|
||||||
)}
|
|
||||||
>
|
>
|
||||||
<ActionList
|
<div
|
||||||
{...{
|
key="inspector"
|
||||||
actions,
|
data-testid="inspector"
|
||||||
actionIds,
|
ref={this.inspectorCreateRef}
|
||||||
isWideLayout,
|
css={[inspectorCss, isWideLayout && inspectorWideCss]}
|
||||||
searchValue,
|
>
|
||||||
selectedActionId,
|
<ActionList
|
||||||
startActionId,
|
{...{
|
||||||
skippedActionIds,
|
actions,
|
||||||
draggableActions,
|
actionIds,
|
||||||
hideMainButtons,
|
isWideLayout,
|
||||||
hideActionButtons,
|
searchValue,
|
||||||
styling,
|
selectedActionId,
|
||||||
}}
|
startActionId,
|
||||||
onSearch={this.handleSearch}
|
skippedActionIds,
|
||||||
onSelect={this.handleSelectAction}
|
draggableActions,
|
||||||
onToggleAction={this.handleToggleAction}
|
hideMainButtons,
|
||||||
onJumpToState={this.handleJumpToState}
|
hideActionButtons,
|
||||||
onCommit={this.handleCommit}
|
styling,
|
||||||
onSweep={this.handleSweep}
|
}}
|
||||||
onReorderAction={this.handleReorderAction}
|
onSearch={this.handleSearch}
|
||||||
currentActionId={actionIds[currentStateIndex]}
|
onSelect={this.handleSelectAction}
|
||||||
lastActionId={getLastActionId(this.props)}
|
onToggleAction={this.handleToggleAction}
|
||||||
/>
|
onJumpToState={this.handleJumpToState}
|
||||||
<ActionPreview
|
onCommit={this.handleCommit}
|
||||||
{...{
|
onSweep={this.handleSweep}
|
||||||
base16Theme,
|
onReorderAction={this.handleReorderAction}
|
||||||
invertTheme,
|
currentActionId={actionIds[currentStateIndex]}
|
||||||
isWideLayout,
|
lastActionId={getLastActionId(this.props)}
|
||||||
tabs,
|
/>
|
||||||
tabName,
|
<ActionPreview
|
||||||
delta,
|
{...{
|
||||||
error,
|
base16Theme,
|
||||||
nextState,
|
invertTheme,
|
||||||
computedStates,
|
isWideLayout,
|
||||||
action,
|
tabs,
|
||||||
actions,
|
tabName,
|
||||||
selectedActionId,
|
delta,
|
||||||
startActionId,
|
error,
|
||||||
dataTypeKey,
|
nextState,
|
||||||
sortStateTreeAlphabetically,
|
computedStates,
|
||||||
disableStateTreeCollection,
|
action,
|
||||||
}}
|
actions,
|
||||||
monitorState={this.props.monitorState}
|
selectedActionId,
|
||||||
updateMonitorState={this.updateMonitorState}
|
startActionId,
|
||||||
styling={styling}
|
dataTypeKey,
|
||||||
onInspectPath={(path: (string | number)[]) =>
|
sortStateTreeAlphabetically,
|
||||||
this.handleInspectPath(inspectedPathType, path)
|
disableStateTreeCollection,
|
||||||
}
|
}}
|
||||||
inspectedPath={monitorState[inspectedPathType]}
|
monitorState={this.props.monitorState}
|
||||||
onSelectTab={this.handleSelectTab}
|
updateMonitorState={this.updateMonitorState}
|
||||||
/>
|
styling={styling}
|
||||||
</div>
|
onInspectPath={(path: (string | number)[]) =>
|
||||||
|
this.handleInspectPath(inspectedPathType, path)
|
||||||
|
}
|
||||||
|
inspectedPath={monitorState[inspectedPathType]}
|
||||||
|
onSelectTab={this.handleSelectTab}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</ThemeProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
import jss, { StyleSheet } from 'jss';
|
import jss, { StyleSheet } from 'jss';
|
||||||
import preset from 'jss-preset-default';
|
import preset from 'jss-preset-default';
|
||||||
import { createStyling, StylingFunction, Theme } from 'react-base16-styling';
|
import { css } from '@emotion/react';
|
||||||
|
import type { Interpolation, Theme } from '@emotion/react';
|
||||||
|
import {
|
||||||
|
createStyling,
|
||||||
|
StylingFunction,
|
||||||
|
Theme as Base16StylingTheme,
|
||||||
|
} from 'react-base16-styling';
|
||||||
import rgba from 'hex-rgba';
|
import rgba from 'hex-rgba';
|
||||||
import { Base16Theme } from 'redux-devtools-themes';
|
import { Base16Theme } from 'redux-devtools-themes';
|
||||||
import type { CurriedFunction1 } from 'lodash';
|
import type { CurriedFunction1 } from 'lodash';
|
||||||
|
@ -8,6 +14,11 @@ import inspector from '../themes/inspector';
|
||||||
import * as reduxThemes from 'redux-devtools-themes';
|
import * as reduxThemes from 'redux-devtools-themes';
|
||||||
import * as inspectorThemes from '../themes';
|
import * as inspectorThemes from '../themes';
|
||||||
|
|
||||||
|
declare module '@emotion/react' {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||||
|
export interface Theme extends Base16Theme {}
|
||||||
|
}
|
||||||
|
|
||||||
jss.setup(preset());
|
jss.setup(preset());
|
||||||
|
|
||||||
const colorMap = (theme: Base16Theme) => ({
|
const colorMap = (theme: Base16Theme) => ({
|
||||||
|
@ -41,25 +52,23 @@ type ColorMap = {
|
||||||
[color in Color]: string;
|
[color in Color]: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const inspectorCss: Interpolation<Theme> = (theme) => ({
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
fontFamily: 'monaco, Consolas, "Lucida Console", monospace',
|
||||||
|
fontSize: '12px',
|
||||||
|
WebkitFontSmoothing: 'antialiased',
|
||||||
|
lineHeight: '1.5em',
|
||||||
|
|
||||||
|
backgroundColor: colorMap(theme).BACKGROUND_COLOR,
|
||||||
|
color: colorMap(theme).TEXT_COLOR,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const inspectorWideCss = css({ flexDirection: 'column' });
|
||||||
|
|
||||||
const getSheetFromColorMap = (map: ColorMap) => ({
|
const getSheetFromColorMap = (map: ColorMap) => ({
|
||||||
inspector: {
|
|
||||||
display: 'flex',
|
|
||||||
'flex-direction': 'column',
|
|
||||||
width: '100%',
|
|
||||||
height: '100%',
|
|
||||||
'font-family': 'monaco, Consolas, "Lucida Console", monospace',
|
|
||||||
'font-size': '12px',
|
|
||||||
'font-smoothing': 'antialiased',
|
|
||||||
'line-height': '1.5em',
|
|
||||||
|
|
||||||
'background-color': map.BACKGROUND_COLOR,
|
|
||||||
color: map.TEXT_COLOR,
|
|
||||||
},
|
|
||||||
|
|
||||||
inspectorWide: {
|
|
||||||
'flex-direction': 'row',
|
|
||||||
},
|
|
||||||
|
|
||||||
actionList: {
|
actionList: {
|
||||||
'flex-basis': '40%',
|
'flex-basis': '40%',
|
||||||
'flex-shrink': 0,
|
'flex-shrink': 0,
|
||||||
|
@ -386,7 +395,7 @@ const getDefaultThemeStyling = (theme: Base16Theme) => {
|
||||||
export const base16Themes = { ...reduxThemes, ...inspectorThemes };
|
export const base16Themes = { ...reduxThemes, ...inspectorThemes };
|
||||||
|
|
||||||
export const createStylingFromTheme: CurriedFunction1<
|
export const createStylingFromTheme: CurriedFunction1<
|
||||||
Theme | undefined,
|
Base16StylingTheme | undefined,
|
||||||
StylingFunction
|
StylingFunction
|
||||||
> = createStyling(getDefaultThemeStyling, {
|
> = createStyling(getDefaultThemeStyling, {
|
||||||
defaultBase16: inspector,
|
defaultBase16: inspector,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user