Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
feat(component): element can now be selected
Browse files Browse the repository at this point in the history
  • Loading branch information
Lasse Küchler committed Dec 11, 2017
1 parent 706a296 commit 15397e1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/component/container/elementWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface ElementWrapperProps {
active?: boolean;
open?: boolean;
title: string;
handleClick?: React.MouseEventHandler<HTMLElement>;
}

export class ElementWrapper extends React.Component<ElementWrapperProps, ElementWrapperState> {
Expand All @@ -29,12 +30,13 @@ export class ElementWrapper extends React.Component<ElementWrapperProps, Element
}

public render(): JSX.Element {
const { active, children, title } = this.props;
const { active, children, handleClick, title } = this.props;
return (
<Element
title={title}
open={!this.state.open}
active={active}
handleClick={handleClick}
handleIconClick={this.handleIconClick}
>
{children}
Expand Down
8 changes: 7 additions & 1 deletion src/component/container/element_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class ElementList extends React.Component<ElementListProps> {

public renderList(item: ListPropsListItem, key?: number): JSX.Element {
return (
<ElementWrapper title={item.value} key={key}>
<ElementWrapper title={item.value} key={key} handleClick={item.onClick}>
{item.children &&
item.children.length > 0 &&
item.children.map((child, index) => this.renderList(child, index))}
Expand Down Expand Up @@ -59,9 +59,15 @@ export class ElementList extends React.Component<ElementListProps> {

const patternPath: string = element.getPatternPath() as string;

const updatePageElement: React.MouseEventHandler<HTMLElement> = event => {
event.stopPropagation();
this.props.store && this.props.store.setSelectedElement(element);
};

return {
label: key,
value: patternPath.replace(/^.*\//, ''),
onClick: updatePageElement,
children: items
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/component/presentation/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface ListPropsListItem {
label?: string;
value: string;

onClick?(event: {}): void;
onClick?: React.MouseEventHandler<HTMLElement>;
}

export class List extends React.Component<ListProps> {
Expand Down

0 comments on commit 15397e1

Please sign in to comment.