Skip to content

add button not visible when focused #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions src/components/KonvaStage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
import TransformerComponent from './TransformerComponent.jsx';
import Rectangle from './Rectangle.jsx';


class KonvaStage extends Component {
state = {
x: undefined,
Expand Down Expand Up @@ -60,7 +59,13 @@ class KonvaStage extends Component {

render() {
const {
components, handleTransform, image, draggable, scaleX, scaleY, focusComponent,
components,
handleTransform,
image,
draggable,
scaleX,
scaleY,
focusComponent,
} = this.props;
const { selectedShapeName } = this.state;

Expand All @@ -80,21 +85,23 @@ class KonvaStage extends Component {
ref={(node) => {
this.group = node;
}}
draggable={draggable}>
<Image image={image} />
{components.map((comp, i) => <Rectangle
draggable={comp.draggable}
selectedShapeName={selectedShapeName}
key={i}
componentId={comp.id}
x={comp.position.x}
y={comp.position.y}
width={comp.position.width}
height={comp.position.height}
title={comp.title}
color={comp.color}
handleTransform={handleTransform}
/>)}
draggable={draggable}
>
{components.map((comp, i) => (
<Rectangle
draggable={comp.draggable}
selectedShapeName={selectedShapeName}
key={i}
componentId={comp.id}
x={comp.position.x}
y={comp.position.y}
width={comp.position.width}
height={comp.position.height}
title={comp.title}
color={comp.color}
handleTransform={handleTransform}
/>
))}
<TransformerComponent
focusComponent={focusComponent}
selectedShapeName={selectedShapeName}
Expand Down
69 changes: 41 additions & 28 deletions src/components/LeftColExpansionPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,36 @@ import { changeFocusChild } from '../actions/components';

const LeftColExpansionPanel = (props) => {
const {
index, classes, focusComponent, component, deleteComponent, addChild,
changeFocusComponent } = props;
index,
classes,
focusComponent,
component,
deleteComponent,
addChild,
changeFocusComponent,
} = props;
const { title, id, color } = component;

function isFocused() {
return focusComponent.title === title ? 'focused' : '';
}

return (
<div className={classes.root}>
<Grid item xs={12} md={6} style={{color: 'red'}}>
<List
style={{color: 'red'}}
>
<ListItem button component="a"
// style={
// if (components.find(comp => comp.title === focusComponent.title))
// }
style={{color: 'red'}}
onClick={()=> {
console.log({ title })
changeFocusComponent({ title })

}}
>
<Grid item xs={12} md={6} style={{ color: 'red' }}>
<List style={{ color: 'red' }}>
<ListItem
button
component="a"
// style={
// if (components.find(comp => comp.title === focusComponent.title))
// }
style={{ color: 'red' }}
onClick={() => {
console.log({ title });
changeFocusComponent({ title });
}}
>
<ListItemText
disableTypography
className={classes.light}
Expand All @@ -48,20 +57,24 @@ const LeftColExpansionPanel = (props) => {
{title}
</Typography>
}
secondary={'focused'}
secondary={isFocused()}
style={{ color }}
/>
<ListItemSecondaryAction>
<IconButton aria-label="Add">
<AddIcon
style={{ color, float: 'right' }}
onClick={() => {
console.log(title);
addChild( { title } );
changeFocusChild( { title } );
}}
/>
</IconButton>
{isFocused() ? (
<div />
) : (
<IconButton aria-label="Add">
<AddIcon
style={{ color, float: 'right' }}
onClick={() => {
console.log(title);
addChild({ title });
changeFocusChild({ title });
}}
/>
</IconButton>
)}
</ListItemSecondaryAction>
</ListItem>
</List>
Expand Down