Skip to content

Commit 6772582

Browse files
committed
Commented most of Konva Stage
1 parent b1f9e10 commit 6772582

File tree

3 files changed

+44
-29
lines changed

3 files changed

+44
-29
lines changed

src/components/KonvaStage.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ interface PropsInt {
1212
image: HTMLImageElement;
1313
components: ComponentsInt;
1414
focusComponent: ComponentInt;
15-
selectableChildren: Array<number>;
15+
// selectableChildren: Array<number>; **It's expecting this prop in the interface, but is never used.**
1616
classes: any;
17-
addComponent: any;
18-
addChild: any;
19-
changeFocusComponent: any;
17+
// addComponent: any; **It's expecting this prop in the interface, but is never used.**
18+
// addChild: any; **It's expecting this prop in the interface, but is never used.**
19+
// changeFocusComponent: any; **It's expecting this prop in the interface, but is never used.**
2020
changeFocusChild: any;
21-
deleteComponent: any;
22-
createApp: any;
23-
deleteAllData: any;
21+
// deleteComponent: any; **It's expecting this prop in the interface, but is never used.**
22+
// createApp: any; **It's expecting this prop in the interface, but is never used.**
23+
// deleteAllData: any; **It's expecting this prop in the interface, but is never used.**
2424
handleTransform: any;
2525
focusChild: any;
2626
changeComponentFocusChild: any;
2727
deleteChild: any;
2828
scaleX: number;
2929
scaleY: number;
30-
draggable: boolean;
30+
// draggable: boolean; **THIS ONE is actually never passed down from the parent but reassigned in a seperate object below in this file.**
3131
}
3232

3333
interface StateInt {
@@ -41,6 +41,10 @@ interface StateInt {
4141
class KonvaStage extends Component<PropsInt, StateInt> {
4242
constructor(props: PropsInt) {
4343
super(props);
44+
//the main purpose of this state, although not supposed to be here per redux rules I believe,
45+
//is to initialize the values of the canvas height and width in pixels, and 'blockSnapSize' refers to
46+
//the height and width of the squares on the grid so it looks like graphing paper. The grid property doesn't do
47+
//anything, and the gridStroke is the stroke width of the squares.
4448
this.state = {
4549
stageWidth: 1800,
4650
stageHeight: 1300,
@@ -180,8 +184,8 @@ class KonvaStage extends Component<PropsInt, StateInt> {
180184
handleTransform,
181185
focusComponent,
182186
focusChild,
183-
deleteChild,
184-
classes
187+
// deleteChild, **neither of these are read**
188+
// classes
185189
} = this.props;
186190

187191
return (

src/containers/AppContainer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ type State = {
3636

3737
//I'm still trying to figure out the typing for the 'workspace' property,
3838
//feel free to assign it the correct type. It seems to point to componentReducer.
39+
//Details on some of these are listed in the render where they are passed down.
3940
const mapStateToProps = (store: {workspace: any}) => ({
40-
imageSource: store.workspace.imageSource,
41+
imageSource: store.workspace.imageSource,
4142
components: store.workspace.components,
4243
totalComponents: store.workspace.totalComponents,
4344
focusComponent: store.workspace.focusComponent,

src/containers/MainContainer.tsx

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ interface StateInt {
4646
modal: any;
4747
}
4848

49-
const IPC = require('electron').ipcRenderer;
49+
// const IPC = require('electron').ipcRenderer; **Variable declared but never used**
5050

5151
const mapDispatchToProps = (dispatch: any) => ({
52+
//this passes the coordinate info from any component bound to the Konva Transformer to the store
5253
handleTransformation: (
5354
componentId: number,
5455
childId: number,
@@ -67,19 +68,25 @@ const mapDispatchToProps = (dispatch: any) => ({
6768
height
6869
})
6970
),
70-
changeImagePath: (imageSource: string) =>
71-
dispatch(actions.changeImagePath(imageSource)),
71+
//this doesn't do anything here
72+
// changeImagePath: (imageSource: string) =>
73+
// dispatch(actions.changeImagePath(imageSource)),
7274

75+
76+
//this function changes the focus of the child within the focused component, thereby binding it to the transformer as a node
7377
changeFocusChild: ({ childId }: { childId: number }) =>
7478
dispatch(changeFocusChild({ childId })),
79+
80+
//the difference between this dispatch function and the one above, is that this once alters the focused child status within the array of components,
81+
//vs the one above changes the focusChild property in the state
7582
changeComponentFocusChild: ({
7683
componentId,
7784
childId
7885
}: {
7986
componentId: number;
8087
childId: number;
8188
}) => dispatch(changeComponentFocusChild({ componentId, childId })),
82-
deleteChild: ({}) => dispatch(deleteChild({})) // if u send no prms, function will delete focus child.
89+
deleteChild: ({}) => dispatch(deleteChild({})) // if u send no prms, function will delete focus child. <-- This comment was already here, unsure what exactly it means.
8390
});
8491

8592
const mapStateToProps = (store: any) => ({
@@ -89,18 +96,20 @@ const mapStateToProps = (store: any) => ({
8996
});
9097

9198
class MainContainer extends Component<PropsInt, StateInt> {
92-
state = {
93-
draggable: false,
94-
toggleClass: true,
95-
scaleX: 1,
96-
scaleY: 1,
97-
x: 0,
98-
y: 0,
99-
modal: ''
100-
};
99+
//Again, state should not be created outside of the single source of truth
100+
//Actually upon further examination, it looks like this state isn't manipulated at all.
101+
// state = {
102+
// draggable: false,
103+
// toggleClass: true,
104+
// scaleX: 1,
105+
// scaleY: 1,
106+
// x: 0,
107+
// y: 0,
108+
// modal: ''
109+
// };
101110

102111
render() {
103-
const { draggable, scaleX, scaleY, modal, toggleClass } = this.state;
112+
//const { draggable, modal } = this.state; //this is being destructured but never read.
104113
const {
105114
components,
106115
handleTransformation,
@@ -113,18 +122,19 @@ class MainContainer extends Component<PropsInt, StateInt> {
113122
image
114123
} = this.props;
115124

116-
const { main }: { main: HTMLDivElement } = this;
125+
// const { main }: { main: HTMLDivElement } = this; **I don't think this has any function**
117126

118127
return (
119128
<MuiThemeProvider theme={theme}>
120129
<div className='main-container'>
121-
{modal}
122-
<div className='main' ref={main}>
130+
{/* {modal} */}
131+
<div className='main' //ref={main} **no function, commenting out**
132+
>
123133
<KonvaStage
124134
image={image}
125135
scaleX={1}
126136
scaleY={1}
127-
draggable={draggable}
137+
// draggable={draggable} this is also from this local state but never read past this container
128138
components={components}
129139
handleTransform={handleTransformation}
130140
focusComponent={focusComponent}

0 commit comments

Comments
 (0)