Container: Updated id format + add feedback for the selected container

This commit is contained in:
Siklos 2022-08-01 11:11:07 +02:00
parent 893b525d45
commit 94c9ac26c0
2 changed files with 8 additions and 2 deletions

View file

@ -4,6 +4,7 @@ import { Container } from '../SVG/Elements/Container';
interface ISVGSidebarProps {
MainContainer: Container | null,
isOpen: boolean,
SelectedContainer: Container | null,
onClick: () => void,
selectContainer: (container: Container) => void
}
@ -46,8 +47,12 @@ export class SVGSidebar extends React.Component<ISVGSidebarProps> {
this.iterateChilds((container: Container, depth: number) => {
const key = container.props.id.toString();
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(
<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 }
</button>
);