import * as React from 'react'; import { motion } from 'framer-motion'; import { Properties } from '../Properties/Properties'; import { Container } from '../SVG/Elements/Container'; interface IElementsSidebarProps { MainContainer: Container | null, isOpen: boolean, SelectedContainer: Container | null, onClick: () => void, onPropertyChange: (key: string, value: string) => void, selectContainer: (container: Container) => void } export class ElementsSidebar extends React.Component { public iterateChilds(handleContainer: (container: Container) => void): React.ReactNode { if (!this.props.MainContainer) { return null; } const it = this.props.MainContainer.MakeIterator(); for (const container of it) { handleContainer(container); } } public render() { const isOpenClasses = this.props.isOpen ? 'right-0' : '-right-64'; const containerRows: React.ReactNode[] = []; this.iterateChilds((container: Container) => { const depth: number = container.getDepth(); const key = container.props.properties.id.toString(); const text = '|\t'.repeat(depth) + key; const selectedClass: string = this.props.SelectedContainer !== null && this.props.SelectedContainer.props.properties.id === container.props.properties.id ? 'bg-blue-500 hover:bg-blue-600' : 'bg-slate-400 hover:bg-slate-600'; containerRows.push( this.props.selectContainer(container)}> { text } ); }); return (
Elements
{ containerRows }
); } }