Container: Updated id format + add feedback for the selected container
This commit is contained in:
parent
893b525d45
commit
94c9ac26c0
2 changed files with 8 additions and 2 deletions
|
@ -102,7 +102,7 @@ class App extends React.Component<IAppProps> {
|
||||||
const depth: number = Container.getDepth(parent) + 1;
|
const depth: number = Container.getDepth(parent) + 1;
|
||||||
const container = new Container({
|
const container = new Container({
|
||||||
parent,
|
parent,
|
||||||
id: `${depth}-${parent.props.children.length.toString()}`,
|
id: `${type}-${depth}-${parent.props.children.length.toString()}`,
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
width: properties?.Width,
|
width: properties?.Width,
|
||||||
|
@ -135,6 +135,7 @@ class App extends React.Component<IAppProps> {
|
||||||
<button className='fixed z-10 top-4 left-4 text-lg bg-blue-200 hover:bg-blue-300 transition-all drop-shadow-md hover:drop-shadow-lg py-2 px-3 rounded-lg' onClick={() => this.ToggleSidebar()}>☰ Menu</button>
|
<button className='fixed z-10 top-4 left-4 text-lg bg-blue-200 hover:bg-blue-300 transition-all drop-shadow-md hover:drop-shadow-lg py-2 px-3 rounded-lg' onClick={() => this.ToggleSidebar()}>☰ Menu</button>
|
||||||
<SVGSidebar
|
<SVGSidebar
|
||||||
MainContainer={this.state.MainContainer}
|
MainContainer={this.state.MainContainer}
|
||||||
|
SelectedContainer={this.state.SelectedContainer}
|
||||||
isOpen={this.state.isSVGSidebarOpen}
|
isOpen={this.state.isSVGSidebarOpen}
|
||||||
onClick={() => this.ToggleSVGSidebar()}
|
onClick={() => this.ToggleSVGSidebar()}
|
||||||
selectContainer={(container: Container) => this.SelectContainer(container)}
|
selectContainer={(container: Container) => this.SelectContainer(container)}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { Container } from '../SVG/Elements/Container';
|
||||||
interface ISVGSidebarProps {
|
interface ISVGSidebarProps {
|
||||||
MainContainer: Container | null,
|
MainContainer: Container | null,
|
||||||
isOpen: boolean,
|
isOpen: boolean,
|
||||||
|
SelectedContainer: Container | null,
|
||||||
onClick: () => void,
|
onClick: () => void,
|
||||||
selectContainer: (container: Container) => void
|
selectContainer: (container: Container) => void
|
||||||
}
|
}
|
||||||
|
@ -46,8 +47,12 @@ export class SVGSidebar extends React.Component<ISVGSidebarProps> {
|
||||||
this.iterateChilds((container: Container, depth: number) => {
|
this.iterateChilds((container: Container, depth: number) => {
|
||||||
const key = container.props.id.toString();
|
const key = container.props.id.toString();
|
||||||
const text = '\t\t'.repeat(depth) + key;
|
const text = '\t\t'.repeat(depth) + key;
|
||||||
|
const selectedClass: string = this.props.SelectedContainer !== null &&
|
||||||
|
this.props.SelectedContainer.props.id === container.props.id
|
||||||
|
? 'bg-blue-500 hover:bg-slate-500'
|
||||||
|
: 'bg-slate-400 hover:bg-slate-600';
|
||||||
containerRows.push(
|
containerRows.push(
|
||||||
<button className='sidebar-row whitespace-pre text-left hover:bg-slate-600 transition-all' key={key} onClick={() => this.props.selectContainer(container)}>
|
<button className={`sidebar-row whitespace-pre text-left transition-all ${selectedClass}`} key={key} onClick={() => this.props.selectContainer(container)}>
|
||||||
{ text }
|
{ text }
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue