Refactor Editor and module functions (#15)
All checks were successful
continuous-integration/drone/push Build is passing

Moved all module functions to separate utils modules

Replaced standard with standard with typescript

Extracted UI elements to separate component

Reviewed-on: https://git.siklos-chaneru.duckdns.org/Siklos/svg-layout-designer-react/pulls/15
This commit is contained in:
Siklos 2022-08-05 15:38:44 -04:00
parent 8e34d6b72a
commit 293af45144
26 changed files with 477 additions and 367 deletions

View file

@ -1,31 +1,32 @@
import * as React from 'react';
import { motion } from 'framer-motion';
import { Properties } from '../Properties/Properties';
import { IContainerModel, getDepth, MakeIterator } from '../../Interfaces/ContainerModel';
import { IContainerModel } from '../../Interfaces/ContainerModel';
import { getDepth, MakeIterator } from '../../utils/itertools';
interface IElementsSidebarProps {
MainContainer: IContainerModel | null,
isOpen: boolean,
MainContainer: IContainerModel | null
isOpen: boolean
isHistoryOpen: boolean
SelectedContainer: IContainerModel | null,
onClick: () => void,
onPropertyChange: (key: string, value: string) => void,
SelectedContainer: IContainerModel | null
onClick: () => void
onPropertyChange: (key: string, value: string) => void
selectContainer: (container: IContainerModel) => void
}
export class ElementsSidebar extends React.PureComponent<IElementsSidebarProps> {
public iterateChilds(handleContainer: (container: IContainerModel) => void): React.ReactNode {
if (!this.props.MainContainer) {
if (this.props.MainContainer == null) {
return null;
}
const it = MakeIterator(this.props.MainContainer);
for (const container of it) {
handleContainer(container as IContainerModel);
handleContainer(container);
}
}
public render() {
public render(): JSX.Element {
let isOpenClasses = '-right-64';
if (this.props.isOpen) {
isOpenClasses = this.props.isHistoryOpen