Skip to content

Commit d0f1c05

Browse files
pseudochild is always rendered first now, regardless of size
1 parent aa3010b commit d0f1c05

File tree

6 files changed

+28
-44
lines changed

6 files changed

+28
-44
lines changed

src/components/CodePreview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CodePreview extends Component<Props> {
2525
direction: 'rtl',
2626
paddingLeft: '20px',
2727
color: '#D3D3D3',
28-
fontSize: 16,
28+
fontSize: 15,
2929
overflow: 'auto',
3030
}}
3131
>

src/components/HtmlAttr.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const styles = theme => ({
2626
input: {
2727
color: '#fff',
2828
opacity: '0.7',
29-
marginBottom: '10px',
29+
marginBottom: '15px',
3030
},
3131
});
3232

@@ -72,6 +72,7 @@ class HtmlAttr extends Component {
7272
classes: {
7373
root: classes.cssLabel,
7474
focused: classes.cssFocused,
75+
input: classes.input,
7576
},
7677
}}
7778
InputProps={{

src/components/KonvaStage.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class KonvaStage extends Component {
1010
constructor(props) {
1111
super(props);
1212
this.state = {
13-
stageWidth: 1000,
14-
stageHeight: 1000,
13+
stageWidth: 1500,
14+
stageHeight: 1500,
1515
blockSnapSize: 10,
1616
grid: [],
1717
gridStroke: 1,
@@ -47,13 +47,13 @@ class KonvaStage extends Component {
4747
// here we should add listener for "container" resize
4848
// take a look here https://developers.google.com/web/updates/2016/10/resizeobserver
4949
// for simplicity I will just listen window resize
50-
window.addEventListener('resize', this.checkSize);
50+
// window.addEventListener('resize', this.checkSize);
5151
this.container.addEventListener('keydown', this.handleKeyDown);
5252
this.createGrid();
5353
}
5454

5555
componentWillUnmount() {
56-
window.removeEventListener('resize', this.checkSize);
56+
// window.removeEventListener('resize', this.checkSize);
5757
this.container.removeEventListener('keydown', this.handleKeyDown);
5858
}
5959

@@ -67,15 +67,17 @@ class KonvaStage extends Component {
6767
};
6868

6969
handleKeyDown = e => {
70-
if (e.keyCode === 46 || e.keyCode === 8) {
70+
// backspace and delete keys are keyCode 8 and 46, respectively
71+
// this function is only used for deleting children atm, could be used for other things
72+
if (e.keyCode === 8 || e.keyCode === 46) {
7173
this.props.deleteChild({});
7274
}
7375
};
7476

7577
handleStageMouseDown = e => {
76-
// // clicked on stage - clear selection
78+
// clicked on stage - clear selection
7779
if (e.target === e.target.getStage()) {
78-
// add functionality for allowing no focusChild
80+
// TODO add functionality for allowing no focusChild
7981
console.log('user clicked on canvas:');
8082
return;
8183
}
@@ -208,11 +210,17 @@ class KonvaStage extends Component {
208210
imageSource={child.htmlElement == 'Image' && child.HTMLInfo.Src ? child.HTMLInfo.Src : null}
209211
/>
210212
))
211-
.sort((rectA, rectB) => rectB.props.width * rectB.props.height - rectA.props.width * rectA.props.height)
213+
.sort((rectA, rectB) => {
214+
if (rectB.props.childId === -1) {
215+
return 1;
216+
}
217+
return rectB.props.width * rectB.props.height - rectA.props.width * rectA.props.height;
218+
})
212219
// reasoning for the sort:
213220
// Konva determines zIndex (which rect is clicked on if rects overlap) based on rendering order
214221
// as long as the smallest components are rendered last they will always be accessible over the big boys
215222
// to guarantee they are rendered last, sort the array in reverse order by size
223+
// only exception is the pseudochild, which should always be rendered first for UX, regardless of size
216224
// THIS COULD BE A BIG PERFORMANCE PROBLEM (PROBABLY WILL BE!)
217225
// TRY TO REFACTOR TO ONLY CHANGE ORDER OF RENDERING IF A BOX IS RESIZED
218226
}

src/components/LeftColExpansionPanel.jsx

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ const LeftColExpansionPanel = props => {
4646
<Grid item xs={9}>
4747
<div
4848
className={classes.root}
49-
style={
50-
!isFocused() ? {} : { boxShadow: "0 10px 10px rgba(0,0,0,0.22)" }
51-
}
49+
style={!isFocused() ? {} : { boxShadow: '0 10px 10px rgba(0,0,0,0.45)' }}
5250
>
5351
<Grid item xs={12} style={{ color: "red" }}>
5452
<List style={{ color: "red" }}>
@@ -78,33 +76,6 @@ const LeftColExpansionPanel = props => {
7876
<div />
7977
) : (
8078
<Fragment>
81-
{/* <span>
82-
{directParents ? (
83-
<p
84-
style={{
85-
padding: '0px',
86-
marginTop: '0px',
87-
marginLeft: '15px',
88-
color: '#D3D3D3',
89-
fontSize: '12px',
90-
}}
91-
>
92-
Used in: {directParents}
93-
</p>
94-
) : (
95-
<p
96-
style={{
97-
padding: '0px',
98-
marginTop: '0px',
99-
marginLeft: '15px',
100-
color: '#D3D3D3',
101-
fontSize: '12px',
102-
}}
103-
>
104-
Not used
105-
</p>
106-
)}
107-
</span> */}
10879
<Button
10980
variant="text"
11081
size="small"

src/containers/LeftContainer.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import LeftColExpansionPanel from '../components/LeftColExpansionPanel';
1616
import HTMLComponentPanel from '../components/HTMLComponentPanel';
1717
import * as actions from '../actions/components';
1818
import { ComponentInt, ComponentsInt, ChildInt } from '../utils/interfaces';
19+
import createModal from '../utils/createModal.util';
20+
import cloneDeep from '../utils/cloneDeep.ts';
21+
22+
const IPC = require('electron').ipcRenderer;
1923

2024
type Props = {
2125
components: ComponentsInt;
@@ -101,7 +105,7 @@ class LeftContainer extends Component<Props> {
101105
} = this.props;
102106
const { componentName, modal } = this.state;
103107

104-
const componentsExpansionPanel = components
108+
const componentsExpansionPanel = cloneDeep(components)
105109
.sort((b: ComponentInt, a: ComponentInt) => b.id - a.id) // sort by id value of comp
106110
.map((component, i) => (
107111
<LeftColExpansionPanel
@@ -130,7 +134,6 @@ class LeftContainer extends Component<Props> {
130134
onChange={this.handleChange}
131135
onKeyPress={ev => {
132136
if (ev.key === 'Enter') {
133-
// Do code here
134137
this.handleAddComponent();
135138
ev.preventDefault();
136139
}

src/public/styles/style.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ LEFT COLUMN
7777
display: flex;
7878
flex-direction: column;
7979
position: relative;
80-
/* overflow-x: hidden; */
80+
overflow-x: hidden;
8181
}
8282

8383
.component-input {
@@ -89,7 +89,8 @@ LEFT COLUMN
8989
display: flex;
9090
/* max-height: 80%; */
9191
height: 60%;
92-
/* overflow-y: hidden; */
92+
overflow-y: scroll;
93+
overflow-x: hidden;
9394
padding: 1%;
9495
}
9596

0 commit comments

Comments
 (0)