Skip to content

Commit e61dfa5

Browse files
committed
final touches on style context migration
1 parent 9224ff2 commit e61dfa5

File tree

6 files changed

+10
-29
lines changed

6 files changed

+10
-29
lines changed

app/src/components/bottom/BottomTabs.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,20 @@ import StylesEditor from './StylesEditor';
77
import CustomizationPanel from '../../containers/CustomizationPanel';
88
import CreationPanel from './CreationPanel';
99
import ContextManager from '../ContextAPIManager/ContextManager';
10-
import StateManager from '../StateManagement/StateManagement';
10+
import StateManager from '../StateManagement/StateManagement';
1111
import Box from '@mui/material/Box';
1212
import Tree from '../../tree/TreeChart';
1313
import FormControl from '@mui/material/FormControl';
1414
import MenuItem from '@mui/material/MenuItem';
1515
import Select from '@mui/material/Select';
1616
import Arrow from '../main/Arrow';
17-
import {useDispatch, useSelector} from 'react-redux';
18-
import { changeProjectType} from '../../redux/reducers/slice/appStateSlice';
17+
import { useDispatch, useSelector } from 'react-redux';
18+
import { changeProjectType } from '../../redux/reducers/slice/appStateSlice';
1919

2020

2121
const BottomTabs = (props): JSX.Element => {
2222
// state that controls which tab the user is on
23-
// const [state, dispatch] = useContext(StateContext); //deconstructing properties from Context interface?
2423
const dispatch = useDispatch();
25-
// const state = useSelector(store => store.appState)
2624
const { state, contextParam, style } = useSelector((store) => ({
2725
state: store.appState,
2826
contextParam: store.contextSlice,
@@ -31,7 +29,6 @@ const BottomTabs = (props): JSX.Element => {
3129
const [tab, setTab] = useState(0);
3230
const classes = useStyles();
3331
const [theme, setTheme] = useState('solarized_light');
34-
// const { style } = useContext(styleContext);
3532

3633
// breaks if handleChange is commented out
3734
const handleChange = (event: React.ChangeEvent, value: number) => {
@@ -41,8 +38,7 @@ const BottomTabs = (props): JSX.Element => {
4138
// When a user changes the project type, the code of all components is rerendered
4239
const handleProjectChange = event => {
4340
const projectType = event.target.value;
44-
dispatch(changeProjectType({projectType, contextParam}))
45-
// dispatch({ type: 'CHANGE PROJECT TYPE', payload: { projectType } });
41+
dispatch(changeProjectType({ projectType, contextParam }))
4642
};
4743
const { components, HTMLTypes } = state;
4844

app/src/components/bottom/CodePreview.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { useContext, useState, useRef, useEffect } from 'react';
2-
import StateContext from '../../context/context';
32
import AceEditor from 'react-ace';
43
import 'ace-builds/src-min-noconflict/ext-searchbox';
54
import 'ace-builds/src-noconflict/mode-javascript';
@@ -14,10 +13,9 @@ import useResizeObserver from '../../tree/useResizeObserver';
1413
import { unpkgPathPlugin } from '../../plugins/unpkg-path-plugin';
1514
import { fetchPlugin } from '../../plugins/fetch-plugin';
1615
import * as esbuild from 'esbuild-wasm';
17-
import store from '../../redux/store';
1816
import {codePreviewSave, codePreviewInput} from "../../redux/reducers/slice/codePreviewSlice";
1917
import { useDispatch, useSelector } from 'react-redux';
20-
// import { store } from './../../index';
18+
2119
const CodePreview: React.FC<{
2220
theme: string | null;
2321
setTheme: any | null;
@@ -38,8 +36,6 @@ const CodePreview: React.FC<{
3836
const wrapper = useRef();
3937
const dimensions = useResizeObserver(wrapper);
4038
const { height } = dimensions || 0;
41-
42-
// const [state] = useContext(StateContext);
4339
const state = useSelector(store => store.appState)
4440
const [, setDivHeight] = useState(0);
4541
let currentComponent = state.components.find(
@@ -59,10 +55,6 @@ const CodePreview: React.FC<{
5955
useEffect(() => {
6056
setInput(currentComponent.code);
6157
dispatch(codePreviewInput(currentComponent.code));
62-
// store.dispatch({
63-
// type: 'CODE_PREVIEW_INPUT',
64-
// payload: currentComponent.code
65-
// });
6658
}, [currentComponent, state.components]);
6759

6860
/**
@@ -72,7 +64,6 @@ const CodePreview: React.FC<{
7264
const handleChange = async (data) => {
7365
setInput(data);
7466
dispatch(codePreviewInput(data));
75-
// store.dispatch({ type: 'CODE_PREVIEW_INPUT', payload: data });
7667
if (!ref.current) {
7768
return;
7869
}
@@ -89,10 +80,6 @@ const CodePreview: React.FC<{
8980
}
9081
});
9182
dispatch(codePreviewSave(result.outputFiles[0].text))
92-
// store.dispatch({
93-
// type: 'CODE_PREVIEW_SAVE',
94-
// payload: result.outputFiles[0].text
95-
// });
9683
};
9784

9885
return (

app/src/components/bottom/CreationPanel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import { useSelector } from 'react-redux';
1010
const CreationPanel = (props): JSX.Element => {
1111
// const {style} = useContext(styleContext);
1212
const style = useSelector((store) => store.styleSlice);
13+
console.log('style from creation',style)
1314
return (
14-
<div className="creation-panel" style={style}>
15+
<div className="creation-panel" style={style.style}>
1516
<ComponentPanel isThemeLight={props.isThemeLight}/>
1617
<HTMLPanel isThemeLight={props.isThemeLight}/>
1718
</div>

app/src/components/bottom/UseStateModal.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, {useState, useContext, useRef} from 'react';
22
import Modal from '@mui/material/Modal';
3-
import StateContext from '../../context/context';
43
import TableStateProps from './TableStateProps';
54
import { useSelector } from 'react-redux';
65

app/src/containers/CustomizationPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ dispatch(updateUseContext({ useContextObj: useContextObj, contextParam: contextP
500500

501501
if (state.canvasFocus.childId === null) {
502502
return (
503-
<div className="column right" id="rightContainer" style={style}>
503+
<div className="column right" id="rightContainer" style={style.style}>
504504
<ProjectManager />
505505
<div className="rightPanelWrapper">
506506
<div>
@@ -526,7 +526,7 @@ dispatch(updateUseContext({ useContextObj: useContextObj, contextParam: contextP
526526
)
527527
}
528528
return (
529-
<div className="column right" id="rightContainer" style={style}>
529+
<div className="column right" id="rightContainer" style={style.style}>
530530
<ProjectManager />
531531
{/* -----------------------------MOVED PROJECT MANAGER-------------------------------------- */}
532532
<div className="rightPanelWrapper">

app/src/containers/LeftContainer.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import React, { useContext, useEffect, useCallback } from 'react';
22
import Grid from '@mui/material/Grid';
33
import ComponentDrag from '../components/right/ComponentDrag';
44
import DragDropPanel from '../components/left/DragDropPanel';
5-
// import StateContext from '../context/context';
6-
// import { styleContext } from './AppContainer';
75
import { useDispatch, useSelector } from 'react-redux';
86
import { deleteChild } from '../redux/reducers/slice/appStateSlice';
97

@@ -34,7 +32,7 @@ const LeftContainer = (props): JSX.Element => {
3432

3533
return (
3634
<div className="left-container hide-show">
37-
<div className="column left" style={style}>
35+
<div className="column left" style={style.style}>
3836
<Grid container direction="column" alignItems="center">
3937
<h4>Drag and Drop</h4>
4038
<DragDropPanel />

0 commit comments

Comments
 (0)