diff --git a/docs/ComponentStructure.drawio b/docs/ComponentStructure.drawio
deleted file mode 100644
index 6bfd739..0000000
--- a/docs/ComponentStructure.drawio
+++ /dev/null
@@ -1 +0,0 @@
-5ZxRc5s4EMc/jeeenAEE2H5sEqftzGWm01zb673cKCCDerLkEXLs9NOfBAIb5KbqTGrJdl9qFgnQb1d/VismI3Cz3L7lcFXesxyRURTk2xG4HUXyXzyT/ynLc2OZTNPGUHCcN6ZwZ3jA35E2Btq6xjmqeg0FY0TgVd+YMUpRJno2yDnb9JstGOnfdQULZBgeMkhM6xeci7KxTqPJzv4O4aJs7xymesBL2DbWI6lKmLPNngnMR+CGMyaaX8vtDSIKXsul6Xf3g7Pdg3FEhU2Hb18XtJyjj/lGLBbfP2///XIPxyHQDyee2xGjXALQh4yLkhWMQjLfWa85W9McqcsG8mjX5k/GVtIYSuM3JMSz9iZcCyZNpVgSfba5p7rRD8eiTRVb8wy9NAAdE5AXSLzQLuqIy1BFbIkEf5b9OCJQ4Kf+c0AdM0XXbodV/tBkf4VyfCGUE6eUm+s+QbLWd3qzWhng+1g3JRboYQXr0W+khB1C+IS4QNuXIZqD1h3iVM9/LYBhoo83OzkJW40o96Sk7ff6nBIX0Yi2WPytul8l+ujr3pnbrb5yffCsD14xgiPLCAZOIzg9cZ2wpRy7pBwZOjHPsWB8FKVEPvT1o/pViJpMY8Gt4eHzW9mz31w+A951cKw2IIl7atOpiDO1AaEB5bRiGthmGE6DGkSXgnnqFPOp58vWmFOnmE89YbbGPHGK2Ukm6AKz04UJMBKOT+8tko1PFeLq0lQgvlA5g48JxzgM+usbMHGdcYSTE4/q2DKqnUp0bAR1nRz/NKpvGBUQ00oNsJQxHeicmqClAuVjjMfAtxBPDPj3kuk9omsLD9xhXglFNOMIUS+JJ9M+cffLmLYefbKiklqKitP0OnSyWHRcmrL1jNNUMTVzGJpJKeeMEJR/RDATUsg/QPoPY8vI8j1Qd1Y5zkKVU/T7oHoqvNQkME16mhRPTU3qtq2Oo0mnvuafWEb+zGXkT4zI1ymMilzXMRn335PJzPV7cmqmhYigzK68eq06Kb9mAtKC1Gow6O2VJCSRb/hnBv5bLPPqCjNqwf+vWoCJDG3FtWQbqp7xkT2hTp2zXex76JDhfJgErh0SmhPCzHHkgEWfRSXfjf+hG0Zk5INbyqiS7gUmZGCCBBdUHmZIVQmkQeHDGSRv9IklzvNa9w/B77vnNSbEYLMzOZC3pwfwg9+G35wQ4dUVPV8PDDeAnHugnW2XMQHiWX8CxAd2+4+L3/wq4ozxp4NKTcfVGf7okvB3hTFv8Jul9zPGPx5UzbpsyBV+cPLfs9iW4kFw2DNH+qLFLMZfQ5sFV1MxDh5VYxklMkjknWSKX3mZ3YeDd+uBAsxxk/vIrMM/4Bw9WrHvWgZsUS+sliupKlT4yX6cxr7RB7NTVxfbyi9wWvptHX8BnJ1ufkRmjV3vila/oCol2+yKNWte05IPm9XPL4HqK/opMpF3IhOZ5d93uBJMXfqnzmg+FP2j0g6o36tB2e/ulwO69ao/DjALaHeEyelIi+u1EFZ1zbaDvMyyyXj2ch0vHRF654d2kdDPMd9nVg5oPeU/90H9st3zc4fd1J8PnK3UOhNVFuT3GzeJ5inU8cdguLPi3hGmDll+b6O2C1WJoRUfH3kP9cY97/iiCpdDuXddNo4jg35w1vsmvm1cxRdVuYwC3+LfrKidMf5x6Nu2VWxW1s6a/yD+k8R8/R6Xv1mLOGf+sXf6Y6b958x/+L23e/4X9dmOudz6ffojD3d/86Q+t/eXY8D8fw==
\ No newline at end of file
diff --git a/src/Components/API/api.ts b/src/Components/API/api.ts
index 9acea24..e113cc9 100644
--- a/src/Components/API/api.ts
+++ b/src/Components/API/api.ts
@@ -1,10 +1,10 @@
-import { IConfiguration } from '../../Interfaces/IConfiguration';
+import { Configuration } from '../../Interfaces/Configuration';
/**
* Fetch the configuration from the API
* @returns {Configation} The model of the configuration for the application
*/
-export async function fetchConfiguration(): Promise {
+export async function fetchConfiguration(): Promise {
const url = `${import.meta.env.VITE_API_URL}`;
// The test library cannot use the Fetch API
// @ts-expect-error
@@ -15,7 +15,7 @@ export async function fetchConfiguration(): Promise {
})
.then(async(response) =>
await response.json()
- ) as IConfiguration;
+ ) as Configuration;
}
return await new Promise((resolve) => {
const xhr = new XMLHttpRequest();
diff --git a/src/Components/App/App.tsx b/src/Components/App/App.tsx
index c85d322..c25c37e 100644
--- a/src/Components/App/App.tsx
+++ b/src/Components/App/App.tsx
@@ -1,9 +1,8 @@
import React, { useEffect, useState } from 'react';
import './App.scss';
import { MainMenu } from '../MainMenu/MainMenu';
-import { ContainerModel } from '../../Interfaces/IContainerModel';
-import Editor from '../Editor/Editor';
-import { IEditorState } from '../../Interfaces/IEditorState';
+import { ContainerModel } from '../../Interfaces/ContainerModel';
+import Editor, { IEditorState } from '../Editor/Editor';
import { LoadState } from './Load';
import { LoadEditor, NewEditor } from './MenuActions';
import { DEFAULT_CONFIG, DEFAULT_MAINCONTAINER_PROPS } from '../../utils/default';
diff --git a/src/Components/App/Load.ts b/src/Components/App/Load.ts
index 909dfc9..b5459c7 100644
--- a/src/Components/App/Load.ts
+++ b/src/Components/App/Load.ts
@@ -1,6 +1,6 @@
import { Dispatch, SetStateAction } from 'react';
import { Revive } from '../../utils/saveload';
-import { IEditorState } from '../../Interfaces/IEditorState';
+import { IEditorState } from '../Editor/Editor';
export function LoadState(
editorState: IEditorState,
diff --git a/src/Components/App/MenuActions.ts b/src/Components/App/MenuActions.ts
index c849ca8..2669c1a 100644
--- a/src/Components/App/MenuActions.ts
+++ b/src/Components/App/MenuActions.ts
@@ -1,8 +1,8 @@
import { Dispatch, SetStateAction } from 'react';
-import { IConfiguration } from '../../Interfaces/IConfiguration';
-import { ContainerModel } from '../../Interfaces/IContainerModel';
+import { Configuration } from '../../Interfaces/Configuration';
+import { ContainerModel } from '../../Interfaces/ContainerModel';
import { fetchConfiguration } from '../API/api';
-import { IEditorState } from "../../Interfaces/IEditorState";
+import { IEditorState } from '../Editor/Editor';
import { LoadState } from './Load';
export function NewEditor(
@@ -11,7 +11,7 @@ export function NewEditor(
): void {
// Fetch the configuration from the API
fetchConfiguration()
- .then((configuration: IConfiguration) => {
+ .then((configuration: Configuration) => {
// Set the main container from the given properties of the API
const MainContainer = new ContainerModel(
null,
diff --git a/src/Components/Editor/ContainerOperations.ts b/src/Components/Editor/ContainerOperations.ts
index 40391c5..fde4a72 100644
--- a/src/Components/Editor/ContainerOperations.ts
+++ b/src/Components/Editor/ContainerOperations.ts
@@ -1,7 +1,7 @@
import { Dispatch, SetStateAction } from 'react';
-import { IHistoryState } from '../../Interfaces/IHistoryState';
-import { IConfiguration } from '../../Interfaces/IConfiguration';
-import { ContainerModel, IContainerModel } from '../../Interfaces/IContainerModel';
+import { HistoryState } from '../../Interfaces/HistoryState';
+import { Configuration } from '../../Interfaces/Configuration';
+import { ContainerModel, IContainerModel } from '../../Interfaces/ContainerModel';
import { findContainerById } from '../../utils/itertools';
import { getCurrentHistory } from './Editor';
@@ -11,9 +11,9 @@ import { getCurrentHistory } from './Editor';
*/
export function SelectContainer(
container: ContainerModel,
- fullHistory: IHistoryState[],
+ fullHistory: HistoryState[],
historyCurrentStep: number,
- setHistory: Dispatch>,
+ setHistory: Dispatch>,
setHistoryCurrentStep: Dispatch>
): void {
const history = getCurrentHistory(fullHistory, historyCurrentStep);
@@ -46,9 +46,9 @@ export function SelectContainer(
*/
export function DeleteContainer(
containerId: string,
- fullHistory: IHistoryState[],
+ fullHistory: HistoryState[],
historyCurrentStep: number,
- setHistory: Dispatch>,
+ setHistory: Dispatch>,
setHistoryCurrentStep: Dispatch>
): void {
const history = getCurrentHistory(fullHistory, historyCurrentStep);
@@ -108,10 +108,10 @@ export function DeleteContainer(
*/
export function AddContainerToSelectedContainer(
type: string,
- configuration: IConfiguration,
- fullHistory: IHistoryState[],
+ configuration: Configuration,
+ fullHistory: HistoryState[],
historyCurrentStep: number,
- setHistory: Dispatch>,
+ setHistory: Dispatch>,
setHistoryCurrentStep: Dispatch>
): void {
const history = getCurrentHistory(fullHistory, historyCurrentStep);
@@ -151,10 +151,10 @@ export function AddContainer(
index: number,
type: string,
parentId: string,
- configuration: IConfiguration,
- fullHistory: IHistoryState[],
+ configuration: Configuration,
+ fullHistory: HistoryState[],
historyCurrentStep: number,
- setHistory: Dispatch>,
+ setHistory: Dispatch>,
setHistoryCurrentStep: Dispatch>
): void {
const history = getCurrentHistory(fullHistory, historyCurrentStep);
diff --git a/src/Components/Editor/Editor.tsx b/src/Components/Editor/Editor.tsx
index 5c8e334..09627e4 100644
--- a/src/Components/Editor/Editor.tsx
+++ b/src/Components/Editor/Editor.tsx
@@ -1,29 +1,32 @@
-import React, { useRef } from 'react';
+import React from 'react';
import './Editor.scss';
-import { IConfiguration } from '../../Interfaces/IConfiguration';
+import { Configuration } from '../../Interfaces/Configuration';
import { SVG } from '../SVG/SVG';
-import { IHistoryState } from '../../Interfaces/IHistoryState';
+import { HistoryState } from '../../Interfaces/HistoryState';
import { UI } from '../UI/UI';
import { SelectContainer, DeleteContainer, AddContainerToSelectedContainer, AddContainer } from './ContainerOperations';
import { SaveEditorAsJSON, SaveEditorAsSVG } from './Save';
import { onKeyDown } from './Shortcuts';
import { OnPropertyChange, OnPropertiesSubmit } from './PropertiesOperations';
-import EditorEvents from '../../Events/EditorEvents';
-import { IEditorState } from '../../Interfaces/IEditorState';
interface IEditorProps {
- configuration: IConfiguration
- history: IHistoryState[]
+ configuration: Configuration
+ history: HistoryState[]
historyCurrentStep: number
}
-export const getCurrentHistory = (history: IHistoryState[], historyCurrentStep: number): IHistoryState[] => history.slice(0, historyCurrentStep + 1);
-export const getCurrentHistoryState = (history: IHistoryState[], historyCurrentStep: number): IHistoryState => history[historyCurrentStep];
+export interface IEditorState {
+ history: HistoryState[]
+ historyCurrentStep: number
+ configuration: Configuration
+}
+
+export const getCurrentHistory = (history: HistoryState[], historyCurrentStep: number): HistoryState[] => history.slice(0, historyCurrentStep + 1);
+export const getCurrentHistoryState = (history: HistoryState[], historyCurrentStep: number): HistoryState => history[historyCurrentStep];
const Editor: React.FunctionComponent = (props) => {
- const [history, setHistory] = React.useState(structuredClone(props.history));
+ const [history, setHistory] = React.useState(structuredClone(props.history));
const [historyCurrentStep, setHistoryCurrentStep] = React.useState(props.historyCurrentStep);
- const editorRef = useRef(null);
React.useEffect(() => {
const onKeyUp = (event: KeyboardEvent): void => onKeyDown(
@@ -35,17 +38,6 @@ const Editor: React.FunctionComponent = (props) => {
window.addEventListener('keyup', onKeyUp);
- const events = EditorEvents;
- const editorState: IEditorState = {
- history,
- historyCurrentStep,
- configuration: props.configuration
- };
-
- for (const event of events) {
- editorRef.current?.addEventListener(event.name, () => event.func(editorState));
- }
-
return () => {
window.removeEventListener('keyup', onKeyUp);
};
@@ -54,7 +46,7 @@ const Editor: React.FunctionComponent = (props) => {
const configuration = props.configuration;
const current = getCurrentHistoryState(history, historyCurrentStep);
return (
-
+
>,
+ setHistory: Dispatch>,
setHistoryCurrentStep: Dispatch>
): void {
const history = getCurrentHistory(fullHistory, historyCurrentStep);
@@ -73,10 +73,10 @@ export function OnPropertyChange(
*/
export function OnPropertiesSubmit(
event: React.SyntheticEvent,
- properties: IProperties,
- fullHistory: IHistoryState[],
+ properties: Properties,
+ fullHistory: HistoryState[],
historyCurrentStep: number,
- setHistory: Dispatch>,
+ setHistory: Dispatch>,
setHistoryCurrentStep: Dispatch>
): void {
event.preventDefault();
diff --git a/src/Components/Editor/RigidBodyBehaviors.ts b/src/Components/Editor/RigidBodyBehaviors.ts
index 116fbc4..95ce545 100644
--- a/src/Components/Editor/RigidBodyBehaviors.ts
+++ b/src/Components/Editor/RigidBodyBehaviors.ts
@@ -1,5 +1,5 @@
-import { IContainerModel } from '../../Interfaces/IContainerModel';
-import { ISizePointer } from '../../Interfaces/ISizePointer';
+import { IContainerModel } from '../../Interfaces/ContainerModel';
+import { SizePointer } from '../../Interfaces/SizePointer';
/**
* "Transform the container into a rigid body"
@@ -167,17 +167,17 @@ function constraintBodyInsideUnallocatedWidth(
* (except the fact that disk space is divided by block).
* @param container Container where to find an available width
* @param exception Container to exclude of the widths (since a container will be moved, it might need to be excluded)
- * @returns {ISizePointer[]} Array of unallocated widths (x=position of the unallocated space, width=size of the allocated space)
+ * @returns {SizePointer[]} Array of unallocated widths (x=position of the unallocated space, width=size of the allocated space)
*/
function getAvailableWidths(
container: IContainerModel,
exception: IContainerModel
-): ISizePointer[] {
+): SizePointer[] {
// Initialize the first size pointer
// which takes full width of the available space
const x = 0;
const width = Number(container.properties.width);
- let unallocatedSpaces: ISizePointer[] = [{ x, width }];
+ let unallocatedSpaces: SizePointer[] = [{ x, width }];
// We will only uses containers that also have the rigid bodies
// as out-of-bound or enormouse containers should be ignored
@@ -192,7 +192,7 @@ function getAvailableWidths(
}
// get the space of the child that is inside the parent
- let newUnallocatedSpace: ISizePointer[] = [];
+ let newUnallocatedSpace: SizePointer[] = [];
// We will iterate on a mutable variable in order to divide it
for (const unallocatedSpace of unallocatedSpaces) {
@@ -229,7 +229,7 @@ function getAvailableWidthsTwoLines(
max1: number,
min2: number,
max2: number
-): ISizePointer[] {
+): SizePointer[] {
if (min2 < min1 && max2 > max1) {
// object 2 is overlapping full width
return [];
@@ -276,5 +276,5 @@ function getAvailableWidthsTwoLines(
*/
const isFitting = (
container: IContainerModel,
- sizePointer: ISizePointer
+ sizePointer: SizePointer
): boolean => Number(container.properties.width) <= sizePointer.width;
diff --git a/src/Components/Editor/Save.ts b/src/Components/Editor/Save.ts
index 5717a41..3aa201a 100644
--- a/src/Components/Editor/Save.ts
+++ b/src/Components/Editor/Save.ts
@@ -1,13 +1,13 @@
-import { IHistoryState } from '../../Interfaces/IHistoryState';
-import { IConfiguration } from '../../Interfaces/IConfiguration';
+import { HistoryState } from '../../Interfaces/HistoryState';
+import { Configuration } from '../../Interfaces/Configuration';
import { getCircularReplacer } from '../../utils/saveload';
import { ID } from '../SVG/SVG';
-import { IEditorState } from '../../Interfaces/IEditorState';
+import { IEditorState } from './Editor';
export function SaveEditorAsJSON(
- history: IHistoryState[],
+ history: HistoryState[],
historyCurrentStep: number,
- configuration: IConfiguration
+ configuration: Configuration
): void {
const exportName = 'state';
const spaces = import.meta.env.DEV ? 4 : 0;
diff --git a/src/Components/Editor/Shortcuts.ts b/src/Components/Editor/Shortcuts.ts
index aa20d96..8ac6790 100644
--- a/src/Components/Editor/Shortcuts.ts
+++ b/src/Components/Editor/Shortcuts.ts
@@ -1,9 +1,9 @@
import { Dispatch, SetStateAction } from 'react';
-import { IHistoryState } from '../../Interfaces/IHistoryState';
+import { HistoryState } from '../../Interfaces/HistoryState';
export function onKeyDown(
event: KeyboardEvent,
- history: IHistoryState[],
+ history: HistoryState[],
historyCurrentStep: number,
setHistoryCurrentStep: Dispatch>
): void {
diff --git a/src/Components/ElementsSidebar/ElementsSidebar.test.tsx b/src/Components/ElementsSidebar/ElementsSidebar.test.tsx
index f1776c0..fac312b 100644
--- a/src/Components/ElementsSidebar/ElementsSidebar.test.tsx
+++ b/src/Components/ElementsSidebar/ElementsSidebar.test.tsx
@@ -2,7 +2,7 @@ import { describe, expect, it, vi } from 'vitest';
import * as React from 'react';
import { fireEvent, render, screen } from '../../utils/test-utils';
import { ElementsSidebar } from './ElementsSidebar';
-import { IContainerModel } from '../../Interfaces/IContainerModel';
+import { IContainerModel } from '../../Interfaces/ContainerModel';
describe.concurrent('Elements sidebar', () => {
it('With a MainContainer', () => {
diff --git a/src/Components/ElementsSidebar/ElementsSidebar.tsx b/src/Components/ElementsSidebar/ElementsSidebar.tsx
index e62f3db..e9d5e59 100644
--- a/src/Components/ElementsSidebar/ElementsSidebar.tsx
+++ b/src/Components/ElementsSidebar/ElementsSidebar.tsx
@@ -1,13 +1,13 @@
import * as React from 'react';
import { motion } from 'framer-motion';
import { Properties } from '../Properties/Properties';
-import ContainerProperties from '../../Interfaces/IProperties';
-import { IContainerModel } from '../../Interfaces/IContainerModel';
+import ContainerProperties from '../../Interfaces/Properties';
+import { IContainerModel } from '../../Interfaces/ContainerModel';
import { getDepth, MakeIterator } from '../../utils/itertools';
import { Menu } from '../Menu/Menu';
import { MenuItem } from '../Menu/MenuItem';
import { handleDragLeave, handleDragOver, handleLeftClick, handleOnDrop, handleRightClick } from './MouseEventHandlers';
-import { IPoint } from '../../Interfaces/IPoint';
+import { Point } from '../../Interfaces/Point';
interface IElementsSidebarProps {
MainContainer: IContainerModel
@@ -64,7 +64,7 @@ export const ElementsSidebar: React.FC = (props: IElement
// States
const [isContextMenuOpen, setIsContextMenuOpen] = React.useState(false);
const [onClickContainerId, setOnClickContainerId] = React.useState('');
- const [contextMenuPosition, setContextMenuPosition] = React.useState({
+ const [contextMenuPosition, setContextMenuPosition] = React.useState({
x: 0,
y: 0
});
diff --git a/src/Components/ElementsSidebar/MouseEventHandlers.ts b/src/Components/ElementsSidebar/MouseEventHandlers.ts
index 1a814d2..53fb14e 100644
--- a/src/Components/ElementsSidebar/MouseEventHandlers.ts
+++ b/src/Components/ElementsSidebar/MouseEventHandlers.ts
@@ -1,12 +1,12 @@
-import { IContainerModel } from '../../Interfaces/IContainerModel';
-import { IPoint } from '../../Interfaces/IPoint';
+import { IContainerModel } from '../../Interfaces/ContainerModel';
+import { Point } from '../../Interfaces/Point';
import { findContainerById } from '../../utils/itertools';
export function handleRightClick(
event: MouseEvent,
setIsContextMenuOpen: React.Dispatch>,
setOnClickContainerId: React.Dispatch>,
- setContextMenuPosition: React.Dispatch>
+ setContextMenuPosition: React.Dispatch>
): void {
event.preventDefault();
@@ -16,7 +16,7 @@ export function handleRightClick(
return;
}
- const contextMenuPosition: IPoint = { x: event.pageX, y: event.pageY };
+ const contextMenuPosition: Point = { x: event.pageX, y: event.pageY };
setIsContextMenuOpen(true);
setOnClickContainerId(event.target.id);
setContextMenuPosition(contextMenuPosition);
diff --git a/src/Components/History/History.tsx b/src/Components/History/History.tsx
index dd8e676..067a867 100644
--- a/src/Components/History/History.tsx
+++ b/src/Components/History/History.tsx
@@ -1,8 +1,8 @@
import * as React from 'react';
-import { IHistoryState } from "../../Interfaces/IHistoryState";
+import { HistoryState } from "../../Interfaces/HistoryState";
interface IHistoryProps {
- history: IHistoryState[]
+ history: HistoryState[]
historyCurrentStep: number
isOpen: boolean
jumpTo: (move: number) => void
diff --git a/src/Components/Properties/Properties.tsx b/src/Components/Properties/Properties.tsx
index 516f23d..49f5028 100644
--- a/src/Components/Properties/Properties.tsx
+++ b/src/Components/Properties/Properties.tsx
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
-import ContainerProperties from '../../Interfaces/IProperties';
+import ContainerProperties from '../../Interfaces/Properties';
import { ToggleButton } from '../ToggleButton/ToggleButton';
import { INPUT_TYPES } from './PropertiesInputTypes';
diff --git a/src/Components/SVG/Elements/Container.tsx b/src/Components/SVG/Elements/Container.tsx
index 6417570..25a45c9 100644
--- a/src/Components/SVG/Elements/Container.tsx
+++ b/src/Components/SVG/Elements/Container.tsx
@@ -1,10 +1,10 @@
import * as React from 'react';
import { XPositionReference } from '../../../Enums/XPositionReference';
-import { IContainerModel } from '../../../Interfaces/IContainerModel';
+import { IContainerModel } from '../../../Interfaces/ContainerModel';
import { getDepth } from '../../../utils/itertools';
import { Dimension } from './Dimension';
-interface IContainerProps {
+export interface IContainerProps {
model: IContainerModel
}
diff --git a/src/Components/SVG/Elements/Selector.tsx b/src/Components/SVG/Elements/Selector.tsx
index e70ca79..c5937e0 100644
--- a/src/Components/SVG/Elements/Selector.tsx
+++ b/src/Components/SVG/Elements/Selector.tsx
@@ -1,5 +1,5 @@
import * as React from 'react';
-import { IContainerModel } from '../../../Interfaces/IContainerModel';
+import { IContainerModel } from '../../../Interfaces/ContainerModel';
import { getAbsolutePosition } from '../../../utils/itertools';
interface ISelectorProps {
diff --git a/src/Components/SVG/SVG.tsx b/src/Components/SVG/SVG.tsx
index 5758d5f..94fb746 100644
--- a/src/Components/SVG/SVG.tsx
+++ b/src/Components/SVG/SVG.tsx
@@ -1,7 +1,7 @@
import * as React from 'react';
import { UncontrolledReactSVGPanZoom } from 'react-svg-pan-zoom';
import { Container } from './Elements/Container';
-import { ContainerModel } from '../../Interfaces/IContainerModel';
+import { ContainerModel } from '../../Interfaces/ContainerModel';
import { Selector } from './Elements/Selector';
import { BAR_WIDTH } from '../Bar/Bar';
diff --git a/src/Components/Sidebar/Sidebar.tsx b/src/Components/Sidebar/Sidebar.tsx
index 440908f..dc2f1a7 100644
--- a/src/Components/Sidebar/Sidebar.tsx
+++ b/src/Components/Sidebar/Sidebar.tsx
@@ -1,9 +1,9 @@
import * as React from 'react';
-import { IAvailableContainer } from '../../Interfaces/IAvailableContainer';
+import { AvailableContainer } from '../../Interfaces/AvailableContainer';
import { truncateString } from '../../utils/stringtools';
interface ISidebarProps {
- componentOptions: IAvailableContainer[]
+ componentOptions: AvailableContainer[]
isOpen: boolean
buttonOnClick: (type: string) => void
}
diff --git a/src/Components/UI/UI.tsx b/src/Components/UI/UI.tsx
index 4fa36e6..ffe9fb3 100644
--- a/src/Components/UI/UI.tsx
+++ b/src/Components/UI/UI.tsx
@@ -2,23 +2,23 @@ import * as React from 'react';
import { ElementsSidebar } from '../ElementsSidebar/ElementsSidebar';
import { Sidebar } from '../Sidebar/Sidebar';
import { History } from '../History/History';
-import { IAvailableContainer } from '../../Interfaces/IAvailableContainer';
-import { ContainerModel } from '../../Interfaces/IContainerModel';
-import { IHistoryState } from '../../Interfaces/IHistoryState';
+import { AvailableContainer } from '../../Interfaces/AvailableContainer';
+import { ContainerModel } from '../../Interfaces/ContainerModel';
+import { HistoryState } from '../../Interfaces/HistoryState';
import { PhotographIcon, UploadIcon } from '@heroicons/react/outline';
import { FloatingButton } from '../FloatingButton/FloatingButton';
import { Bar } from '../Bar/Bar';
-import IProperties from '../../Interfaces/IProperties';
+import Properties from '../../Interfaces/Properties';
interface IUIProps {
- current: IHistoryState
- history: IHistoryState[]
+ current: HistoryState
+ history: HistoryState[]
historyCurrentStep: number
- AvailableContainers: IAvailableContainer[]
+ AvailableContainers: AvailableContainer[]
SelectContainer: (container: ContainerModel) => void
DeleteContainer: (containerId: string) => void
OnPropertyChange: (key: string, value: string | number | boolean) => void
- OnPropertiesSubmit: (event: React.FormEvent, properties: IProperties) => void
+ OnPropertiesSubmit: (event: React.FormEvent, properties: Properties) => void
AddContainerToSelectedContainer: (type: string) => void
AddContainer: (index: number, type: string, parentId: string) => void
SaveEditorAsJSON: () => void
diff --git a/src/Events/EditorEvents.ts b/src/Events/EditorEvents.ts
deleted file mode 100644
index 316b7b8..0000000
--- a/src/Events/EditorEvents.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { IEditorState } from '../Interfaces/IEditorState';
-import { IHistoryState } from '../Interfaces/IHistoryState';
-
-const getEditorState = (editorState: IEditorState): void => {
- const customEvent = new CustomEvent('getEditorState', { detail: editorState });
- document.dispatchEvent(customEvent);
-};
-
-const getCurrentHistoryState = (editorState: IEditorState): void => {
- const customEvent = new CustomEvent(
- 'getCurrentHistoryState',
- { detail: editorState.history[editorState.historyCurrentStep] });
- document.dispatchEvent(customEvent);
-};
-
-export interface IEditorEvent {
- name: string
- func: (editorState: IEditorState) => void
-}
-
-const events: IEditorEvent[] = [
- { name: 'getEditorState', func: getEditorState },
- { name: 'getCurrentHistoryState', func: getCurrentHistoryState }
-];
-
-export default events;
diff --git a/src/Interfaces/IAvailableContainer.ts b/src/Interfaces/AvailableContainer.ts
similarity index 87%
rename from src/Interfaces/IAvailableContainer.ts
rename to src/Interfaces/AvailableContainer.ts
index c7ad3c1..b328b0a 100644
--- a/src/Interfaces/IAvailableContainer.ts
+++ b/src/Interfaces/AvailableContainer.ts
@@ -2,7 +2,7 @@ import React from 'react';
import { XPositionReference } from '../Enums/XPositionReference';
/** Model of available container used in application configuration */
-export interface IAvailableContainer {
+export interface AvailableContainer {
Type: string
Width: number
Height: number
diff --git a/src/Interfaces/IAvailableSymbol.ts b/src/Interfaces/AvailableSymbol.ts
similarity index 70%
rename from src/Interfaces/IAvailableSymbol.ts
rename to src/Interfaces/AvailableSymbol.ts
index c8e9324..e1d518d 100644
--- a/src/Interfaces/IAvailableSymbol.ts
+++ b/src/Interfaces/AvailableSymbol.ts
@@ -1,12 +1,12 @@
import { XPositionReference } from '../Enums/XPositionReference';
-import { IImage } from './IImage';
+import { Image } from './Image';
/**
* Model of available symbol to configure the application */
-export interface IAvailableSymbolModel {
+export interface AvailableSymbolModel {
Name: string
XPositionReference: XPositionReference
- Image: IImage
+ Image: Image
Width: number
Height: number
}
diff --git a/src/Interfaces/Configuration.ts b/src/Interfaces/Configuration.ts
new file mode 100644
index 0000000..f8d4854
--- /dev/null
+++ b/src/Interfaces/Configuration.ts
@@ -0,0 +1,9 @@
+import { AvailableContainer } from './AvailableContainer';
+import { AvailableSymbolModel } from './AvailableSymbol';
+
+/** Model of configuration for the application to configure it */
+export interface Configuration {
+ AvailableContainers: AvailableContainer[]
+ AvailableSymbols: AvailableSymbolModel[]
+ MainContainer: AvailableContainer
+}
diff --git a/src/Interfaces/IContainerModel.ts b/src/Interfaces/ContainerModel.ts
similarity index 81%
rename from src/Interfaces/IContainerModel.ts
rename to src/Interfaces/ContainerModel.ts
index b180486..1c70ae3 100644
--- a/src/Interfaces/IContainerModel.ts
+++ b/src/Interfaces/ContainerModel.ts
@@ -1,21 +1,21 @@
-import IProperties from './IProperties';
+import Properties from './Properties';
export interface IContainerModel {
children: IContainerModel[]
parent: IContainerModel | null
- properties: IProperties
+ properties: Properties
userData: Record
}
export class ContainerModel implements IContainerModel {
public children: IContainerModel[];
public parent: IContainerModel | null;
- public properties: IProperties;
+ public properties: Properties;
public userData: Record;
constructor(
parent: IContainerModel | null,
- properties: IProperties,
+ properties: Properties,
children: IContainerModel[] = [],
userData = {}) {
this.parent = parent;
diff --git a/src/Interfaces/IHistoryState.ts b/src/Interfaces/HistoryState.ts
similarity index 66%
rename from src/Interfaces/IHistoryState.ts
rename to src/Interfaces/HistoryState.ts
index fd46fbc..da1d74b 100644
--- a/src/Interfaces/IHistoryState.ts
+++ b/src/Interfaces/HistoryState.ts
@@ -1,6 +1,6 @@
-import { IContainerModel } from './IContainerModel';
+import { IContainerModel } from './ContainerModel';
-export interface IHistoryState {
+export interface HistoryState {
LastAction: string
MainContainer: IContainerModel
SelectedContainer: IContainerModel | null
diff --git a/src/Interfaces/IConfiguration.ts b/src/Interfaces/IConfiguration.ts
deleted file mode 100644
index e6f1f44..0000000
--- a/src/Interfaces/IConfiguration.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { IAvailableContainer } from './IAvailableContainer';
-import { IAvailableSymbolModel } from './IAvailableSymbol';
-
-/** Model of configuration for the application to configure it */
-export interface IConfiguration {
- AvailableContainers: IAvailableContainer[]
- AvailableSymbols: IAvailableSymbolModel[]
- MainContainer: IAvailableContainer
-}
diff --git a/src/Interfaces/IEditorState.tsx b/src/Interfaces/IEditorState.tsx
deleted file mode 100644
index 495a868..0000000
--- a/src/Interfaces/IEditorState.tsx
+++ /dev/null
@@ -1,8 +0,0 @@
-import { IConfiguration } from './IConfiguration';
-import { IHistoryState } from './IHistoryState';
-
-export interface IEditorState {
- history: IHistoryState[]
- historyCurrentStep: number
- configuration: IConfiguration
-}
diff --git a/src/Interfaces/IImage.ts b/src/Interfaces/Image.ts
similarity index 81%
rename from src/Interfaces/IImage.ts
rename to src/Interfaces/Image.ts
index 7432440..b839b09 100644
--- a/src/Interfaces/IImage.ts
+++ b/src/Interfaces/Image.ts
@@ -1,5 +1,5 @@
/** Model of an image with multiple source */
-export interface IImage {
+export interface Image {
Name: string
Url: string
Base64Image: string
diff --git a/src/Interfaces/IPoint.ts b/src/Interfaces/Point.ts
similarity index 50%
rename from src/Interfaces/IPoint.ts
rename to src/Interfaces/Point.ts
index d2e202a..43fd673 100644
--- a/src/Interfaces/IPoint.ts
+++ b/src/Interfaces/Point.ts
@@ -1,4 +1,4 @@
-export interface IPoint {
+export interface Point {
x: number
y: number
}
diff --git a/src/Interfaces/IProperties.ts b/src/Interfaces/Properties.ts
similarity index 77%
rename from src/Interfaces/IProperties.ts
rename to src/Interfaces/Properties.ts
index 4996ce5..6f2f32e 100644
--- a/src/Interfaces/IProperties.ts
+++ b/src/Interfaces/Properties.ts
@@ -1,7 +1,7 @@
import * as React from 'react';
import { XPositionReference } from '../Enums/XPositionReference';
-export default interface IProperties extends React.CSSProperties {
+export default interface Properties extends React.CSSProperties {
id: string
parentId: string | null
x: number
diff --git a/src/Interfaces/ISizePointer.ts b/src/Interfaces/SizePointer.ts
similarity index 87%
rename from src/Interfaces/ISizePointer.ts
rename to src/Interfaces/SizePointer.ts
index 05f880c..e5ec599 100644
--- a/src/Interfaces/ISizePointer.ts
+++ b/src/Interfaces/SizePointer.ts
@@ -3,7 +3,7 @@
* x being the address where the pointer is pointing
* width being the overall (un)allocated space affected to the address
*/
-export interface ISizePointer {
+export interface SizePointer {
x: number
width: number
}
diff --git a/src/utils/default.ts b/src/utils/default.ts
index 785a840..51c1d7a 100644
--- a/src/utils/default.ts
+++ b/src/utils/default.ts
@@ -1,7 +1,7 @@
-import { IConfiguration } from '../Interfaces/IConfiguration';
-import IProperties from '../Interfaces/IProperties';
+import { Configuration } from '../Interfaces/Configuration';
+import Properties from '../Interfaces/Properties';
-export const DEFAULT_CONFIG: IConfiguration = {
+export const DEFAULT_CONFIG: Configuration = {
AvailableContainers: [
{
Type: 'Container',
@@ -25,7 +25,7 @@ export const DEFAULT_CONFIG: IConfiguration = {
}
};
-export const DEFAULT_MAINCONTAINER_PROPS: IProperties = {
+export const DEFAULT_MAINCONTAINER_PROPS: Properties = {
id: 'main',
parentId: 'null',
x: 0,
diff --git a/src/utils/itertools.ts b/src/utils/itertools.ts
index d50a089..67cd40c 100644
--- a/src/utils/itertools.ts
+++ b/src/utils/itertools.ts
@@ -1,4 +1,4 @@
-import { IContainerModel } from '../Interfaces/IContainerModel';
+import { IContainerModel } from '../Interfaces/ContainerModel';
/**
* Returns a Generator iterating of over the children depth-first
diff --git a/src/utils/saveload.ts b/src/utils/saveload.ts
index 356dd50..a33652e 100644
--- a/src/utils/saveload.ts
+++ b/src/utils/saveload.ts
@@ -1,5 +1,5 @@
import { findContainerById, MakeIterator } from './itertools';
-import { IEditorState } from '../Interfaces/IEditorState';
+import { IEditorState } from '../Components/Editor/Editor';
/**
* Revive the Editor state