diff --git a/app/src/components/SimulationDashboard/components/element/ElementDesign.tsx b/app/src/components/SimulationDashboard/components/element/ElementDesign.tsx index 1696481..8537778 100644 --- a/app/src/components/SimulationDashboard/components/element/ElementDesign.tsx +++ b/app/src/components/SimulationDashboard/components/element/ElementDesign.tsx @@ -1,15 +1,7 @@ import React, { RefObject, useEffect, useState } from "react"; import DataSourceSelector from "../../../ui/inputs/DataSourceSelector"; import RenameInput from "../../../ui/inputs/RenameInput"; -import { - AlignJustifyIcon, - AlignLeftIcon, - AlignRightIcon, - ArrowIcon, - FlexColumnIcon, - FlexRowIcon, - FlexRowReverseIcon, -} from "../../../icons/ExportCommonIcons"; +import { AlignJustifyIcon, AlignLeftIcon, AlignRightIcon, ArrowIcon, FlexColumnIcon, FlexRowIcon, FlexRowReverseIcon } from "../../../icons/ExportCommonIcons"; import InputWithDropDown from "../../../ui/inputs/InputWithDropDown"; import InputRange from "../../../ui/inputs/InputRange"; import { getAlphaFromRgba, hexToRgba, rgbaToHex } from "../../functions/helpers/colorHandlers"; @@ -24,35 +16,15 @@ interface ElementDesignProps { selectedBlock: string; selectedElement: string; updateElementStyle: (blockId: string, elementId: string, style: ExtendedCSSProperties) => void; - updateElementSize: ( - blockId: string, - elementId: string, - size: { width: number; height: number } - ) => void; - updateElementPosition: ( - blockId: string, - elementId: string, - position: { x: number; y: number } - ) => void; - updateElementPositionType: ( - blockId: string, - elementId: string, - positionType: "relative" | "absolute" | "fixed" - ) => void; + updateElementSize: (blockId: string, elementId: string, size: { width: number; height: number }) => void; + updateElementPosition: (blockId: string, elementId: string, position: { x: number; y: number }) => void; + updateElementPositionType: (blockId: string, elementId: string, positionType: "relative" | "absolute" | "fixed") => void; updateElementZIndex: (blockId: string, elementId: string, zIndex: number) => void; - updateElementData: ( - blockId: string, - elementId: string, - updates: Partial - ) => void; + updateElementData: (blockId: string, elementId: string, updates: Partial) => void; updateGraphData: (blockId: string, elementId: string, newData: GraphDataPoint[]) => void; updateGraphTitle: (blockId: string, elementId: string, title: string) => void; updateGraphType: (blockId: string, elementId: string, type: GraphTypes) => void; - updateDataType: ( - blockId: string, - elementId: string, - dataType: "single-machine" | "multiple-machine" - ) => void; + updateDataType: (blockId: string, elementId: string, dataType: "single-machine" | "multiple-machine") => void; updateCommonValue: (blockId: string, elementId: string, commonValue: string) => void; updateDataValue: (blockId: string, elementId: string, dataValue: string | string[]) => void; updateDataSource: (blockId: string, elementId: string, dataSource: string | string[]) => void; @@ -76,9 +48,7 @@ const ElementDesign: React.FC = ({ const [color, setColor] = useState("#000000"); useEffect(() => { - setColor( - rgbaToHex(getCurrentElementStyleValue(currentElement, "backgroundColor") || "#000000") - ); + setColor(rgbaToHex(getCurrentElementStyleValue(currentElement, "backgroundColor") || "#000000")); }, [currentElement]); return ( @@ -95,11 +65,7 @@ const ElementDesign: React.FC = ({ { id: "radar", label: "Radar Chart" }, ]} onSelect={(newValue) => { - updateGraphType( - selectedBlock, - selectedElement, - newValue.id as GraphTypes - ); + updateGraphType(selectedBlock, selectedElement, newValue.id as GraphTypes); }} showEyeDropper={false} /> @@ -112,15 +78,8 @@ const ElementDesign: React.FC = ({ {["relative", "absolute"].map((position) => (
- updateElementPositionType( - selectedBlock, - selectedElement, - position as "relative" | "absolute" | "fixed" - ) - } + className={`type ${currentElement.positionType === position ? "active" : ""}`} + onClick={() => updateElementPositionType(selectedBlock, selectedElement, position as "relative" | "absolute" | "fixed")} > {position.charAt(0).toUpperCase() + position.slice(1)}
@@ -129,48 +88,16 @@ const ElementDesign: React.FC = ({
- +
- +
- +
- +
@@ -178,10 +105,7 @@ const ElementDesign: React.FC = ({
updateElementStyle(selectedBlock, selectedElement, { textAlign: "right", @@ -191,11 +115,7 @@ const ElementDesign: React.FC = ({
updateElementStyle(selectedBlock, selectedElement, { textAlign: "justify", @@ -205,10 +125,7 @@ const ElementDesign: React.FC = ({
updateElementStyle(selectedBlock, selectedElement, { textAlign: "left", @@ -220,10 +137,7 @@ const ElementDesign: React.FC = ({
updateElementStyle(selectedBlock, selectedElement, { flexDirection: "row", @@ -233,11 +147,7 @@ const ElementDesign: React.FC = ({
updateElementStyle(selectedBlock, selectedElement, { flexDirection: "column", @@ -247,11 +157,7 @@ const ElementDesign: React.FC = ({
updateElementStyle(selectedBlock, selectedElement, { flexDirection: "row-reverse", @@ -261,11 +167,7 @@ const ElementDesign: React.FC = ({
updateElementStyle(selectedBlock, selectedElement, { flexDirection: "column-reverse", @@ -282,22 +184,12 @@ const ElementDesign: React.FC = ({ label="Layer" value={String(currentElement.zIndex || 1)} placeholder={"Layer"} - onChange={(newValue: string) => - updateElementZIndex( - selectedBlock, - selectedElement, - Number(newValue) - ) - } + onChange={(newValue: string) => updateElementZIndex(selectedBlock, selectedElement, Number(newValue))} />
+ { + updateElementStyle(selectedBlock, selectedElement, { + borderRadius: Number(newValue), + }); + }} + />
@@ -443,21 +336,6 @@ const ElementDesign: React.FC = ({ updateElementStyle(selectedBlock, selectedElement, { backdropFilter: `blur(${Number(value)}px)` }); }} /> - { - updateElementStyle(selectedBlock, selectedElement, { - borderRadius: Number(newValue), - }); - }} - />
);