diff --git a/src/App.tsx b/src/App.tsx index 0d89c10..722e02b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -59,7 +59,7 @@ function AudioDeviceArrangerApp() { const [isDarkMode, setIsDarkMode] = useState(() => { const saved = localStorage.getItem('darkMode') - return saved ? JSON.parse(saved) : false + return saved ? JSON.parse(saved) : true }) const [editingDevice, setEditingDevice] = useState(null) @@ -67,10 +67,10 @@ function AudioDeviceArrangerApp() { useEffect(() => { localStorage.setItem('darkMode', JSON.stringify(isDarkMode)) - if (isDarkMode) { - document.documentElement.classList.add('dark') - } else { + if (!isDarkMode) { document.documentElement.classList.remove('dark') + } else { + document.documentElement.classList.add('dark') } }, [isDarkMode]) @@ -117,7 +117,7 @@ function AudioDeviceArrangerApp() { }, animated: true, zIndex: 1010, - type: 'arrow', + type: 'smoothstep', }), [isDarkMode], ) diff --git a/src/components/AddDeviceForm.tsx b/src/components/AddDeviceForm.tsx index ccce557..130cd30 100644 --- a/src/components/AddDeviceForm.tsx +++ b/src/components/AddDeviceForm.tsx @@ -3,6 +3,7 @@ import React, { useState } from 'react' import { Device, Port } from '../types/devices' import * as Form from '@radix-ui/react-form' +import { colorOptions } from '../constants/colors' interface AddDeviceFormProps { onAddDevice: (device: Omit) => void @@ -33,6 +34,7 @@ const AddDeviceForm: React.FC = ({ onAddDevice }) => { id: `input-${Date.now()}`, name: `Input ${inputs.length + 1}`, type: 'input', + color: colorOptions[Math.floor(Math.random() * colorOptions.length)], }, ]) } @@ -44,6 +46,7 @@ const AddDeviceForm: React.FC = ({ onAddDevice }) => { id: `output-${Date.now()}`, name: `Output ${outputs.length + 1}`, type: 'output', + color: colorOptions[Math.floor(Math.random() * colorOptions.length)], }, ]) } diff --git a/src/components/CustomConnectionLine.tsx b/src/components/CustomConnectionLine.tsx index bbb6930..6c84767 100644 --- a/src/components/CustomConnectionLine.tsx +++ b/src/components/CustomConnectionLine.tsx @@ -25,7 +25,7 @@ const CustomConnectionLine: React.FC = ({ diff --git a/src/components/CustomEdge.tsx b/src/components/CustomEdge.tsx index a620385..825947d 100644 --- a/src/components/CustomEdge.tsx +++ b/src/components/CustomEdge.tsx @@ -1,9 +1,24 @@ // src/components/CustomEdge.tsx import React from 'react' -import { getBezierPath, EdgeProps } from '@xyflow/react' +import { getSmoothStepPath, EdgeProps } from '@xyflow/react' -const CustomEdge: React.FC = ({ +interface HandleElement { + id: string + position: string +} + +interface CustomEdgeData { + sourceHandle?: HandleElement & { style?: React.CSSProperties } + targetHandle?: HandleElement & { style?: React.CSSProperties } + onDelete?: (id: string) => void +} + +type CustomEdgeProps = EdgeProps & { + data?: CustomEdgeData +} + +const CustomEdge: React.FC = ({ id, sourceX, sourceY, @@ -13,8 +28,10 @@ const CustomEdge: React.FC = ({ targetPosition, style = {}, data, + // sourceHandle, + // targetHandle, }) => { - const [edgePath] = getBezierPath({ + const [edgePath] = getSmoothStepPath({ sourceX, sourceY, sourcePosition, @@ -23,11 +40,16 @@ const CustomEdge: React.FC = ({ targetPosition, }) + const color = + data?.sourceHandle?.style?.background || + data?.targetHandle?.style?.background || + '#999' + return ( <> diff --git a/src/components/CustomNode.tsx b/src/components/CustomNode.tsx index 41089ae..c99a2e4 100644 --- a/src/components/CustomNode.tsx +++ b/src/components/CustomNode.tsx @@ -11,10 +11,7 @@ interface CustomNodeData extends Device { const CustomNode: React.FC<{ data: CustomNodeData }> = ({ data }) => { return ( -
+
{data.type.charAt(0).toUpperCase()} @@ -37,9 +34,16 @@ const CustomNode: React.FC<{ data: CustomNodeData }> = ({ data }) => { type="target" position={Position.Left} id={input.id} - style={{ left: -8, top: `${(index + 1) * 24}px` }} + style={{ + left: -8, + top: `${(index + 1) * 24}px`, + background: input.color, + }} /> - + {input.name}
@@ -52,14 +56,21 @@ const CustomNode: React.FC<{ data: CustomNodeData }> = ({ data }) => {
{data.outputs.map((output: Port, index: number) => (
- + {output.name}
))} diff --git a/src/components/EditDeviceForm.tsx b/src/components/EditDeviceForm.tsx index 7108227..caab50f 100644 --- a/src/components/EditDeviceForm.tsx +++ b/src/components/EditDeviceForm.tsx @@ -2,6 +2,7 @@ import React, { useState } from 'react' import { Device, Port } from '../types/devices' +import { colorOptions } from '../constants/colors' interface EditDeviceFormProps { device: Device @@ -27,6 +28,7 @@ const EditDeviceForm: React.FC = ({ id: `input-${Date.now()}`, name: `Input ${inputs.length + 1}`, type: 'input', + color: colorOptions[Math.floor(Math.random() * colorOptions.length)], }, ]) } @@ -38,6 +40,7 @@ const EditDeviceForm: React.FC = ({ id: `output-${Date.now()}`, name: `Output ${outputs.length + 1}`, type: 'output', + color: colorOptions[Math.floor(Math.random() * colorOptions.length)], }, ]) } diff --git a/src/constants/colors.ts b/src/constants/colors.ts new file mode 100644 index 0000000..3b185cf --- /dev/null +++ b/src/constants/colors.ts @@ -0,0 +1,12 @@ +export const colorOptions = [ + '#FF6B6B', + '#4ECDC4', + '#45B7D1', + '#FFA07A', + '#98D8C8', + '#F06292', + '#BA68C8', + '#FFD54F', + '#4DB6AC', + '#7986CB', +] diff --git a/src/types/devices.ts b/src/types/devices.ts index ff71bb9..8798d22 100644 --- a/src/types/devices.ts +++ b/src/types/devices.ts @@ -4,6 +4,7 @@ export interface Port { id: string name: string type: 'input' | 'output' + color: string } export interface Device {