From 869cd2a7c48cfd382c92856faceee6f057d84f2b Mon Sep 17 00:00:00 2001 From: Carl Fuchs Date: Mon, 20 Feb 2023 14:46:22 +0100 Subject: [PATCH] [Fix] SymbolDimension (Canvas/Svg) => DEFAULT_DIMENSION_SYMBOL_STYLE in default.ts --- src/Components/Canvas/DimensionLayer.ts | 10 ++-------- src/Components/SVG/Elements/DimensionLayer.tsx | 9 ++++----- src/utils/default.ts | 6 +++++- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/Components/Canvas/DimensionLayer.ts b/src/Components/Canvas/DimensionLayer.ts index 6b3182e..1a345a8 100644 --- a/src/Components/Canvas/DimensionLayer.ts +++ b/src/Components/Canvas/DimensionLayer.ts @@ -7,11 +7,10 @@ import { SHOW_BORROWER_DIMENSIONS, SHOW_CHILDREN_DIMENSIONS, DIMENSION_MARGIN, - SHOW_SELF_MARGINS_DIMENSIONS + SHOW_SELF_MARGINS_DIMENSIONS, DEFAULT_DIMENSION_SYMBOL_STYLE } from '../../utils/default'; import { FindContainerById, MakeRecursionDFSIterator, Pairwise } from '../../utils/itertools'; import { TransformX, TransformY } from '../../utils/svg'; -import { type IDimensionStyle } from '../SVG/Elements/Dimension'; import { RenderDimension } from './Dimension'; export function AddContainerDimensions( @@ -589,11 +588,6 @@ function AddHorizontalSymbolDimension( .toFixed(0) .toString(); - // TODO: Put this in default.ts - const defaultDimensionSymbolStyle: IDimensionStyle = { - color: 'black' - }; - RenderDimension(ctx, { id, xStart: 0, @@ -602,6 +596,6 @@ function AddHorizontalSymbolDimension( yEnd: -offset, text, scale, - style: defaultDimensionSymbolStyle + style: DEFAULT_DIMENSION_SYMBOL_STYLE }); } diff --git a/src/Components/SVG/Elements/DimensionLayer.tsx b/src/Components/SVG/Elements/DimensionLayer.tsx index f3634e9..a097a3e 100644 --- a/src/Components/SVG/Elements/DimensionLayer.tsx +++ b/src/Components/SVG/Elements/DimensionLayer.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import { Orientation } from '../../../Enums/Orientation'; import { Position } from '../../../Enums/Position'; import { + DEFAULT_DIMENSION_SYMBOL_STYLE, DIMENSION_MARGIN, SHOW_BORROWER_DIMENSIONS, SHOW_CHILDREN_DIMENSIONS, @@ -10,7 +11,7 @@ import { } from '../../../utils/default'; import { FindContainerById, MakeRecursionDFSIterator, Pairwise } from '../../../utils/itertools'; import { TransformX, TransformY } from '../../../utils/svg'; -import { Dimension, type IDimensionStyle } from './Dimension'; +import { Dimension } from './Dimension'; import { type IContainerModel } from '../../../Interfaces/IContainerModel'; import { type ISymbolModel } from '../../../Interfaces/ISymbolModel'; @@ -182,7 +183,6 @@ function AddHorizontalSymbolDimension(symbol: ISymbolModel, const width = symbol.offset + (symbol.width / 2); if (width != null && width > 0) { const id = `dim-y-margin-left${symbol.width.toFixed(0)}-${symbol.id}`; - const style = symbol.linkedContainers.values().next().value.dimensionOptions; const offset = (DIMENSION_MARGIN * (depth + 1)) / scale; const text = width @@ -198,7 +198,7 @@ function AddHorizontalSymbolDimension(symbol: ISymbolModel, yEnd={-offset} text={text} scale={scale} - style={style}/> + style={DEFAULT_DIMENSION_SYMBOL_STYLE}/> ); } } @@ -212,7 +212,6 @@ function AddVerticalSymbolDimension(symbol: ISymbolModel, const height = symbol.offset + (symbol.height / 2); if (height != null && height > 0) { const id = `dim-x-margin-left${symbol.height.toFixed(0)}-${symbol.id}`; - const style = symbol.linkedContainers.values().next().value.dimensionOptions; const offset = (DIMENSION_MARGIN * (depth + 1)) / scale; const text = height @@ -228,7 +227,7 @@ function AddVerticalSymbolDimension(symbol: ISymbolModel, yEnd={0} text={text} scale={scale} - style={style}/> + style={DEFAULT_DIMENSION_SYMBOL_STYLE}/> ); } } diff --git a/src/utils/default.ts b/src/utils/default.ts index 24e8bbb..a7baa17 100644 --- a/src/utils/default.ts +++ b/src/utils/default.ts @@ -9,6 +9,7 @@ import { type ISymbolModel } from '../Interfaces/ISymbolModel'; import { Orientation } from '../Enums/Orientation'; import { AppState } from '../Enums/AppState'; import { type IDimensionOptions } from '../Interfaces/IDimensionOptions'; +import { type IDimensionStyle } from '../Components/SVG/Elements/Dimension'; /// EDITOR DEFAULTS /// @@ -69,6 +70,9 @@ export const SHOW_BORROWER_DIMENSIONS = true; export const DIMENSION_MARGIN = 50; export const SYMBOL_MARGIN = 25; export const NOTCHES_LENGTH = 10; +export const DEFAULT_DIMENSION_SYMBOL_STYLE: IDimensionStyle = { + color: '#000000' +}; /// SYMBOL DEFAULTS /// @@ -306,7 +310,7 @@ export function GetDefaultSymbolModel(name: string, type: name, config: structuredClone(symbolConfig), offset: 0, - isVertical : symbolConfig.isVertical ?? DEFAULT_SYMBOL_IS_VERTICAL, + isVertical: symbolConfig.isVertical ?? DEFAULT_SYMBOL_IS_VERTICAL, width: symbolConfig.Width ?? DEFAULT_SYMBOL_WIDTH, height: symbolConfig.Height ?? DEFAULT_SYMBOL_HEIGHT, linkedContainers: new Set(),