Implement minWidth property + refactor default property of new containers and main container (#34)
All checks were successful
continuous-integration/drone/push Build is passing
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:
parent
60329ef143
commit
2945febd91
12 changed files with 137 additions and 44 deletions
|
@ -4,10 +4,9 @@ import { IConfiguration } from '../../Interfaces/IConfiguration';
|
|||
import { ContainerModel, IContainerModel } from '../../Interfaces/IContainerModel';
|
||||
import { findContainerById } from '../../utils/itertools';
|
||||
import { getCurrentHistory } from './Editor';
|
||||
import IProperties from '../../Interfaces/IProperties';
|
||||
import { AddMethod } from '../../Enums/AddMethod';
|
||||
import { IAvailableContainer } from '../../Interfaces/IAvailableContainer';
|
||||
import { XPositionReference } from '../../Enums/XPositionReference';
|
||||
import { GetDefaultContainerProps } from '../../utils/default';
|
||||
|
||||
/**
|
||||
* Select a container
|
||||
|
@ -203,25 +202,17 @@ export function AddContainer(
|
|||
|
||||
let x = containerConfig.DefaultX ?? 0;
|
||||
const y = containerConfig.DefaultY ?? 0;
|
||||
const width = containerConfig.Width ?? parentClone.properties.width;
|
||||
const height = containerConfig.Height ?? parentClone.properties.height;
|
||||
|
||||
x = ApplyAddMethod(index, containerConfig, parentClone, x);
|
||||
|
||||
const defaultProperties: IProperties = {
|
||||
id: `${type}-${count}`,
|
||||
parentId: parentClone.properties.id,
|
||||
const defaultProperties = GetDefaultContainerProps(
|
||||
type,
|
||||
count,
|
||||
parentClone,
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
isRigidBody: false,
|
||||
isAnchor: false,
|
||||
XPositionReference: containerConfig.XPositionReference ?? XPositionReference.Left,
|
||||
customSVG: containerConfig.CustomSVG,
|
||||
style: containerConfig.Style,
|
||||
userData: containerConfig.UserData
|
||||
};
|
||||
containerConfig
|
||||
);
|
||||
|
||||
// Create the container
|
||||
const newContainer = new ContainerModel(
|
||||
|
@ -265,6 +256,7 @@ function ApplyAddMethod(index: number, containerConfig: IAvailableContainer, par
|
|||
if (index > 0 && (
|
||||
containerConfig.AddMethod === undefined ||
|
||||
containerConfig.AddMethod === AddMethod.Append)) {
|
||||
// Append method (default)
|
||||
const lastChild: IContainerModel | undefined = parent.children.at(index - 1);
|
||||
|
||||
if (lastChild !== undefined) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue