Skip to content

Commit 97ca836

Browse files
Merge pull request #17 from ChristianEdwardPadilla/development
add button not visible when focused
2 parents 8441aa6 + 22c15e0 commit 97ca836

File tree

2 files changed

+65
-45
lines changed

2 files changed

+65
-45
lines changed

src/components/KonvaStage.jsx

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
import TransformerComponent from './TransformerComponent.jsx';
77
import Rectangle from './Rectangle.jsx';
88

9-
109
class KonvaStage extends Component {
1110
state = {
1211
x: undefined,
@@ -60,7 +59,13 @@ class KonvaStage extends Component {
6059

6160
render() {
6261
const {
63-
components, handleTransform, image, draggable, scaleX, scaleY, focusComponent,
62+
components,
63+
handleTransform,
64+
image,
65+
draggable,
66+
scaleX,
67+
scaleY,
68+
focusComponent,
6469
} = this.props;
6570
const { selectedShapeName } = this.state;
6671

@@ -80,21 +85,23 @@ class KonvaStage extends Component {
8085
ref={(node) => {
8186
this.group = node;
8287
}}
83-
draggable={draggable}>
84-
<Image image={image} />
85-
{components.map((comp, i) => <Rectangle
86-
draggable={comp.draggable}
87-
selectedShapeName={selectedShapeName}
88-
key={i}
89-
componentId={comp.id}
90-
x={comp.position.x}
91-
y={comp.position.y}
92-
width={comp.position.width}
93-
height={comp.position.height}
94-
title={comp.title}
95-
color={comp.color}
96-
handleTransform={handleTransform}
97-
/>)}
88+
draggable={draggable}
89+
>
90+
{components.map((comp, i) => (
91+
<Rectangle
92+
draggable={comp.draggable}
93+
selectedShapeName={selectedShapeName}
94+
key={i}
95+
componentId={comp.id}
96+
x={comp.position.x}
97+
y={comp.position.y}
98+
width={comp.position.width}
99+
height={comp.position.height}
100+
title={comp.title}
101+
color={comp.color}
102+
handleTransform={handleTransform}
103+
/>
104+
))}
98105
<TransformerComponent
99106
focusComponent={focusComponent}
100107
selectedShapeName={selectedShapeName}

src/components/LeftColExpansionPanel.jsx

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,36 @@ import { changeFocusChild } from '../actions/components';
1919

2020
const LeftColExpansionPanel = (props) => {
2121
const {
22-
index, classes, focusComponent, component, deleteComponent, addChild,
23-
changeFocusComponent } = props;
22+
index,
23+
classes,
24+
focusComponent,
25+
component,
26+
deleteComponent,
27+
addChild,
28+
changeFocusComponent,
29+
} = props;
2430
const { title, id, color } = component;
2531

32+
function isFocused() {
33+
return focusComponent.title === title ? 'focused' : '';
34+
}
35+
2636
return (
2737
<div className={classes.root}>
28-
<Grid item xs={12} md={6} style={{color: 'red'}}>
29-
<List
30-
style={{color: 'red'}}
31-
>
32-
<ListItem button component="a"
33-
// style={
34-
// if (components.find(comp => comp.title === focusComponent.title))
35-
// }
36-
style={{color: 'red'}}
37-
onClick={()=> {
38-
console.log({ title })
39-
changeFocusComponent({ title })
40-
41-
}}
42-
>
38+
<Grid item xs={12} md={6} style={{ color: 'red' }}>
39+
<List style={{ color: 'red' }}>
40+
<ListItem
41+
button
42+
component="a"
43+
// style={
44+
// if (components.find(comp => comp.title === focusComponent.title))
45+
// }
46+
style={{ color: 'red' }}
47+
onClick={() => {
48+
console.log({ title });
49+
changeFocusComponent({ title });
50+
}}
51+
>
4352
<ListItemText
4453
disableTypography
4554
className={classes.light}
@@ -48,20 +57,24 @@ const LeftColExpansionPanel = (props) => {
4857
{title}
4958
</Typography>
5059
}
51-
secondary={'focused'}
60+
secondary={isFocused()}
5261
style={{ color }}
5362
/>
5463
<ListItemSecondaryAction>
55-
<IconButton aria-label="Add">
56-
<AddIcon
57-
style={{ color, float: 'right' }}
58-
onClick={() => {
59-
console.log(title);
60-
addChild( { title } );
61-
changeFocusChild( { title } );
62-
}}
63-
/>
64-
</IconButton>
64+
{isFocused() ? (
65+
<div />
66+
) : (
67+
<IconButton aria-label="Add">
68+
<AddIcon
69+
style={{ color, float: 'right' }}
70+
onClick={() => {
71+
console.log(title);
72+
addChild({ title });
73+
changeFocusChild({ title });
74+
}}
75+
/>
76+
</IconButton>
77+
)}
6578
</ListItemSecondaryAction>
6679
</ListItem>
6780
</List>

0 commit comments

Comments
 (0)