Implement minWidth property + refactor default property of new containers and main container (#34)
All checks were successful
continuous-integration/drone/push Build is passing

Co-authored-by: Eric NGUYEN <enguyen@techform.fr>
Reviewed-on: https://git.siklos-chaneru.duckdns.org/Siklos/svg-layout-designer-react/pulls/34
This commit is contained in:
Siklos 2022-08-17 11:14:19 -04:00
parent 60329ef143
commit 2945febd91
12 changed files with 137 additions and 44 deletions

View file

@ -1,5 +1,7 @@
import { XPositionReference } from '../Enums/XPositionReference';
import { IAvailableContainer } from '../Interfaces/IAvailableContainer';
import { IConfiguration } from '../Interfaces/IConfiguration';
import { IContainerModel } from '../Interfaces/IContainerModel';
import IProperties from '../Interfaces/IProperties';
export const DEFAULT_CONFIG: IConfiguration = {
@ -31,6 +33,7 @@ export const DEFAULT_MAINCONTAINER_PROPS: IProperties = {
parentId: 'null',
x: 0,
y: 0,
minWidth: 1,
width: Number(DEFAULT_CONFIG.MainContainer.Width),
height: Number(DEFAULT_CONFIG.MainContainer.Height),
isRigidBody: false,
@ -42,6 +45,29 @@ export const DEFAULT_MAINCONTAINER_PROPS: IProperties = {
}
};
export const GetDefaultContainerProps = (
type: string,
typeCount: number,
parent: IContainerModel,
x: number,
y: number,
containerConfig: IAvailableContainer
): IProperties => ({
id: `${type}-${typeCount}`,
parentId: parent.properties.id,
x,
y,
width: containerConfig.Width ?? containerConfig.MinWidth ?? parent.properties.width,
height: containerConfig.Height ?? parent.properties.height,
isRigidBody: false,
isAnchor: false,
XPositionReference: containerConfig.XPositionReference ?? XPositionReference.Left,
minWidth: containerConfig.MinWidth ?? 0,
customSVG: containerConfig.CustomSVG,
style: containerConfig.Style,
userData: containerConfig.UserData
});
export const DIMENSION_MARGIN = 50;
export const NOTCHES_LENGTH = 4;